14#ifndef INTERROGATEDATABASE_H
15#define INTERROGATEDATABASE_H
36class EXPCL_INTERROGATEDB InterrogateDatabase {
38 InterrogateDatabase();
41 static InterrogateDatabase *
get_ptr();
77 void *
get_fptr(FunctionWrapperIndex wrapper);
113 INLINE
void check_latest();
117 void merge_from(
const InterrogateDatabase &other);
119 bool find_module(FunctionWrapperIndex wrapper,
121 int binary_search_module(
int begin,
int end, FunctionIndex function);
124 const std::string &wrapper_hash_name);
127 typedef std::map<TypeIndex, InterrogateType> TypeMap;
129 typedef std::map<FunctionIndex, InterrogateFunction *> FunctionMap;
130 FunctionMap _function_map;
131 typedef std::map<FunctionWrapperIndex, InterrogateFunctionWrapper> FunctionWrapperMap;
132 FunctionWrapperMap _wrapper_map;
134 typedef std::map<ManifestIndex, InterrogateManifest> ManifestMap;
135 ManifestMap _manifest_map;
136 typedef std::map<ElementIndex, InterrogateElement> ElementMap;
137 ElementMap _element_map;
139 typedef std::map<MakeSeqIndex, InterrogateMakeSeq> MakeSeqMap;
140 MakeSeqMap _make_seq_map;
142 typedef std::vector<TypeIndex> GlobalTypes;
143 GlobalTypes _global_types;
144 GlobalTypes _all_types;
145 typedef std::vector<FunctionIndex> GlobalFunctions;
146 GlobalFunctions _global_functions;
147 GlobalFunctions _all_functions;
148 typedef std::vector<ManifestIndex> GlobalManifests;
149 GlobalManifests _global_manifests;
150 typedef std::vector<ElementIndex> GlobalElements;
151 GlobalElements _global_elements;
155 typedef std::vector<InterrogateModuleDef *> Modules;
157 typedef std::map<std::string, InterrogateModuleDef *> ModulesByHash;
158 ModulesByHash _modules_by_hash;
161 typedef std::vector<InterrogateModuleDef *> Requests;
168 LT_type_name = 0x001,
169 LT_type_scoped_name = 0x002,
170 LT_type_true_name = 0x004,
171 LT_manifest_name = 0x008,
172 LT_element_name = 0x010,
173 LT_element_scoped_name = 0x020,
177 typedef std::map<std::string, int> Lookup;
178 Lookup _types_by_name;
179 Lookup _types_by_scoped_name;
180 Lookup _types_by_true_name;
181 Lookup _manifests_by_name;
182 Lookup _elements_by_name;
183 Lookup _elements_by_scoped_name;
185 void freshen_types_by_name();
186 void freshen_types_by_scoped_name();
187 void freshen_types_by_true_name();
188 void freshen_manifests_by_name();
189 void freshen_elements_by_name();
190 void freshen_elements_by_scoped_name();
192 int lookup(
const std::string &name,
193 Lookup &lookup, LookupType type,
194 void (InterrogateDatabase::*freshen)());
196 static InterrogateDatabase *_global_ptr;
197 static int _file_major_version;
198 static int _file_minor_version;
199 static int _current_major_version;
200 static int _current_minor_version;
This class manages a mapping of integers to integers.
int get_num_global_types()
Returns the total number of "global" types known to the interrogate database.
void remove_type(TypeIndex type)
Erases the type from the database.
TypeIndex lookup_type_by_scoped_name(const std::string &name)
Returns the TypeIndex associated with the first type found with the given scoped name,...
void request_module(InterrogateModuleDef *def)
Requests that the interrogate data for the given module be made available.
ManifestIndex get_global_manifest(int n)
Returns the index of the nth global manifest constant known to the interrogate database.
const InterrogateFunction & get_function(FunctionIndex function)
Returns the function associated with the given FunctionIndex, if there is one.
InterrogateFunction & update_function(FunctionIndex function)
Returns a non-const reference to the indicated function, allowing the user to update it.
static int get_current_minor_version()
Returns the minor version number currently expected in interrogate database files generated by this c...
InterrogateType & update_type(TypeIndex type)
Returns a non-const reference to the indicated type, allowing the user to update it.
ManifestIndex lookup_manifest_by_name(const std::string &name)
Returns the ManifestIndex associated with the first manifest found with the given name,...
int get_num_all_functions()
Returns the total number of functions known to the interrogate database.
InterrogateElement & update_element(ElementIndex element)
Returns a non-const reference to the indicated data element, allowing the user to update it.
int get_num_all_types()
Returns the total number of types known to the interrogate database.
void add_manifest(ManifestIndex index, const InterrogateManifest &manifest)
Adds the indicated manifest constant to the database at the given index number.
TypeIndex lookup_type_by_true_name(const std::string &name)
Returns the TypeIndex associated with the first type found with the given true name,...
const InterrogateMakeSeq & get_make_seq(MakeSeqIndex element)
Returns the make_seq associated with the given MakeSeqIndex, if there is one.
bool get_error_flag()
Returns the global error flag.
void add_wrapper(FunctionWrapperIndex index, const InterrogateFunctionWrapper &wrapper)
Adds the indicated function wrapper to the database at the given index number.
int get_num_global_elements()
Returns the total number of global data elements known to the interrogate database.
void add_type(TypeIndex index, const InterrogateType &type)
Adds the indicated type to the database at the given index number.
const InterrogateManifest & get_manifest(ManifestIndex manifest)
Returns the manifest constant associated with the given ManifestIndex, if there is one.
const InterrogateType & get_type(TypeIndex type)
Returns the type associated with the given TypeIndex, if there is one.
const InterrogateElement & get_element(ElementIndex element)
Returns the data element associated with the given ElementIndex, if there is one.
int get_num_global_manifests()
Returns the total number of global manifest constants known to the interrogate database.
InterrogateManifest & update_manifest(ManifestIndex manifest)
Returns a non-const reference to the indicated manifest constant, allowing the user to update it.
int get_num_global_functions()
Returns the total number of global functions known to the interrogate database.
InterrogateFunctionWrapper & update_wrapper(FunctionWrapperIndex wrapper)
Returns a non-const reference to the indicated function wrapper, allowing the user to update it.
void add_element(ElementIndex index, const InterrogateElement &element)
Adds the indicated data element to the database at the given index number.
static int get_file_minor_version()
Returns the minor version number of the interrogate database file currently being read.
bool read(std::istream &in, InterrogateModuleDef *def)
Reads a database from the indicated stream, associated with the indicated module definition and merge...
void set_error_flag(bool error_flag)
Sets the global error flag.
const InterrogateFunctionWrapper & get_wrapper(FunctionWrapperIndex wrapper)
Returns the function wrapper associated with the given FunctionWrapperIndex, if there is one.
static int get_current_major_version()
Returns the major version number currently expected in interrogate database files generated by this c...
int get_next_index()
Returns a new index number suitable for the next thing, that will not be shared with any other index ...
static InterrogateDatabase * get_ptr()
Returns the global pointer to the one InterrogateDatabase.
void * get_fptr(FunctionWrapperIndex wrapper)
Returns the function pointer associated with the given function wrapper, if it has a pointer availabl...
ElementIndex lookup_element_by_name(const std::string &name)
Returns the ElementIndex associated with the first element found with the given name,...
FunctionIndex get_all_function(int n)
Returns the index of the nth function known to the interrogate database.
TypeIndex get_all_type(int n)
Returns the index of the nth type known to the interrogate database.
ElementIndex lookup_element_by_scoped_name(const std::string &name)
Returns the ElementIndex associated with the first element found with the given scoped name,...
FunctionWrapperIndex get_wrapper_by_unique_name(const std::string &unique_name)
Looks up the function wrapper corresponding to the given unique name, if available.
void add_make_seq(MakeSeqIndex index, const InterrogateMakeSeq &make_seq)
Adds the indicated make_seq to the database at the given index number.
InterrogateMakeSeq & update_make_seq(MakeSeqIndex make_seq)
Returns a non-const reference to the indicated make_seq, allowing the user to update it.
void add_function(FunctionIndex index, InterrogateFunction *function)
Adds the indicated function to the database at the given index number.
int remap_indices(int first_index)
Resequences all of the various index numbers so that all of the functions start at first_index and in...
void write(std::ostream &out, InterrogateModuleDef *def) const
Writes the database to the indicated stream for later reading.
static int get_file_major_version()
Returns the major version number of the interrogate database file currently being read.
TypeIndex lookup_type_by_name(const std::string &name)
Returns the TypeIndex associated with the first type found with the given name, or 0 if no type has t...
ElementIndex get_global_element(int n)
Returns the index of the nth global data element known to the interrogate database.
TypeIndex get_global_type(int n)
Returns the index of the nth global type known to the interrogate database.
FunctionIndex get_global_function(int n)
Returns the index of the nth global function known to the interrogate database.
An internal representation of a data element, like a data member or a global variable.
An internal representation of a callable function.
An internal representation of a function.
Represents a synthetic method created via the MAKE_SEQ() macro.
An internal representation of a manifest constant.
An internal representation of a type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.