H3D API  2.4.1
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
H3D::H3DNodeDatabase Struct Reference

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.
 
NodecreateNode ()
 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...
 
FieldgetField (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 H3DNodeDatabaselookupTypeId (const type_info &t)
 Search the node database for an entry with a matching type_info structure.
 
static H3DNodeDatabaselookupName (const string &name)
 Search the node database for an entry with a matching name.
 
static NodecreateNode (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 H3DNodeDatabaselookupNodeInstance (const Node *n)
 Get the database for a specific node instance.
 

Static Public Attributes

static H3DNodeDatabaseType * database
 The database with all H3DNodeDatabase instances.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ H3DNodeDatabase() [1/2]

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() [2/2]

H3DNodeDatabase::H3DNodeDatabase ( const Node n,
H3DNodeDatabase _parent 
)

Constructor, for dynamic nodes.

Note
The reason for having two arguments is intialization order. Some const variables will be initialized before parent, beause they are declared before the parent variable in the header.

References database.

Member Function Documentation

◆ addField()

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().

◆ begin()

static NodeDatabaseConstIterator H3D::H3DNodeDatabase::begin ( )
inlinestatic

Iterator to the first element in the database.

Can be used to iterate over all H3DNodeDatabase instances that have been created.

◆ createNode()

Node * H3DNodeDatabase::createNode ( const string &  name)
static

Create a new instance of a Node type.

Parameters
nameThe name of the node in the database.
Returns
A new instance of the node if it exists in the database, otherwise NULL is returned.

Referenced by H3D::Node::clone().

◆ fieldDBBegin()

FieldDBConstIterator H3D::H3DNodeDatabase::fieldDBBegin ( )
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().

◆ removeField()

bool H3DNodeDatabase::removeField ( const string &  _name,
Node _node = NULL 
)

Remove a field from the node database entry.

Parameters
_nameThe name of the field to remove
_nodeThe node instance to remove from, if NULL then it is removed for all

References H3D::FieldDBElement::getField(), and H3D::FieldDBElement::getName().


The documentation for this struct was generated from the following files: