HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_Default.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_Default.h (Parameter Library)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __PRM_Default__
12 #define __PRM_Default__
13 
14 #include "PRM_API.h"
15 #include <SYS/SYS_Types.h>
16 #include <CH/CH_ExprLanguage.h>
17 
18 // These options can be OR'd and are processed in order from top to bottom.
20  PRM_DEFAULT_LOCK = 0x00000001,
21  PRM_DEFAULT_USER = 0x00000002,
22  PRM_DEFAULT_EXPR = 0x00000004,
23  PRM_DEFAULT_FCTY = 0x00000008,
24  PRM_DEFAULT_MASK = 0x0000000F
25 };
26 
27 #define PRM_FACTORY_DEF PRM_DefaultType( \
28  PRM_DEFAULT_LOCK | PRM_DEFAULT_FCTY)
29 #define PRM_USER_DEF PRM_DefaultType( \
30  PRM_FACTORY_DEF | PRM_DEFAULT_USER)
31 #define PRM_TRUE_FACTORY_DEF PRM_DefaultType( \
32  PRM_FACTORY_DEF | PRM_DEFAULT_EXPR)
33 #define PRM_FACTORY_UI_DEF PRM_DefaultType( \
34  PRM_TRUE_FACTORY_DEF & ~PRM_DEFAULT_LOCK)
35 
36 //
37 // For now, ordinal and animated parameters are both stored in a floating
38 // point number.
39 //
40 
42 {
43 public:
44  /// PRM_Default has two parts: a float and a string. For floating point
45  /// parameters, if the default string is defined, then the parameter will
46  /// start off being animated and have the channel expression defined by the
47  /// string. Otherwise, the floating point default is used for float and
48  /// integer types, while the string is used to initialize string types.
49  PRM_Default(fpreal thefloat=0,
50  const char *thestring = 0,
51  CH_StringMeaning string_meaning =
53 
54  fpreal getFloat() const { return myFloat; }
55  int getOrdinal() const { return (int)myFloat; }
56  bool gotString() const { return (myString) ? true : false; }
57  const char *getString() const { return (myString) ? myString : ""; }
59  { return myStringMeaning; }
60 
61  void set(fpreal thefloat, const char *thestring,
62  CH_StringMeaning string_meaning);
63 
64  void setFloat(fpreal v) { myFloat = v; }
65  void setOrdinal(int v) { myFloat = (fpreal)v; }
66  void setString(const char *v, bool free_existing = false);
67  void setStringMeaning(CH_StringMeaning string_meaning);
68 
69  /// NOTE: Based on the lack of destructor, PRM_Default does NOT
70  /// own *myString, but ownership semantics are bonkers in
71  /// these mysterious lands of PRM.
72  int64 getMemoryUsage(bool inclusive) const
73  { return inclusive ? sizeof(*this) : 0; }
74 
75 private:
76  fpreal myFloat;
77  const char *myString;
78  CH_StringMeaning myStringMeaning;
79 };
80 #endif
int getOrdinal() const
Definition: PRM_Default.h:55
CH_StringMeaning
const GLdouble * v
Definition: glcorearb.h:837
PRM_DefaultType
Definition: PRM_Default.h:19
void setFloat(fpreal v)
Definition: PRM_Default.h:64
CH_StringMeaning getStringMeaning() const
Definition: PRM_Default.h:58
fpreal getFloat() const
Definition: PRM_Default.h:54
const char * getString() const
Definition: PRM_Default.h:57
long long int64
Definition: SYS_Types.h:116
void setOrdinal(int v)
Definition: PRM_Default.h:65
fpreal64 fpreal
Definition: SYS_Types.h:277
int64 getMemoryUsage(bool inclusive) const
Definition: PRM_Default.h:72
bool gotString() const
Definition: PRM_Default.h:56
#define PRM_API
Definition: PRM_API.h:10