HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SHOP_GeoOverride.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: SHOP_GeoOverride.h (SHOP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __SHOP_GeoOverride__
12 #define __SHOP_GeoOverride__
13 
14 #include "SHOP_API.h"
15 #include <UT/UT_Options.h>
16 
17 class UT_WorkBuffer;
18 class UT_StringArray;
19 
20 /// Class to help with managing material overrides for geometry attributes
22 {
23 public:
26 
27  /// Number of entries
28  exint entries() const { return myOptions.getNumOptions(); }
29 
30  /// Clear object
31  void clear() { myOptions.clear(); }
32 
33  /// Merge with another SHOP_GeoOverride object
34  void merge(const SHOP_GeoOverride &other)
35  { myOptions.merge(other.myOptions); }
36 
37  /// Load from the string (i.e. "{'diff_clrb':0.32,'map':'foo.pic'}")
38  bool load(const char *string);
39  /// Save to a string (note that the order of the keys may be different.
40  bool save(UT_WorkBuffer &result) const;
41 
42  /// @{
43  /// Add override options
44  void addKey(const char *key, exint value)
45  { myOptions.setOptionI(key, value); }
46  void addKey(const char *key, fpreal value)
47  { myOptions.setOptionF(key, value); }
48  void addKey(const char *key, const UT_StringHolder &value)
49  { myOptions.setOptionS(key, value); }
50  /// @}
51 
52  /// Extract the keys
53  void getKeys(UT_StringArray &keys) const;
54 
55  /// Check to see whether the value associated with the key is a string or a
56  /// number.
57  bool isString(const char *key) const;
58  /// @{
59  /// Extract options
60  bool import(const char *key, fpreal &value) const;
61  bool import(const char *key, exint &value) const;
62  bool import(const char *key, UT_WorkBuffer &buf) const;
63  /// @}
64 
65 private:
66  // For now, we store the map in a UT_Options. In the material_override
67  // attribute, we have a single scalar (int, real or string) value for each
68  // key.
69  UT_Options myOptions;
70 };
71 
72 #endif
bool isString(const AttributeArray &array)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
void addKey(const char *key, const UT_StringHolder &value)
GLsizei const GLfloat * value
Definition: glcorearb.h:824
int64 exint
Definition: SYS_Types.h:125
**But if you need a result
Definition: thread.h:613
void merge(const SHOP_GeoOverride &other)
Merge with another SHOP_GeoOverride object.
#define SHOP_API
Definition: SHOP_API.h:10
exint entries() const
Number of entries.
Class to help with managing material overrides for geometry attributes.
void addKey(const char *key, exint value)
void addKey(const char *key, fpreal value)
A map of string to various well defined value types.
Definition: UT_Options.h:84
fpreal64 fpreal
Definition: SYS_Types.h:277
void clear()
Clear object.
Definition: core.h:1131