Ocular Engine
Ocular::Core::BuilderNode Class Reference

Generic node system used for loading and saving SceneObjects and their components. More...

#include <BuilderNode.hpp>

Public Member Functions

 BuilderNode (BuilderNode *parent, std::string const &name, std::string const &type, std::string const &value)
 
std::string const & getName () const
 
std::string const & getValue () const
 
std::string const & getType () const
 
BuilderNode const * getParent () const
 
BuilderNodeaddChild (std::string const &name, std::string const &type, std::string const &value)
 
BuilderNode const * getChild (std::string const &name) const
 
void findChildrenByName (std::vector< BuilderNode * > &children, std::string const &name) const
 
void findChildrenByType (std::vector< BuilderNode * > &children, std::string const &type) const
 
void getAllChildren (std::vector< BuilderNode * > &children) const
 
uint32_t getNumChildren () const
 

Detailed Description

Generic node system used for loading and saving SceneObjects and their components.

A BuilderNode chain is employed when reading from and writing to various Ocular file types including: Scene (.oscene), SceneObject (.opref), and Material (.omat). These nodes allow for a generic pattern in which both primitive and custom types may be used to specify the contents of an object.

Member Function Documentation

BuilderNode * Ocular::Core::BuilderNode::addChild ( std::string const &  name,
std::string const &  type,
std::string const &  value 
)

Adds a new child to this node.

If a child already exists with the specified name, that child will be overwritten by the new child.

Parameters
[in]name
[in]type
[in]value
void Ocular::Core::BuilderNode::findChildrenByName ( std::vector< BuilderNode * > &  children,
std::string const &  name 
) const

Finds all children with the specified string in their name.

Note
Names are unique, so this searches for any children whose name contains the string.
Parameters
[out]children
[in]name
void Ocular::Core::BuilderNode::findChildrenByType ( std::vector< BuilderNode * > &  children,
std::string const &  type 
) const

Finds all children whose type matches the specified string.

Parameters
[out]children
[in]type
void Ocular::Core::BuilderNode::getAllChildren ( std::vector< BuilderNode * > &  children) const

Adds references to all children into the provided vector container.

Parameters
[out]children
BuilderNode const * Ocular::Core::BuilderNode::getChild ( std::string const &  name) const

Attempts to retrieve the child with the specified name.

Parameters
[in]name
Returns
Child with the specified name. If no such child exists, returns nullptr.
std::string const & Ocular::Core::BuilderNode::getName ( ) const
Returns
The name of the variable stored in this node.
uint32_t Ocular::Core::BuilderNode::getNumChildren ( ) const

Returns number of child nodes.

BuilderNode const * Ocular::Core::BuilderNode::getParent ( ) const
Returns
The parent of this node. If no parent, returns nullptr.
std::string const & Ocular::Core::BuilderNode::getType ( ) const
Returns
The string representation of the type of variable stored in this node.
std::string const & Ocular::Core::BuilderNode::getValue ( ) const
Returns
The string representation of the value of the variable stored in this node.

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