H3D API
2.4.1
|
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with that name. More...
#include <H3D/H3DNodeDatabase.h>
Classes | |
class | FieldDBConstIterator |
The FieldDBConstIterator is an iterator class used for iterating over the field instances in an H3DNodeDatabase. More... | |
struct | TypeInfoWrapper |
Wrapper class to be able to put type_info as a key in a map. More... | |
Public Member Functions | |
H3DNodeDatabase (const string &_name, H3DCreateNodeFunc _createf, const type_info &_ti, H3DNodeDatabase *_parent=0) | |
Constructor. | |
H3DNodeDatabase (const string &_name, const string &_alias, H3DCreateNodeFunc _createf, const type_info &_ti, H3DNodeDatabase *_parent=0) | |
Constructor. More... | |
H3DNodeDatabase (const type_info &_ti, H3DNodeDatabase *_parent=0) | |
Unnamed constructor, for nodes that cannot be instantiated but instead act as base classes for other nodes. | |
void | addAlias (const string &alias) |
Add an alias for the node in the database. | |
const string & | getName () |
Get the name of the node in the database object. | |
const type_info & | getTypeInfo () |
Get the type_info of the node in the database object. | |
Node * | createNode () |
Create a new instance of the node type the database object refers to. | |
void | addField (FieldDBElement *f) |
add a field to the node database entry. More... | |
bool | removeField (const string &_name, Node *_node=NULL) |
Remove a field from the node database entry. More... | |
Field * | getField (const Node *n, const string &f) const |
getField() will search the node's field database for a field matching the given name and returning a pointer to the field if found. | |
void | initFields (Node *) const |
initialise the given Node using the contents of the database - initialise field names, field owner pointers and access restrictors. | |
void | clearDynamicFields () |
Remove all DynamicFieldDBElements from the database. | |
void | clearDynamicFields (Node *n) |
Remove all DynamicFieldDBElements from the database belonging to the node n;. | |
FieldDBConstIterator | fieldDBBegin () |
Gets an iterator to the beginning first field in the H3DNodeDatabase. More... | |
FieldDBConstIterator | fieldDBEnd () |
Returns an iterator pointing at the end of fields in the H3DNodeDatabase. | |
size_t | fieldDBSize () |
Returns the number of fields in the H3DNodeDatabase. | |
H3DNodeDatabase (const Node *n, H3DNodeDatabase *_parent) | |
Constructor, for dynamic nodes. More... | |
Static Public Member Functions | |
static H3DNodeDatabase * | lookupTypeId (const type_info &t) |
Search the node database for an entry with a matching type_info structure. | |
static H3DNodeDatabase * | lookupName (const string &name) |
Search the node database for an entry with a matching name. | |
static Node * | createNode (const string &name) |
Create a new instance of a Node type. More... | |
static NodeDatabaseConstIterator | begin () |
Iterator to the first element in the database. More... | |
static NodeDatabaseConstIterator | end () |
Returns an iterator pointing at the end of the H3DNodeDatabase created. | |
static H3DNodeDatabase * | lookupNodeInstance (const Node *n) |
Get the database for a specific node instance. | |
Static Public Attributes | |
static H3DNodeDatabaseType * | database |
The database with all H3DNodeDatabase instances. | |
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with that name.
Each node that is to be used via X3D file input must register itself in the database in order to be available to X3D. To register a static H3DNodeDatabase member variable must be defined in the node class with the (nodename, constructor) pair that is wanted.
H3DNodeDatabase::H3DNodeDatabase | ( | const string & | _name, |
const string & | _alias, | ||
H3DCreateNodeFunc | _createf, | ||
const type_info & | _ti, | ||
H3DNodeDatabase * | _parent = 0 |
||
) |
Constructor.
Allows the adding of one alias name as well as the ordinary name. Any extra alias names must be added with the addAlias method.
H3DNodeDatabase::H3DNodeDatabase | ( | const Node * | n, |
H3DNodeDatabase * | _parent | ||
) |
Constructor, for dynamic nodes.
References database.
void H3DNodeDatabase::addField | ( | FieldDBElement * | f | ) |
add a field to the node database entry.
The field is only added if there is not already a field with that name in the database.
References fieldDBBegin(), fieldDBEnd(), and H3D::FieldDBElement::getName().
|
inlinestatic |
Iterator to the first element in the database.
Can be used to iterate over all H3DNodeDatabase instances that have been created.
|
static |
Create a new instance of a Node type.
name | The name of the node in the database. |
Referenced by H3D::Node::clone().
|
inline |
Gets an iterator to the beginning first field in the H3DNodeDatabase.
Can be used to iteratate through all the fields in the database.
Referenced by addField(), H3D::H3DNodeDatabase::FieldDBConstIterator::FieldDBConstIterator(), and H3D::PyNode::getFieldList().
bool H3DNodeDatabase::removeField | ( | const string & | _name, |
Node * | _node = NULL |
||
) |
Remove a field from the node database entry.
_name | The name of the field to remove |
_node | The node instance to remove from, if NULL then it is removed for all |
References H3D::FieldDBElement::getField(), and H3D::FieldDBElement::getName().