HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VOP_OperatorInfo.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: VOP_OperatorInfo.h ( VOP Library, C++)
7  *
8  * COMMENTS: This is additional information available via every VOP
9  * operator.
10  */
11 
12 #ifndef __VOP_OperatorInfo__
13 #define __VOP_OperatorInfo__
14 
15 #include "VOP_API.h"
16 #include "VOP_Types.h"
17 #include <UT/UT_String.h>
18 #include <UT/UT_StringArray.h>
19 #include <UT/UT_Array.h>
20 #include <OP/OP_Operator.h>
21 #include <iosfwd>
22 
27 
29 {
30  VOP_CONNECTOR_FLAG_HIDDEN = 0x0001, // initially hidden
31  VOP_CONNECTOR_FLAG_PARMGEN_CHILD = 0x0002 // defined by Parm VOP child
32 };
33 
34 
35 /// Class containing tags for an input or an output.
37 {
38 public:
39  const VOP_InOutTagMap& operator=(const VOP_InOutTagMap &other);
40 
41  void setTag(const char* name, const char* value);
42  UT_StringHolder getTag(const char* name) const;
43  bool hasTag(const char *name) const;
44 
45  void getTagNames(UT_StringArray &names) const;
46 
47 private:
49  UT_UniquePtr<MapType> myTags;
50 };
51 
52 /// Class containing information about node's input or output connector port.
54 {
55 public:
57  const VOP_TypeInfo &type_info);
58  VOP_InOutInfo(const VOP_InOutInfo &other);
59  ~VOP_InOutInfo();
60 
61  const UT_String &getName() const
62  { return myName; }
63  void setName(const char *name)
64  { myName.harden(name); }
65  const UT_String &getLabel() const
66  { return myLabel; }
67  void setLabel(const char *label)
68  { myLabel.harden(label); }
69 
70  void addTypeInfo(const VOP_TypeInfo &type_info);
71  void insertTypeInfo(const VOP_TypeInfo &newtype, int i);
72  void setTypeInfo(int i, const VOP_TypeInfo &newtype);
73  void removeTypeInfo(int i);
74 
75  const VOP_TypeInfo &getTypeInfo(int i) const;
76  VOP_Type getType(int i) const;
77 
78  void addInputName(const char* name)
79  { myDefaultInputNames.append(name); }
80  void insertInputName(const char *name, int i)
81  { myDefaultInputNames.insert(name, i); }
82  void removeInputName(int i)
83  { myDefaultInputNames.remove(i); }
84 
85  const UT_StringHolder &getInputName(int i) const
86  { return myDefaultInputNames(i); }
87  void setInputName(int i, const char *new_name)
88  { myDefaultInputNames(i) = new_name; }
89 
90  void addValueOption(const VOP_TypeInfo &type_info);
91  void insertValueOption(
92  const VOP_TypeInfo &type_info, int i);
93  void removeValueOption(int i);
94  UT_Options &getValueOption(int i);
95  void changeValueOption(int i, const VOP_TypeInfo &type_info,
96  const char *new_val = NULL);
97 
98  int getNumTypes() const
99  { return myTypeInfos.entries(); }
100  int getNumNames() const
101  { return myDefaultInputNames.entries();}
102  int getNumOptions() const
103  { return myValueOptions.entries();}
104 
105  void setTag(const char* name, const char* value)
106  { myTags.setTag(name, value); }
107  UT_StringHolder getTag(const char* name) const
108  { return myTags.getTag(name); }
109  bool hasTag(const char *name) const
110  { return myTags.hasTag(name); }
112  { return myTags; }
113  void copyTagsFrom(VOP_InOutInfo& src_info)
114  { myTags = src_info.myTags; }
115 
116  void setFlag(VOP_ConnectorFlagType flag_type, bool value)
117  {
118  if(value)
119  myFlags |= flag_type;
120  else
121  myFlags &= ~flag_type;
122  }
123 
125  {
126  return ((myFlags & flag_type) != 0);
127  }
128 
129  void copyFlagsFrom(VOP_InOutInfo& src_info)
130  {
131  myFlags = src_info.myFlags;
132  }
133 
134  void setAllFlags(int flags)
135  {
136  myFlags = flags;
137  }
138 
139  int getAllFlags(void)
140  {
141  return myFlags;
142  }
143 
144 private:
145  UT_String myName;
146  UT_String myLabel;
147  UT_ValArray<VOP_TypeInfo*> myTypeInfos;
148  UT_StringArray myDefaultInputNames;
149  UT_Array<UT_Options> myValueOptions;
150  VOP_InOutTagMap myTags;
151 
152  int myFlags;
153 };
154 
156 {
157 public:
159  virtual ~VOP_OperatorInfo();
160 
161  const VOP_OperatorInfo & operator=(const VOP_OperatorInfo &other);
162 
164  { return myCode; }
165  const UT_String &getCode() const
166  { return myCode; }
168  { return myOuterCode; }
169  const UT_String &getOuterCode() const
170  { return myOuterCode; }
171  void setVopnetMask(const char *mask);
172  const UT_String &getVopnetMask() const
173  { return myVopnetMask; }
174  void setRenderMask(const char *mask);
175  const UT_String &getRenderMask() const
176  { return myRenderMask; }
178  { return myOutputInfos; }
180  { return myOutputInfos; }
182  { return myInputInfos; }
184  { return myInputInfos; }
186  { return myInputSetNames; }
188  { return myInputSetNames; }
190  { return myInputSetLabels; }
192  { return myInputSetLabels; }
194  { return myForceCodeGeneration; }
195  const bool &getForceCodeGeneration() const
196  { return myForceCodeGeneration; }
198  { return myExternalShader; }
199  const bool &getExternalShader() const
200  { return myExternalShader; }
202  { return myShaderType; }
204  { myShaderType = t; }
205 
206  void clearInOutInfo();
207  virtual void saveToDialogScript(std::ostream &os) const;
208  virtual void updateExtraInfoBuffer(OP_ExtraInfoBuffer &b) const;
209 
210  /// Obtains a name of a node parameter that corresponds to a given
211  /// input name when the node uses the given signature.
212  /// @{
213  void getParmNameFromInput(UT_String &parm_name,
214  const char *input_name, int input_set_index) const;
215  void getParmNameFromInput(UT_WorkBuffer &parm_name,
216  const char *input_name, int input_set_index) const;
217  /// @}
218 
219  /// Obtains a name of the input given parameter name, considering
220  /// the available signatures in this class.
221  void getInputNameFromParm(UT_String &input_name,
222  const char *parm_name) const;
223 
224  /// Returns a new language context object based on this operator info.
225  /// Caller is responsible for deleting the returned object.
226  VOP_LanguageContextTypeList *newLanguageContextTypeList() const;
227 
228 protected:
229  static void saveInOutInfoToDialogScript(std::ostream &os,
230  const UT_ValArray<VOP_InOutInfo *> &infoarray,
231  const char *infotype);
232  static void saveInputFlags(std::ostream &os,
233  const UT_ValArray<VOP_InOutInfo *> &inoutarray,
234  const char *token, bool only_nonzero_flags);
235 
236 private:
237  UT_ValArray<VOP_InOutInfo *> myOutputInfos;
238  UT_ValArray<VOP_InOutInfo *> myInputInfos;
239  UT_StringArray myInputSetNames;
240  UT_StringArray myInputSetLabels;
241  UT_String myVopnetMask;
242  UT_String myRenderMask;
243  UT_String myOuterCode;
244  UT_String myCode;
245  VOP_Type myShaderType;
246  bool myForceCodeGeneration;
247  bool myExternalShader;
248 };
249 
250 #endif
251 
UT_String & getOuterCode()
const UT_String & getOuterCode() const
const UT_String & getLabel() const
const UT_StringArray & getInputSetLabels() const
void setName(const char *name)
VOP_ConnectorFlagType
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
void setTag(const char *name, const char *value)
int getNumNames() const
UT_ValArray< VOP_InOutInfo * > & getInputInfos()
void copyTagsFrom(VOP_InOutInfo &src_info)
Class containing information about node's input or output connector port.
UT_String & getCode()
int getNumTypes() const
GLint GLuint mask
Definition: glcorearb.h:123
GLbitfield flags
Definition: glcorearb.h:1595
const UT_StringHolder & getInputName(int i) const
bool hasTag(const char *name) const
png_uint_32 i
Definition: png.h:2877
UT_Array< VOP_Type > VOP_VopTypeArray
const bool & getForceCodeGeneration() const
void copyFlagsFrom(VOP_InOutInfo &src_info)
virtual void updateExtraInfoBuffer(OP_ExtraInfoBuffer &b) const
Definition: OP_Operator.h:104
UT_ValArray< VOP_InOutInfo * > & getOutputInfos()
bool & getExternalShader()
void setShaderType(VOP_Type t)
UT_StringArray & getInputSetLabels()
#define VOP_API
Definition: VOP_API.h:10
const UT_String & getCode() const
void setAllFlags(int flags)
void setInputName(int i, const char *new_name)
const bool & getExternalShader() const
const VOP_InOutTagMap & getTagsMap() const
GLuint const GLchar * name
Definition: glcorearb.h:785
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
virtual void saveToDialogScript(std::ostream &os) const =0
void removeInputName(int i)
GLsizei const GLfloat * value
Definition: glcorearb.h:823
A map of string to various well defined value types.
Definition: UT_Options.h:42
void insertInputName(const char *name, int i)
const UT_String & getName() const
int getAllFlags(void)
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:47
int getNumOptions() const
bool & getForceCodeGeneration()
VOP_Type
Definition: VOP_Types.h:24
Class containing tags for an input or an output.
VOP_Type getShaderType() const
const UT_ValArray< VOP_InOutInfo * > & getInputInfos() const
const UT_String & getRenderMask() const
UT_StringHolder getTag(const char *name) const
bool hasFlag(VOP_ConnectorFlagType flag_type)
const UT_ValArray< VOP_InOutInfo * > & getOutputInfos() const
UT_Array< VOP_TypeInfo > VOP_VopTypeInfoArray
UT_StringArray & getInputSetNames()
const UT_String & getVopnetMask() const
void setFlag(VOP_ConnectorFlagType flag_type, bool value)
void setLabel(const char *label)
void addInputName(const char *name)
const UT_StringArray & getInputSetNames() const