HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_ScriptPage.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: PRM_ScriptPage.h ( PRM Library, C++)
7  *
8  * COMMENTS: A page of scripted parameters. These pages are used to define
9  * the folder tabs for each page in a std. switcher.
10  */
11 
12 #ifndef __PRM_ScriptPage__
13 #define __PRM_ScriptPage__
14 
15 #include "PRM_API.h"
16 #include <UT/UT_NonCopyable.h>
17 #include <UT/UT_String.h>
18 #include <UT/UT_ValArray.h>
19 
20 #define ISERROR(msg) { is.error(msg); return 0; }
21 #define ISWARNING(msg) { is.warning(msg); }
22 
23 class DS_Stream;
24 class PRM_ScriptParm;
25 class PRM_Template;
26 class PRM_ScriptImports;
27 class PRM_SpareData;
29 
31 {
32 public:
34  virtual ~PRM_ScriptPage();
35 
37 
38  enum
39  {
40  PRM_SCRIPT_RMAN = 0x01, // RenderMan style command script
41  PRM_SCRIPT_SHELL = 0x02, // Shell style command script
42  PRM_SCRIPT_VEX = 0x04, // Vex style command script
43  PRM_SCRIPT_INVISIBLE = 0x08, // This group of parms is invisible
44  PRM_SCRIPT_INVISIBLETAB = 0x10, // This page of parms is invisible
45  PRM_SCRIPT_OBSOLETE = 0x20 // This group/page of parms is obsolete
46  };
47 
48  /// normally, we are parsing the whole stream & thus expect the opening
49  /// brace. However, a derived Reader might want to read some meta data,
50  /// then hand off to us, in which case expect_open_brace will be false.
51  int parse(DS_Stream &is,
52  bool expect_open_brace,
53  PRM_ScriptParm *group_owner_parm,
54  bool parsing_import,
55  bool fix_invalid_joins=true,
56  int multiparm_depth=0);
57 
58  void appendScriptParms(
60 
61  const char *getToken() const { return myToken; }
62  void setToken(const char *token) { myToken = token; }
63  const char *getLabel() const { return myLabel; }
64  const char *getDefault() const { return myDefault; }
65  PRM_ScriptParm *getParm(int i) { return myParms(i); }
66  int getParmEntries() const { return myParms.entries(); }
67  bool getBaseParm() const { return myBaseParm; }
68  bool getTabBreak() const { return myTabBreak; }
70  { return myConditionalGroup; }
72  { return myConditionalPage; }
73  PRM_SpareData *getSpareData(bool create=false);
74  void enforceOptions();
75 
76  bool containsReservedName() const;
77 
78  // Set the default if there is no default defined...
79  void setEmptyDefault(const char *str)
80  {
81  if (!myDefault.isstring())
82  myDefault.harden(str);
83  }
84 
85  void setFlag(unsigned flag) { myFlag |= flag; }
86  void clearFlag(unsigned flag) { myFlag &= ~flag; }
87  unsigned getFlag(unsigned bit) const { return myFlag & bit;}
88 
89  // By default, this will simply return the number of parameters in my page
90  virtual int countParameters() const;
91 
92  // Gets the actual number of templates required by this page, including
93  // all pages within pages and so on.
94  int computeTemplateSize();
95  // Fills an array of PRM_Templates from all our parms. The size of the
96  // array must be at least computeTemplateSize() + 1. By passing in a
97  // non-zero idx starting value the templates from this page can be
98  // appended after some existing templates.
99  void fillTemplate(PRM_Template *tplate, int &idx,
100  PRM_ScriptImports *&imports);
101 
102  // Obsolete template handling.
103  int computeObsoleteTemplateSize();
104  void fillObsoleteTemplate(PRM_Template *tplate);
105 
107  {
108  const char *token;
110  };
111 
112  /// a list of tokens not handled by PRM_ScriptPage, but which may be
113  /// handled by my subclasses or should at least be ignored without
114  /// generating an error. Each token contains the expected parameter count.
115  /// Negative values indicate tokens that take brace-enclosed blocks.
116  static const TokenParmCount theTokens[];
117 
118 protected:
119  friend class PRM_ScriptGroup;
120 
121  virtual PRM_ScriptParm *newParm();
122  virtual PRM_ScriptPage *newImportPage();
123  virtual int parseHelp(DS_Stream &is, UT_String &help);
124  virtual int handleUnknown(DS_Stream &is, UT_String &token);
125  int parseImport(DS_Stream &is,
126  int multiparm_depth);
127  void processImportPage(PRM_ScriptPage *page);
128  int parseAttribute(DS_Stream &is);
129 
130  void fillTemplate(PRM_Template *tplate, int &idx,
131  PRM_ScriptImports *&imports,
132  int nest_level, int switcher_idx,
133  int folder);
134 
135 
151  unsigned myFlag;
152 
153 };
154 
155 #endif
PRM_ScriptImports * myImports
void fillTemplate(PRM_Template *array, int &idx, PRM_ScriptImports *&imports, int nest_level)
int getParmEntries() const
void setToken(const char *token)
PRM_SpareData * mySpareData
const char * getToken() const
UT_ValArray< PRM_ScriptParm * > myObsoleteParms
std::string help(const App *app, const Error &e)
Printout the full help string on error (if this fn is set, the old default for CLI11) ...
Definition: CLI11.h:8978
UT_String myImportToken
UT_String myLabel
PRM_ConditionalGroup * getPageConditional() const
bool getBaseParm() const
PRM_ConditionalGroup * myConditionalPage
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
void setFlag(unsigned flag)
void setEmptyDefault(const char *str)
UT_String myImportMask
const char * getDefault() const
void clearFlag(unsigned flag)
PRM_ConditionalGroup * getGroupConditional() const
GA_API const UT_StringHolder parms
UT_String myImportSource
bool getTabBreak() const
PRM_ScriptParm * getParm(int i)
This class allow setting multiple conditionals for a PRM_Template.
const char * getLabel() const
PRM_ConditionalGroup * myConditionalGroup
UT_String myToken
UT_String myDefault
unsigned getFlag(unsigned bit) const
UT_ValArray< PRM_ScriptParm * > myParms
#define PRM_API
Definition: PRM_API.h:10