HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_StringHolder.h>
20 #include <UT/UT_Array.h>
21 #include <OP/OP_Operator.h>
22 #include <iosfwd>
23 
28 
30 {
31  VOP_CONNECTOR_FLAG_HIDDEN = 0x0001, // initially hidden
32  VOP_CONNECTOR_FLAG_PARMGEN_CHILD = 0x0002 // defined by Parm VOP child
33 };
34 
35 
36 /// Class containing tags for an input or an output.
38 {
39 public:
40  const VOP_InOutTagMap& operator=(const VOP_InOutTagMap &other);
41 
42  void setTag(const char* name, const char* value);
43  UT_StringHolder getTag(const char* name) const;
44  bool hasTag(const char *name) const;
45 
46  void getTagNames(UT_StringArray &names) const;
47 
48 private:
50  UT_UniquePtr<MapType> myTags;
51 };
52 
53 /// Class containing information about node's input or output connector port.
55 {
56 public:
58  const VOP_TypeInfo &type_info);
59  VOP_InOutInfo(const VOP_InOutInfo &other);
60  ~VOP_InOutInfo();
61 
62  const UT_StringHolder &getName() const
63  { return myName; }
64  void setName(const UT_StringHolder &name)
65  { myName = name; }
66  const UT_StringHolder &getLabel() const
67  { return myLabel; }
68  void setLabel(const UT_StringHolder &label)
69  { myLabel = label; }
70 
71  void addTypeInfo(const VOP_TypeInfo &type_info);
72  void insertTypeInfo(const VOP_TypeInfo &newtype, int i);
73  void setTypeInfo(int i, const VOP_TypeInfo &newtype);
74  void removeTypeInfo(int i);
75 
76  const VOP_TypeInfo &getTypeInfo(int i) const;
77  VOP_Type getType(int i) const;
78 
79  void addInputName(const char* name)
80  { myDefaultInputNames.append(name); }
81  void insertInputName(const char *name, int i)
82  { myDefaultInputNames.insert(name, i); }
83  void removeInputName(int i)
84  { myDefaultInputNames.remove(i); }
85 
86  const UT_StringHolder &getInputName(int i) const
87  { return myDefaultInputNames(i); }
88  void setInputName(int i, const char *new_name)
89  { myDefaultInputNames(i) = new_name; }
90 
91  void addValueOption(const VOP_TypeInfo &type_info);
92  void insertValueOption(
93  const VOP_TypeInfo &type_info, int i);
94  void removeValueOption(int i);
95  UT_Options &getValueOption(int i);
96  void changeValueOption(int i, const VOP_TypeInfo &type_info,
97  const char *new_val = NULL);
98 
99  int getNumTypes() const
100  { return myTypeInfos.entries(); }
101  int getNumNames() const
102  { return myDefaultInputNames.entries();}
103  int getNumOptions() const
104  { return myValueOptions.entries();}
105 
106  void setTag(const char* name, const char* value)
107  { myTags.setTag(name, value); }
108  UT_StringHolder getTag(const char* name) const
109  { return myTags.getTag(name); }
110  bool hasTag(const char *name) const
111  { return myTags.hasTag(name); }
113  { return myTags; }
114  void copyTagsFrom(VOP_InOutInfo& src_info)
115  { myTags = src_info.myTags; }
116 
117  void setFlag(VOP_ConnectorFlagType flag_type, bool value)
118  {
119  if(value)
120  myFlags |= flag_type;
121  else
122  myFlags &= ~flag_type;
123  }
124 
126  {
127  return ((myFlags & flag_type) != 0);
128  }
129 
130  void copyFlagsFrom(VOP_InOutInfo& src_info)
131  {
132  myFlags = src_info.myFlags;
133  }
134 
135  void setAllFlags(int flags)
136  {
137  myFlags = flags;
138  }
139 
140  int getAllFlags(void)
141  {
142  return myFlags;
143  }
144 
145 private:
146  UT_StringHolder myName;
147  UT_StringHolder myLabel;
148  UT_ValArray<VOP_TypeInfo*> myTypeInfos;
149  UT_StringArray myDefaultInputNames;
150  UT_Array<UT_Options> myValueOptions;
151  VOP_InOutTagMap myTags;
152 
153  int myFlags;
154 };
155 
157 {
158 public:
160  virtual ~VOP_OperatorInfo();
161 
162  const VOP_OperatorInfo & operator=(const VOP_OperatorInfo &other);
163 
165  { return myCode; }
166  const UT_String &getCode() const
167  { return myCode; }
169  { return myOuterCode; }
170  const UT_String &getOuterCode() const
171  { return myOuterCode; }
172  void setVopnetMask(const char *mask);
173  const UT_String &getVopnetMask() const
174  { return myVopnetMask; }
175  void setRenderMask(const char *mask);
176  const UT_String &getRenderMask() const
177  { return myRenderMask; }
179  { return myOutputInfos; }
181  { return myOutputInfos; }
183  { return myInputInfos; }
185  { return myInputInfos; }
187  { return myInputSetNames; }
189  { return myInputSetNames; }
191  { return myInputSetLabels; }
193  { return myInputSetLabels; }
195  { return myForceCodeGeneration; }
196  const bool &getForceCodeGeneration() const
197  { return myForceCodeGeneration; }
199  { return myExternalShader; }
200  const bool &getExternalShader() const
201  { return myExternalShader; }
203  { return myShaderType; }
205  { myShaderType = t; }
206 
207  void clearInOutInfo();
208  virtual void saveToDialogScript(std::ostream &os) const;
209  virtual void updateExtraInfoBuffer(OP_ExtraInfoBuffer &b) const;
210 
211  /// Obtains a name of a node parameter that corresponds to a given
212  /// input name when the node uses the given signature.
213  /// @{
214  void getParmNameFromInput(UT_String &parm_name,
215  const char *input_name, int input_set_index) const;
216  void getParmNameFromInput(UT_WorkBuffer &parm_name,
217  const char *input_name, int input_set_index) const;
218  /// @}
219 
220  /// Obtains a name of the input given parameter name, considering
221  /// the available signatures in this class.
222  void getInputNameFromParm(UT_String &input_name,
223  const char *parm_name) const;
224 
225  /// Returns a new language context object based on this operator info.
226  /// Caller is responsible for deleting the returned object.
227  VOP_LanguageContextTypeList *newLanguageContextTypeList() const;
228 
229 protected:
230  static void saveInOutInfoToDialogScript(std::ostream &os,
231  const UT_ValArray<VOP_InOutInfo *> &infoarray,
232  const char *infotype);
233  static void saveInputFlags(std::ostream &os,
234  const UT_ValArray<VOP_InOutInfo *> &inoutarray,
235  const char *token, bool only_nonzero_flags);
236 
237 private:
238  UT_ValArray<VOP_InOutInfo *> myOutputInfos;
239  UT_ValArray<VOP_InOutInfo *> myInputInfos;
240  UT_StringArray myInputSetNames;
241  UT_StringArray myInputSetLabels;
242  UT_String myVopnetMask;
243  UT_String myRenderMask;
244  UT_String myOuterCode;
245  UT_String myCode;
246  VOP_Type myShaderType;
247  bool myForceCodeGeneration;
248  bool myExternalShader;
249 };
250 
251 #endif
252 
UT_String & getOuterCode()
const UT_String & getOuterCode() const
void setLabel(const UT_StringHolder &label)
const UT_StringArray & getInputSetLabels() const
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:106
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)
const UT_StringHolder & getLabel() const
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)
int getAllFlags(void)
void setName(const UT_StringHolder &name)
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_StringHolder & getName() 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 addInputName(const char *name)
const UT_StringArray & getInputSetNames() const