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