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 {
21  PRM_DEFAULT_LOCK = 0x00000001,
22  PRM_DEFAULT_USER = 0x00000002,
23  PRM_DEFAULT_EXPR = 0x00000004,
24  PRM_DEFAULT_FCTY = 0x00000008,
25  PRM_DEFAULT_MASK = 0x0000000F
26 };
27 
28 #define PRM_FACTORY_DEF PRM_DefaultType( \
29  PRM_DEFAULT_LOCK | PRM_DEFAULT_FCTY)
30 #define PRM_USER_DEF PRM_DefaultType( \
31  PRM_FACTORY_DEF | PRM_DEFAULT_USER)
32 #define PRM_TRUE_FACTORY_DEF PRM_DefaultType( \
33  PRM_FACTORY_DEF | PRM_DEFAULT_EXPR)
34 #define PRM_FACTORY_UI_DEF PRM_DefaultType( \
35  PRM_TRUE_FACTORY_DEF & ~PRM_DEFAULT_LOCK)
36 
37 //
38 // For now, ordinal and animated parameters are both stored in a floating
39 // point number.
40 //
41 
43 {
44 public:
45  /// PRM_Default has two parts: a float and a string. For floating point
46  /// parameters, if the default string is defined, then the parameter will
47  /// start off being animated and have the channel expression defined by the
48  /// string. Otherwise, the floating point default is used for float and
49  /// integer types, while the string is used to initialize string types.
50  PRM_Default(fpreal thefloat=0,
51  const char *thestring = 0,
52  CH_StringMeaning string_meaning =
54 
55  fpreal getFloat() const { return myFloat; }
56  int getOrdinal() const { return (int)myFloat; }
57  bool gotString() const { return (myString) ? true : false; }
58  const char *getString() const { return (myString) ? myString : ""; }
60  { return myStringMeaning; }
61 
62  void set(fpreal thefloat, const char *thestring,
63  CH_StringMeaning string_meaning);
64 
65  void setFloat(fpreal v) { myFloat = v; }
66  void setOrdinal(int v) { myFloat = (fpreal)v; }
67  void setString(const char *v, bool free_existing = false);
68  void setStringMeaning(CH_StringMeaning string_meaning);
69 
70  /// NOTE: Based on the lack of destructor, PRM_Default does NOT
71  /// own *myString, but ownership semantics are bonkers in
72  /// these mysterious lands of PRM.
73  int64 getMemoryUsage(bool inclusive) const
74  { return inclusive ? sizeof(*this) : 0; }
75 
76 private:
77  fpreal myFloat;
78  const char *myString;
79  CH_StringMeaning myStringMeaning;
80 };
81 #endif
int getOrdinal() const
Definition: PRM_Default.h:56
CH_StringMeaning
const GLdouble * v
Definition: glcorearb.h:837
PRM_DefaultType
Definition: PRM_Default.h:19
void setFloat(fpreal v)
Definition: PRM_Default.h:65
CH_StringMeaning getStringMeaning() const
Definition: PRM_Default.h:59
fpreal getFloat() const
Definition: PRM_Default.h:55
constexpr auto set(type rhs) -> int
Definition: core.h:610
const char * getString() const
Definition: PRM_Default.h:58
long long int64
Definition: SYS_Types.h:116
void setOrdinal(int v)
Definition: PRM_Default.h:66
fpreal64 fpreal
Definition: SYS_Types.h:278
int64 getMemoryUsage(bool inclusive) const
Definition: PRM_Default.h:73
bool gotString() const
Definition: PRM_Default.h:57
#define PRM_API
Definition: PRM_API.h:10