29 #ifndef __DEFNODES_H__
30 #define __DEFNODES_H__
37 #ifdef H3D_REFERENCE_COUNT_DEBUG
41 #define DEFNODES_DEBUG_NAME(ref_ptr, debug_name) (ref_ptr).name = debug_name;
43 #define DEFNODES_DEBUG_NAME(ref_ptr, name)
50 #ifdef H3D_REFERENCE_COUNT_DEBUG
64 static std::set< DEFNodesBase * > DEF_nodes;
82 #pragma warning( disable : 4275 )
88 private map< const string, Node * >
89 #ifdef H3D_REFERENCE_COUNT_DEBUG
94 #pragma warning( default : 4275 )
101 typedef map< const string, Node * >::const_iterator const_iterator;
106 return map< const string, Node * >::begin();
112 return map< const string, Node * >::end();
120 iterator i = find( def_name );
124 insert( make_pair( def_name, def_node ) );
128 (*i).second->unref();
129 (*i).second = def_node;
137 iterator i = find( def_name );
142 (*i).second->unref();
151 for( const_iterator i = dn->
begin(); i != dn->
end(); ++i )
152 addNode( (*i).first, (*i).second );
158 for( const_iterator i = begin(); i != end(); ++i )
160 (*i).second->unref();
161 map< const string, Node * >::clear();
165 return map< const string, Node * >::empty();
175 iterator i = find( def_name );
191 template<
class NodeType >
193 NodeType *&return_node ) {
194 Node *node = getNode( def_name ) ;
195 NodeType *n =
dynamic_cast< NodeType *
>( node );
198 msg <<
"DEFNodes::getNode (expecting "
199 <<
typeid( NodeType ).name()
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
Base class that adds functionallity needed for reference count debugging.
Definition: DEFNodes.h:53
Provides a mapping between defined DEF names in X3D and the nodes they refer to.
Definition: DEFNodes.h:92
const_iterator end()
Returns a const_iterator to the end element in the DEFNodes struct.
Definition: DEFNodes.h:111
Node * getNode(const string &def_name)
Get the node by its DEF name.
Definition: DEFNodes.h:174
void merge(DEFNodes *dn)
Add the entries from another DEFNodes structure do this one.
Definition: DEFNodes.h:149
void clear()
Removes all the entries in the map.
Definition: DEFNodes.h:157
void removeNode(const string &def_name)
Removes a DEF name/Node * pair from the structure.
Definition: DEFNodes.h:136
const_iterator begin()
Returns a const_iterator to the first element in the DEFNodes struct.
Definition: DEFNodes.h:105
void getNode(const string &def_name, NodeType *&return_node)
Get the node by its DEF name.
Definition: DEFNodes.h:192
void addNode(const string &def_name, Node *def_node)
Adds a DEF name/Node * pair to the structure.
Definition: DEFNodes.h:119
An exception for errors when the Node type is not what was expected.
Definition: DEFNodes.h:74
An exception for errors when the DEF name does not exist in the DEF nodes structure.
Definition: DEFNodes.h:79
H3D_VALUE_EXCEPTION(string, InvalidType)
An exception thrown when a field is of the wrong type when it is checked.
H3D API namespace.
Definition: Anchor.h:38