forked from ahmidou/SpliceAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDGPortImpl.h
204 lines (151 loc) · 7.36 KB
/
DGPortImpl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// Copyright 2010-2013 Fabric Engine Inc. All rights reserved.
#ifndef __FabricSpliceImpl_PORTIMPL_H__
#define __FabricSpliceImpl_PORTIMPL_H__
#include "LoggingImpl.h"
#include "ObjectImpl.h"
#include "TypeDefs.h"
#include <FabricCore.h>
#include <limits.h>
namespace FabricSpliceImpl
{
class DGPortImpl : public ObjectImpl
{
friend class DGGraphImpl;
public:
enum Mode
{
Mode_IN,
Mode_OUT,
Mode_IO
};
/*
Constructors / Destructors
*/
~DGPortImpl();
/*
Basic data getters
*/
/// returns the name of the member this DGPort is connected to
char const * getMember() const { return mMember.c_str(); }
/// returns the name of the FabricCore::DGNode this DGPort is connected to
char const * getDGNodeName() const { return mDGNodeName.c_str(); }
/// returns a unique key descripting the DGPort
char const * getKey() const { return mKey.c_str(); }
/// returns the FabricSpliceImpl::DGGraph this DGPort belongs to
DGGraphImplPtr getDGGraph();
/// returns the mode of this DGPort
Mode getMode() const { return mMode; }
/// sets the mode of this DGPort
void setMode(Mode mode) { mMode = mode; }
/// returns the data type of the member this DGPort is connected to
char const * getDataType() const { return mDataType.c_str(); }
/// returns the data size of a single element of the member this DGPort is connected to.
/// So for example, both for a 'Vec3' and 'Vec3[]' this will return sizeof(Vec3) == 12
uint32_t getDataSize() const { return mDataSize; }
/// returns true if the data type of this DGPort is shallow.
/// only shallow data types can be used with the high performance IO
bool isShallow() const { return mIsShallow; }
/// returns true if the data type of this DGPort is an array (Vec3[] for example)
bool isArray() const { return mIsArray; }
/// returns true if the data type of this DGPort is a struct
bool isStruct() const { return mIsStruct; }
/// returns true if the data type of this DGPort is an object
bool isObject() const { return mIsObject; }
/// returns true if the data type of this DGPort is an interface
bool isInterface() const { return mIsInterface; }
/// returns true if this port auto initializes KL objects
bool doesAutoInitObjects() const { return mAutoInitObjects; }
/*
FabricCore slicing management
*/
/// returns the slice count of the FabricCore::DGNode this DGPort is connected to
uint32_t getSliceCount(std::string * errorOut = NULL);
/// sets the slice count of the FabricCore::DGNode this DGPort is connected to
bool setSliceCount(uint32_t count, std::string * errorOut = NULL);
/*
FabricCore::Variant IO
*/
/// returns the value of a specific slice of this DGPort as a FabricCore::Variant
FabricCore::Variant getVariant(uint32_t slice = 0, std::string * errorOut = NULL);
/// sets the value of a specific slice of this DGPort from a FabricCore::Variant
bool setVariant(FabricCore::Variant value, uint32_t slice = 0, std::string * errorOut = NULL);
/// returns the value of a specific slice of this DGPort as a JSON string
std::string getJSON(uint32_t slice = 0, std::string * errorOut = NULL);
/// sets the value of a specific slice of this DGPort from a JSON string
bool setJSON(const std::string & json, uint32_t slice = 0, std::string * errorOut = NULL);
/// returns the default value of this DGPort as a FabricCore::Variant
FabricCore::Variant getDefault(std::string * errorOut = NULL);
/*
FabricCore::RTVal IO
*/
/// returns the value of a specific slice of this DGPort as a FabricCore::RTVal
FabricCore::RTVal getRTVal(bool evaluate = false, uint32_t slice = 0, std::string * errorOut = NULL);
/// sets the value of a specific slice of this DGPort from a FabricCore::RTVal
bool setRTVal(FabricCore::RTVal value, uint32_t slice = 0, std::string * errorOut = NULL);
/*
High Performance IO
void* access to the internal data of the FabricCore::DGNode is only possible
for shallow data types (like Vec3 for example).
*/
/// returns the size of an array member this DGPort is connected to
uint32_t getArrayCount(uint32_t slice = 0, std::string * errorOut = NULL);
/// returns the void* array data of this DGPort.
/// this only works for array DGPorts (isArray() == true)
/// the bufferSize has to match getArrayCount() * getDataSize()
bool getArrayData(void * buffer, uint32_t bufferSize, uint32_t slice = 0, std::string * errorOut = NULL);
/// sets the void* array data of this DGPort.
/// this only works for array DGPorts (isArray() == true)
/// this also sets the array count determined by bufferSize / getDataSize()
bool setArrayData(void * buffer, uint32_t bufferSize, uint32_t slice = 0, std::string * errorOut = NULL);
/// gets the void* slice array data of this DGPort.
/// this only works for non-array DGPorts (isArray() == false)
/// the bufferSize has to match getSliceCount() * getDataSize()
bool getAllSlicesData(void * buffer, uint32_t bufferSize, std::string * errorOut = NULL);
/// sets the void* slice array data of this DGPort.
/// this only works for non-array DGPorts (isArray() == false)
/// the bufferSize has to match getSliceCount() * getDataSize()
bool setAllSlicesData(void * buffer, uint32_t bufferSize, std::string * errorOut = NULL);
/// set the array data based on another port
/// this performs data replication, and only works on shallow array data ports.
/// the data type has to match as well (so only Vec3 to Vec3 for example).
bool copyArrayDataFromDGPort(DGPortImplPtr other, uint32_t slice = 0, uint32_t otherSlice = UINT_MAX, std::string * errorOut = NULL);
/// set the slices data based on another port
/// this performs data replication, and only works on shallow non array data ports.
/// the data type has to match as well (so only Vec3 to Vec3 for example).
bool copyAllSlicesDataFromDGPort(DGPortImplPtr other, bool resizeTarget = false, std::string * errorOut = NULL);
/*
Auxiliary option management
*/
// sets an auxiliary option
void setOption(const std::string & name, const FabricCore::Variant & value);
// gets an auxiliary option (empty variant if not defined)
FabricCore::Variant getOption(const std::string & name);
// gets a dictionary of all options
FabricCore::Variant getAllOptions();
private:
DGPortImpl(DGGraphImplPtr thisGraph, const std::string & name, const std::string & member, FabricCore::DGNode dgNode, const std::string & dgNodeName, Mode mode, uint32_t dataSize, bool shallow, bool autoInitObjects);
DGGraphImplWeakPtr mGraph;
std::string mGraphName;
std::string mKey;
std::string mMember;
bool mAutoInitObjects;
FabricCore::DGNode mDGNode;
std::string mDGNodeName;
Mode mMode;
std::string mDataType;
bool mIsShallow;
bool mIsArray;
bool mIsStruct;
bool mIsObject;
bool mIsInterface;
uint32_t mDataSize;
// int mManipulatable;
std::map<std::string,FabricCore::Variant> mOptions;
};
typedef std::map<std::string, DGPortImplPtr> DGPortMap;
typedef DGPortMap::iterator DGPortIt;
typedef DGPortMap::const_iterator DGPortConstIt;
typedef std::pair<std::string, DGPortImplPtr> DGPortPair;
};
#include "DGGraphImpl.h"
#endif