Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

openvrml::scope Class Reference

The scope class keeps track of defined nodes and prototypes. More...

Collaboration diagram for openvrml::scope:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 scope (const std::string &id, const scope_ptr &parent=scope_ptr())
 Construct.

virtual ~scope ()
 Destroy.

bool add_type (const node_type_ptr &type) throw (std::bad_alloc)
 Add a node type.

const node_type_ptrfind_type (const std::string &id) const
 Find a node type, given a type name. Returns 0 if type is not defined.

const node_type_ptrfirst_type () const
 The first type in the scope.

nodefind_node (const std::string &id) const
 Find the node in the scope with node::id id.


Public Attributes

const std::string id
 scope identifier.

const scope_ptr parent
 The parent scope; null if the scope is a root scope.


Private Member Functions

 scope (const scope &)
 Not implemented.

scope & operator= (const scope &)
 Not implemented.


Private Attributes

std::list< node_type_ptrnode_type_list
 List of node_types in the scope.

std::map< std::string, node * > named_node_map
 Map of the named nodes in the scope.


Friends

class node
 node identifiers are stored in the scope, so node needs special privilege to access them.


Detailed Description

The scope class keeps track of defined nodes and prototypes.

PROTO definitions add node types to the namespace. PROTO implementations are a separate node type namespace, and require that any nested PROTOs NOT be available outside the PROTO implementation. PROTOs defined outside the current namespace are available.


Constructor & Destructor Documentation

openvrml::scope::scope const std::string &  id,
const scope_ptr parent = scope_ptr()
[explicit]
 

Construct.

Parameters:
id the identifier for the scope.
parent the parent scope.
For the root scope, id should be the URI of the world. For child scopes, id should be the name of the PROTO to which the scope corresponds.

openvrml::scope::~scope  )  [virtual]
 

Destroy.

openvrml::scope::scope const scope &   )  [private]
 

Not implemented.

scopes are not copyable.


Member Function Documentation

bool openvrml::scope::add_type const node_type_ptr type  )  throw (std::bad_alloc)
 

Add a node type.

Print an error message if the argument type is already defined.

Parameters:
type a node_type_ptr
Returns:
true if type is successfully added to the scope; false otherwise (if a node_type with the same id is already defined for the scope).
Exceptions:
std::bad_alloc if memory allocation fails.
Precondition:
type is not null.

node * openvrml::scope::find_node const std::string &  id  )  const
 

Find the node in the scope with node::id id.

Returns:
a pointer to a node with node::id id, or 0 if no such node exists in the scope.

const node_type_ptr & openvrml::scope::find_type const std::string &  id  )  const
 

Find a node type, given a type name. Returns 0 if type is not defined.

const node_type_ptr & openvrml::scope::first_type  )  const
 

The first type in the scope.

Returns:
the first node_type in the scope, or a null node_type_ptr if the scope has no node_types.

scope & openvrml::scope::operator= const scope &   )  [private]
 

Not implemented.

scopes are not copyable.


Friends And Related Function Documentation

openvrml::scope::node [friend]
 

node identifiers are stored in the scope, so node needs special privilege to access them.


Member Data Documentation

const std::string openvrml::scope::id
 

scope identifier.

std::map< std::string, node * > openvrml::scope::named_node_map [private]
 

Map of the named nodes in the scope.

std::list< node_type_ptr > openvrml::scope::node_type_list [private]
 

List of node_types in the scope.

const scope_ptr openvrml::scope::parent
 

The parent scope; null if the scope is a root scope.