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