HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_String.h>
17 #include <UT/UT_ValArray.h>
18 
19 #define ISERROR(msg) { is.error(msg); return 0; }
20 #define ISWARNING(msg) { is.warning(msg); }
21 
22 class DS_Stream;
23 class PRM_ScriptParm;
24 class PRM_Template;
25 class PRM_ScriptImports;
26 class PRM_SpareData;
28 
30 public:
32  virtual ~PRM_ScriptPage();
33 
34  enum {
35  PRM_SCRIPT_RMAN = 0x01, // RenderMan style command script
36  PRM_SCRIPT_SHELL = 0x02, // Shell style command script
37  PRM_SCRIPT_VEX = 0x04, // Vex style command script
38  PRM_SCRIPT_INVISIBLE = 0x08, // This group of parms is invisible
39  PRM_SCRIPT_INVISIBLETAB = 0x10, // This page of parms is invisible
40  PRM_SCRIPT_OBSOLETE = 0x20 // This group/page of parms is obsolete
41  };
42 
43  /// normally, we are parsing the whole stream & thus expect the opening
44  /// brace. However, a derived Reader might want to read some meta data,
45  /// then hand off to us, in which case expect_open_brace will be false.
46  int parse(DS_Stream &is,
47  bool expect_open_brace,
48  PRM_ScriptParm *group_owner_parm,
49  bool parsing_import,
50  bool fix_invalid_joins=true);
51 
52  void appendScriptParms(
54 
55  const char *getToken() const { return myToken; }
56  void setToken(const char *token) { myToken = token; }
57  const char *getLabel() const { return myLabel; }
58  const char *getDefault() const { return myDefault; }
59  PRM_ScriptParm *getParm(int i) { return myParms(i); }
60  int getParmEntries() const { return myParms.entries(); }
61  bool getBaseParm() const { return myBaseParm; }
62  bool getTabBreak() const { return myTabBreak; }
64  { return myConditionalGroup; }
66  { return myConditionalPage; }
67  PRM_SpareData *getSpareData(bool create=false);
68  void enforceOptions();
69 
70  bool containsReservedName() const;
71 
72  // Set the default if there is no default defined...
73  void setEmptyDefault(const char *str)
74  {
75  if (!myDefault.isstring())
76  myDefault.harden(str);
77  }
78 
79  void setFlag(unsigned flag) { myFlag |= flag; }
80  void clearFlag(unsigned flag) { myFlag &= ~flag; }
81  unsigned getFlag(unsigned bit) const { return myFlag & bit;}
82 
83  // By default, this will simply return the number of parameters in my page
84  virtual int countParameters() const;
85 
86  // Gets the actual number of templates required by this page, including
87  // all pages within pages and so on.
88  int computeTemplateSize();
89  // Fills an array of PRM_Templates from all our parms. The size of the
90  // array must be at least computeTemplateSize() + 1. By passing in a
91  // non-zero idx starting value the templates from this page can be
92  // appended after some existing templates.
93  void fillTemplate(PRM_Template *tplate, int &idx,
94  PRM_ScriptImports *&imports);
95 
96  // Obsolete template handling.
97  int computeObsoleteTemplateSize();
98  void fillObsoleteTemplate(PRM_Template *tplate);
99 
101  {
102  const char *token;
104  };
105 
106  /// a list of tokens not handled by PRM_ScriptPage, but which may be
107  /// handled by my subclasses or should at least be ignored without
108  /// generating an error. Each token contains the expected parameter count.
109  /// Negative values indicate tokens that take brace-enclosed blocks.
110  static const TokenParmCount theTokens[];
111 
112 protected:
113  friend class PRM_ScriptGroup;
114 
115  virtual PRM_ScriptParm *newParm();
116  virtual PRM_ScriptPage *newImportPage();
117  virtual int parseHelp(DS_Stream &is, UT_String &help);
118  virtual int handleUnknown(DS_Stream &is, UT_String &token);
119  int parseImport(DS_Stream &is);
120  void processImportPage(PRM_ScriptPage *page);
121  int parseAttribute(DS_Stream &is);
122 
123  void fillTemplate(PRM_Template *tplate, int &idx,
124  PRM_ScriptImports *&imports,
125  int nest_level, int switcher_idx,
126  int folder);
127 
128 
144  unsigned myFlag;
145 
146 };
147 
148 #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
png_uint_32 i
Definition: png.h:2877
UT_String myImportToken
UT_String myLabel
PRM_ConditionalGroup * getPageConditional() const
bool getBaseParm() const
PRM_ConditionalGroup * myConditionalPage
void setFlag(unsigned flag)
void setEmptyDefault(const char *str)
UT_String myImportMask
const char * getDefault() const
void clearFlag(unsigned flag)
PRM_ConditionalGroup * getGroupConditional() const
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
png_infop png_uint_32 flag
Definition: png.h:2242
UT_ValArray< PRM_ScriptParm * > myParms
#define PRM_API
Definition: PRM_API.h:10