HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_OTLDefinition.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: OP_OTLDefinition.h ( OTL Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __OP_OTLDefinition__
13 #define __OP_OTLDefinition__
14 
15 #include "OP_API.h"
16 #include "OP_Node.h"
17 #include <UT/UT_StringHolder.h>
18 #include <UT/UT_ValArray.h>
19 #include <iosfwd>
20 
21 class UT_String;
22 class UT_WorkBuffer;
23 
24 
25 // In addition to alphanumeric and '_' characters, these are the characters
26 // that are legal in the operator type name.
27 // '.' - allowed for version numbering
28 // ':' - used for namespaces
29 // '/' - used for namespaces (scoping within another operator, which requires
30 // a slash for "table/opname" specification)
31 #define OTL_LEGAL_OPTYPE_NAME_CHARS ".:/"
32 
33 
35 {
36 public:
38 
39  OP_OTLDefinition(const OP_OTLDefinition &definition) = default;
40  OP_OTLDefinition &operator=(const OP_OTLDefinition &src) = default;
41 
42  const UT_StringHolder &getName() const
43  { return myName; }
45  { myName = name; }
46  const UT_StringHolder &getLabel() const
47  { return myLabel; }
49  { myLabel = label; }
50  const UT_StringHolder &getPath() const
51  { return myPath; }
53  { myPath = path; }
54  const UT_StringHolder &getIcon() const
55  { return myIcon; }
56  void setIcon(const UT_StringHolder &icon)
57  { myIcon = icon; }
58  const UT_StringHolder &getAuthor() const
59  { return myAuthor; }
60  void setAuthor(const UT_StringHolder &author)
61  { myAuthor = author; }
63  { return myCopyright; }
64  void setCopyright(const UT_StringHolder &copyright)
65  { myCopyright = copyright; }
67  { return myOpTableName; }
68  void setOpTableName(const UT_StringHolder &optablename)
69  { myOpTableName = optablename; }
71  { return myIndexPath; }
72  void setIndexPath(const UT_StringHolder &indexpath)
73  { myIndexPath = indexpath; }
75  { return myIndexFile; }
76  void setIndexFile(const UT_StringHolder &indexfile)
77  { myIndexFile = indexfile; }
79  { return myLicenseInfo; }
80  void setLicenseInfo(const UT_StringHolder &licenseinfo)
81  { myLicenseInfo = licenseinfo; }
83  { return myExtraInfo; }
84  void setExtraInfo(const UT_StringHolder &extrainfo)
85  { myExtraInfo = extrainfo; }
87  { return myUserInfo; }
88  void setUserInfo(const UT_StringHolder &userinfo)
89  { myUserInfo = userinfo; }
90  int getMinInputs() const
91  { return myMinInputs; }
92  void setMinInputs(int inputs)
93  { myMinInputs = inputs; }
94  int getMaxInputs() const
95  { return myMaxInputs; }
96  void setMaxInputs(int inputs)
97  { myMaxInputs = inputs; }
98  int getNumOrderedInputs() const
99  { return myNumOrderedInputs; }
100  void setNumOrderedInputs(int inputs)
101  { myNumOrderedInputs = inputs; }
102  int getMaxOutputs() const
103  { return myMaxOutputs; }
104  void setMaxOutputs(int outputs)
105  { myMaxOutputs = outputs; }
106  int getModTime() const
107  { return myModTime; }
108  void setModTime(int modtime)
109  { myModTime = modtime; }
110  bool getIsSubnet() const
111  { return myIsSubnet; }
112  void setIsSubnet(bool issubnet)
113  { myIsSubnet = issubnet ? 1 : 0; }
114  bool getIsPython() const
115  { return myIsPython; }
116  void setIsPython(bool ispython)
117  { myIsPython = ispython ? 1 : 0; }
118  bool getIsDummyDefinition() const
119  { return myIsDummyDefinition; }
120  void setIsDummyDefinition(bool isdummy)
121  { myIsDummyDefinition = isdummy ? 1 : 0; }
123  { return myCachedLicenseType; }
125  { myCachedLicenseType = type; }
126 
127  /// Return if this is an internally defined operator
128  bool isInternal() const
129  { return myPath == theInternalPath.asRef(); }
130 
131  /// Mark as internal
133  { setPath(theInternalPath.asHolder()); }
134 
135  // Handle options that appear in index files (-icon, -inputs, etc.).
136  int handleOption(int argc, char *argv[]);
137  // Concatenates the op table name and the op name to get a unique name.
138  void getTableAndName(UT_WorkBuffer &name) const;
139  void getTableAndName(UT_String &name) const;
140 
141  // Converts the table name into an OP_OpTypeId.
142  OP_OpTypeId getOpTypeId() const;
143 
144  bool load(UT_IStream &is,
145  UT_StringHolder *errors = nullptr);
146  bool save(std::ostream &os);
147  // Writes a text description that is easily readable by the user.
148  void writeTextDescription(UT_WorkBuffer &buffer,
149  const char *indent = 0) const;
150  // Writes a text description based on the format string. The format
151  // string is a series of characters. Each character represents one
152  // piece of information. The information is output on a single line.
153  void writeFormattedText(UT_WorkBuffer &buffer,
154  const char *format) const;
155  // Read in a text description written out as above. We return false if an
156  // invalid or malformed description is found. We return true if we read in
157  // a good description _or_ if we reach the end of the stream before even
158  // starting a description.
159  bool readTextDescription(UT_IStream &is);
160 
161  /// Returns an official name of the library section that contains
162  /// the HDA definition eg "Object/hda", or "artistA::Object/hda::2.0".
163  /// See UT_OpUtils::getOpTypeDefSectionName() for more details.
164  /// @{
165  void getDefinitionSectionName(UT_String &sectname) const;
166  void getDefinitionSectionName(UT_WorkBuffer &sectname) const;
167  /// @}
168 
169  /// Returns an official file path that should be used for a given
170  /// definition, eg "oplib:/Object/hda?Object/hda".
171  void constructDefinitionPath(UT_String &path) const;
172 
173  /// Utility function for converting a string to a modification time.
174  static int getModTimeFromString(const char *str);
175 
176  /// Returns true if the name is a valid operator name that can be used for
177  /// an OP_Operator instance.
178  static bool isValidOperatorName(const char *name);
179 
180  /// Returns true if op_name includes a namespace and that namesapce
181  /// matches the given scope_opname, e.g., op_name of "Object/geo::op"
182  /// matches scope_name of "Object/geo".
183  /// If op_name does not include a namespace, it is allowed everywhere,
184  /// so it will match any scope, thus this function will return true.
185  /// Returns false otherwise.
186  static bool isMatchingNamespaceScope( const char *op_name,
187  const char *scope_opname );
188 
189 private:
190  UT_StringHolder myName;
191  UT_StringHolder myLabel;
192  UT_StringHolder myPath;
193  UT_StringHolder myIcon;
194  UT_StringHolder myAuthor;
195  UT_StringHolder myCopyright;
196  UT_StringHolder myOpTableName;
197  UT_StringHolder myIndexPath;
198  UT_StringHolder myIndexFile;
199  UT_StringHolder myLicenseInfo;
200  UT_StringHolder myExtraInfo;
201  UT_StringHolder myUserInfo;
202  int32 myMinInputs;
203  int32 myMaxInputs;
204  int32 myNumOrderedInputs;
205  int32 myMaxOutputs;
206  int32 myModTime;
207  char myIsSubnet;
208  char myIsPython;
209  char myIsDummyDefinition;
210  OP_OTLLicenseType myCachedLicenseType;
211 
212  // Path value that marks definition as isInternal()
213  static const UT_StringLit theInternalPath;
214 };
215 
217 
218 #endif
219 
type
Definition: core.h:977
UT_ValArray< OP_OTLDefinition * > OP_OTLDefinitionArray
int int32
Definition: SYS_Types.h:39
void setLicenseInfo(const UT_StringHolder &licenseinfo)
const UT_StringHolder & getLicenseInfo() const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
bool getIsPython() const
const UT_StringHolder & getUserInfo() const
const UT_StringHolder & getLabel() const
void setIsSubnet(bool issubnet)
int getNumOrderedInputs() const
void setMaxOutputs(int outputs)
void setUserInfo(const UT_StringHolder &userinfo)
GLuint const GLchar * name
Definition: glcorearb.h:785
GLenum src
Definition: glcorearb.h:1792
GLuint buffer
Definition: glcorearb.h:659
const UT_StringHolder & getIcon() const
bool getIsDummyDefinition() const
const UT_StringHolder & getAuthor() const
void setLabel(const UT_StringHolder &label)
void setNumOrderedInputs(int inputs)
bool isInternal() const
Return if this is an internally defined operator.
void setIcon(const UT_StringHolder &icon)
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
void setExtraInfo(const UT_StringHolder &extrainfo)
const UT_StringHolder & getPath() const
void setIsPython(bool ispython)
OP_OTLLicenseType getCachedLicenseType() const
int getMaxInputs() const
void setCopyright(const UT_StringHolder &copyright)
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
OP_OpTypeId
Definition: OP_OpTypeId.h:18
void setName(const UT_StringHolder &name)
int getMinInputs() const
int getModTime() const
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
void setMinInputs(int inputs)
void setPath(const UT_StringHolder &path)
void setIndexFile(const UT_StringHolder &indexfile)
#define OP_API
Definition: OP_API.h:10
OP_OTLLicenseType
const UT_StringHolder & getIndexFile() const
void setCachedLicenseType(OP_OTLLicenseType type)
int getMaxOutputs() const
void setIndexPath(const UT_StringHolder &indexpath)
void setOpTableName(const UT_StringHolder &optablename)
const UT_StringHolder & getName() const
void setPathToInternal()
Mark as internal.
void setAuthor(const UT_StringHolder &author)
bool getIsSubnet() const
void setModTime(int modtime)
const UT_StringHolder & getIndexPath() const
void setIsDummyDefinition(bool isdummy)
void setMaxInputs(int inputs)
const UT_StringHolder & getCopyright() const
const UT_StringHolder & getOpTableName() const
const UT_StringHolder & getExtraInfo() const