HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_GeometryIndex.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: GA_GeometryIndex.h
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef GA_GEOMETRYINDEX_H_
12 #define GA_GEOMETRYINDEX_H_
13 
14 #include "GA_API.h"
15 
16 #include <UT/UT_Map.h>
17 #include <UT/UT_StringHolder.h>
18 #include <UT/UT_StringMap.h>
19 
20 class UT_JSONParser;
21 class UT_JSONWriter;
22 
24 {
25 public:
27  virtual ~GA_GeometryIndex();
28 
29  void clear();
30 
31  /// Writes the index to a JSON reader
32  /// Should be called from within an array context
33  bool writeToJSON(UT_JSONWriter& writer);
34 
35  /// Reads the index from a JSON parser
36  bool readFromJSON(UT_JSONParser& parser);
37 
38  /// Adds an entry to the index. Key can be an exint or a string.
39  void addEntry(exint key, exint location);
40 
41  void addEntry(const char* key, exint location);
42 
43  /// Adds a subindex entry. Fill the returned index as you would
44  /// the top level index. Memory is owned by the parent index.
45  GA_GeometryIndex* addSubindexEntry(exint key);
46 
47  GA_GeometryIndex* addSubindexEntry(const char* key);
48 
49  /// Retrieves an entry.
50  exint getEntryByInt(exint key);
51 
52  exint getEntryByString(const UT_StringRef& key);
53 
54  /// Retrieves subindex entry
55  GA_GeometryIndex* getSubindexEntryByInt(exint key);
56 
57  GA_GeometryIndex* getSubindexEntryByString(const UT_StringRef& key);
58 
59  /// Returns true if the index has no entries
60  bool isEmpty() const;
61 
62 private:
63  UT_Map<exint, exint> myIntEntries;
64  UT_StringMap<exint> myStringEntries;
65 
66  UT_Map<exint, GA_GeometryIndex*> myIntSubindexEntries;
67  UT_StringMap<GA_GeometryIndex*> myStringSubindexEntries;
68 
69  void deleteSubindexEntries();
70 };
71 
72 #endif // GA_GEOMETRYINDEX_H_
int64 exint
Definition: SYS_Types.h:125
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
#define GA_API
Definition: GA_API.h:14
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:39
GLint location
Definition: glcorearb.h:805