HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIM_Query.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  */
7 
8 #ifndef __SIM_Query_h__
9 #define __SIM_Query_h__
10 
11 #include "SIM_API.h"
12 #include <UT/UT_Options.h>
13 #include <UT/UT_IntArray.h>
14 #include <UT/UT_Array.h>
15 
16 class UT_StringArray;
17 class UT_InfoTree;
18 class SIM_Data;
19 class SIM_QuerySuffixInfo;
20 
21 /// This class provides an interface between a SIM_Data and the Houdini
22 /// expression language. It also helps in building the tree view of a
23 /// simulation.
25 {
26 public:
27  /// Simple constructor.
28  explicit SIM_Query();
29  /// Constructor which takes a const SIM_Data as our owner.
30  explicit SIM_Query(const SIM_Data *owner);
31  /// Destructor for this class.
32  virtual ~SIM_Query();
33 
34  /// This function returns true if this object needs to be deleted when
35  /// the owner data changes. This may be the case if this class caches
36  /// some information about the SIM_Data owner. This default implementation
37  /// returns false.
38  bool deleteIfDataModified() const;
39 
40  int getNumRecordTypes() const;
41  const char *getRecordTypeName(int recordtypenum) const;
42 
43  int getNumRecords(const char *recordtype) const;
44  int getNumFields(const char *recordtype) const;
45  const char *getFieldName(const char *recordtype,
46  int fieldnum) const;
47  UT_OptionType getFieldType(const char *recordtype,
48  int fieldnum) const;
49  UT_OptionType getFieldTypeByName(const char *recordtype,
50  const char *fieldname) const;
51 
52  /// Sets the result pointer to a UT_OptionEntry subclass that
53  /// depends on the data type of the field. It may be any of the
54  /// UT_OptionEntryImpl classes. It is up to the caller to free
55  /// this result pointer.
56  bool getFieldRaw(const char *recordtype,
57  int recordnum,
58  const char *fieldname,
59  UT_OptionEntry *&result) const;
60  /// These functions use getFieldRawand process the result to
61  /// generate a nice string or single float value as required
62  /// by the expression library.
63  bool getFieldString(const char *recordtype,
64  int recordnum,
65  const char *fieldname,
66  UT_String &result) const;
67  bool getFieldString(const char *recordtype,
68  int recordnum,
69  const char *fieldname,
70  UT_StringHolder &result) const;
71  bool getFieldFloat(const char *recordtype,
72  int recordnum,
73  const char *fieldname,
74  fpreal &result) const;
75 
76  /// Fills the provided array with the names of all valid values that
77  /// can be passed to the getFieldFloat function. This includes all
78  /// versions of the field names with appropriate suffices.
79  void getAllFieldFloatNames(
80  const char *recordtype,
81  UT_StringArray &names,
82  UT_Array<UT_OptionType> &fieldtypes,
83  UT_IntArray &vectorindices) const;
84 
85  /// Fills a UT_InfoTree structure with all our data.
86  void getInfoTree(UT_InfoTree &infotree,
87  const char *recordtype) const;
88 
89 protected:
90  const SIM_Data *getOwner() const;
91 
92  virtual bool deleteIfDataModifiedSubclass() const;
93 
94  virtual int getNumRecordTypesSubclass() const;
95  virtual const char *getRecordTypeNameSubclass(
96  int recordtypenum) const;
97 
98  virtual int getNumRecordsSubclass(
99  const char *recordtype) const;
100  virtual int getNumFieldsSubclass(
101  const char *recordtype) const;
102  virtual const char *getFieldNameSubclass(
103  const char *recordtype,
104  int fieldnum) const;
105  virtual UT_OptionType getFieldTypeSubclass(
106  const char *recordtype,
107  int fieldnum) const;
108  virtual bool getFieldRawSubclass(
109  const char *recordtype,
110  int recordnum,
111  const char *fieldname,
112  UT_OptionEntry *&result) const;
113 
114 private:
115  static const SIM_QuerySuffixInfo *getSuffixInfos(UT_OptionType otype);
116  static bool isPossibleFieldSuffix(
117  char secondlastchar,
118  char lastchar);
119  static int getFieldSuffixVectorIndex(
120  UT_OptionType fieldtype,
121  char secondlastchar,
122  char lastchar);
123 
124  const SIM_Data *myOwner;
125 
126  /// Give SIM_QueryCombine special access to our protected methods.
127  friend class SIM_QueryCombine;
128 };
129 
130 #endif
131 
UT_OptionType
double fpreal
Definition: SYS_Types.h:269
#define SIM_API
Definition: SIM_API.h:10