Ocean
Loading...
Searching...
No Matches
Ocean::SceneDescription::DynamicNode Class Reference

This class is the base class for all nodes able to handle fields loaded during runtime. More...

#include <DynamicNode.h>

Inheritance diagram for Ocean::SceneDescription::DynamicNode:

Public Member Functions

bool addField (const std::string &name, const Field &field)
 Adds a new field during runtime.
 
unsigned int dynamicFields () const
 Returns the number of dynamic fields.
 
bool hasAnyField (const std::string &fieldName) const override
 Returns whether this node has a special standard or dynamic field.
 
bool hasDynamicField (const std::string &name) const
 Returns whether this node holds a specific dynamic field.
 
const std::string & dynamicFieldName (const unsigned int index) const
 Returns the name of a dynamic field by a given index.
 
const FieldanyField (const std::string &fieldName) const override
 Returns the field base of a specified standard or dynamic field.
 
FieldanyField (const std::string &fieldName) override
 Returns the field base of a specified standard or dynamic field.
 
const FielddynamicField (const std::string &fieldName) const
 Returns the field base of a specified dynamic field.
 
FielddynamicField (const std::string &fieldName)
 Returns the field base of a specified dynamic field.
 
template<typename T >
const T & dynamicField (const std::string &fieldName) const
 Returns a specified dynamic field.
 
template<typename T >
T & dynamicField (const std::string &fieldName)
 Returns a specified dynamic field.
 
bool removeField (const std::string &name)
 Removes a field added during runtime.
 
bool isDynamic () const override
 Returns whether this node can hold dynamic generated field.
 
- Public Member Functions inherited from Ocean::SceneDescription::Node
virtual DescriptionType descriptionType () const =0
 Returns the scene description type of this node.
 
NodeId id () const
 Returns the unique node id of this node.
 
const std::string & name () const
 Returns the name of this node.
 
const std::string & type () const
 Returns the type of this node.
 
const Fieldfield (const std::string &fieldName) const
 Returns the field base of a specified (standard) field.
 
Fieldfield (const std::string &fieldName)
 Returns the field base of a specified (standard) field.
 
template<typename T >
const T & field (const std::string &fieldName) const
 Returns a specified (standard) field.
 
template<typename T >
T & field (const std::string &fieldName)
 Returns a specified (standard) field.
 
template<typename T >
const T & anyField (const std::string &fieldName) const
 Returns a specified standard or dynamic field.
 
template<typename T >
T & anyField (const std::string &fieldName)
 Returns a specified standard or dynamic field.
 
FieldAccessType fieldAccessType (const std::string &fieldName) const
 Returns the access type of a specified field.
 
virtual void setName (const std::string &name)
 Sets the name of this node.
 
bool hasField (const std::string &fieldName) const
 Returns whether this node has a special (standard) field.
 
virtual std::string originalFieldName (const std::string &fieldName) const
 Tries to translate an alias field name to the original field name.
 
Field::Type fieldType (const std::string &fieldName) const
 Returns the type of a special field.
 
unsigned int fieldDimension (const std::string &fieldName) const
 Return the dimension of a special field.
 

Protected Types

using DynamicFields = std::vector< std::unique_ptr< Field > >
 Definition of a vector holding fields.
 
using DynamicFieldIndices = std::unordered_map< std::string, unsigned int >
 Definition of a map mapping field names to field indices.
 
- Protected Types inherited from Ocean::SceneDescription::Node
using FieldMap = std::map< std::string, Field * >
 Definition of a map mapping field names to fields.
 

Protected Member Functions

 DynamicNode ()
 Creates a new dynamic node object.
 
 ~DynamicNode () override
 Destructs a dynamic node object.
 
- Protected Member Functions inherited from Ocean::SceneDescription::Node
 Node ()
 Creates a new node.
 
 Node (const Node &node)=delete
 Disabled copy constructor.
 
virtual ~Node ()
 Destructs a node.
 
virtual size_t objectAddress () const
 Returns the address of the most derived object.
 
void registerField (NodeSpecification &specification, const std::string &fieldName, const Field &field, const FieldAccessType accessType=ACCESS_GET_SET)
 Registers a new field to a specified node type.
 
Nodeoperator= (const Node &node)=delete
 Disabled copy operator.
 

Protected Attributes

DynamicFields dynamicFields_
 Vector holding the dynamic fields.
 
DynamicFieldIndices dynamicFieldIndices_
 Map mapping names of dynamic fields to indices.
 
- Protected Attributes inherited from Ocean::SceneDescription::Node
NodeId nodeId_
 Unique node id.
 
std::string name_
 Node name.
 
NodeSpecificationspecification_ = nullptr
 Pointer to the node specification, guaranteed to exist as long as the node exist.
 

Additional Inherited Members

- Public Types inherited from Ocean::SceneDescription::Node
enum  FieldAccessType {
  ACCESS_NONE = 0 , ACCESS_GET = 1 , ACCESS_SET = 2 , ACCESS_GET_SET = ACCESS_GET | ACCESS_SET ,
  ACCESS_EXPLICIT_NOTIFICATION = 4
}
 Definition of different field access types. More...
 
- Static Protected Member Functions inherited from Ocean::SceneDescription::Node
static LocknodeIdCounterLock ()
 Returns the lock for the node id counter.
 
- Static Protected Attributes inherited from Ocean::SceneDescription::Node
static NodeId nodeIdCounter_
 Unique node id counter.
 

Detailed Description

This class is the base class for all nodes able to handle fields loaded during runtime.

A dynamic field is identified by its name. The index of a dynamic field is not an identity but an enumeration handle with range [0, dynamicFields()), valid only until the next addField() or removeField() call.

Member Typedef Documentation

◆ DynamicFieldIndices

using Ocean::SceneDescription::DynamicNode::DynamicFieldIndices = std::unordered_map<std::string, unsigned int>
protected

Definition of a map mapping field names to field indices.

◆ DynamicFields

using Ocean::SceneDescription::DynamicNode::DynamicFields = std::vector<std::unique_ptr<Field> >
protected

Definition of a vector holding fields.

Constructor & Destructor Documentation

◆ DynamicNode()

Ocean::SceneDescription::DynamicNode::DynamicNode ( )
protected

Creates a new dynamic node object.

◆ ~DynamicNode()

Ocean::SceneDescription::DynamicNode::~DynamicNode ( )
overrideprotected

Destructs a dynamic node object.

Member Function Documentation

◆ addField()

bool Ocean::SceneDescription::DynamicNode::addField ( const std::string &  name,
const Field field 
)

Adds a new field during runtime.

The field is appended, so it receives the highest index and the indices of all existing fields stay valid.

Parameters
nameThe name of the field, must be valid
fieldField to add, a copy is stored
Returns
True, if no field has be added with the same name before

◆ anyField() [1/2]

const Field & Ocean::SceneDescription::DynamicNode::anyField ( const std::string &  fieldName) const
overridevirtual

Returns the field base of a specified standard or dynamic field.

See also
Node::anyField().

Reimplemented from Ocean::SceneDescription::Node.

◆ anyField() [2/2]

Field & Ocean::SceneDescription::DynamicNode::anyField ( const std::string &  fieldName)
overridevirtual

Returns the field base of a specified standard or dynamic field.

See also
Node::anyField().

Reimplemented from Ocean::SceneDescription::Node.

◆ dynamicField() [1/4]

Field & Ocean::SceneDescription::DynamicNode::dynamicField ( const std::string &  fieldName)

Returns the field base of a specified dynamic field.

Beware: Changing a field value using this function will not produce any field changing event functions!

Parameters
fieldNameName of the dynamic field to return
Returns
Field base of the specified dynamic field

◆ dynamicField() [2/4]

template<typename T >
T & Ocean::SceneDescription::DynamicNode::dynamicField ( const std::string &  fieldName)

Returns a specified dynamic field.

Beware: Changing a field value using this function will not produce any field changing event functions!

Parameters
fieldNameName of the dynamic field to return

◆ dynamicField() [3/4]

const Field & Ocean::SceneDescription::DynamicNode::dynamicField ( const std::string &  fieldName) const

Returns the field base of a specified dynamic field.

Parameters
fieldNameName of the dynamic field to return
Returns
Field base of the specified dynamic field

◆ dynamicField() [4/4]

template<typename T >
const T & Ocean::SceneDescription::DynamicNode::dynamicField ( const std::string &  fieldName) const

Returns a specified dynamic field.

Parameters
fieldNameName of the dynamic field to return

◆ dynamicFieldName()

const std::string & Ocean::SceneDescription::DynamicNode::dynamicFieldName ( const unsigned int  index) const

Returns the name of a dynamic field by a given index.

The index reflects the order in which the fields have been added, it is not stable across a removeField() call.

Parameters
indexIndex of the dynamic field to return, with range [0, dynamicFields())
Returns
The name of the dynamic field
Exceptions
OceanExceptionIs thrown if the index does not exist

◆ dynamicFields()

unsigned int Ocean::SceneDescription::DynamicNode::dynamicFields ( ) const
inline

Returns the number of dynamic fields.

Together with dynamicFieldName() this allows to enumerate all dynamic fields of this node.

Returns
Number of dynamic fields

◆ hasAnyField()

bool Ocean::SceneDescription::DynamicNode::hasAnyField ( const std::string &  fieldName) const
overridevirtual

Returns whether this node has a special standard or dynamic field.

See also
Node::hasAnyField().

Reimplemented from Ocean::SceneDescription::Node.

◆ hasDynamicField()

bool Ocean::SceneDescription::DynamicNode::hasDynamicField ( const std::string &  name) const

Returns whether this node holds a specific dynamic field.

Parameters
nameThe name of the dynamic field to check
Returns
True, if so

◆ isDynamic()

bool Ocean::SceneDescription::DynamicNode::isDynamic ( ) const
overridevirtual

Returns whether this node can hold dynamic generated field.

See also
Node::isDynamic().

Reimplemented from Ocean::SceneDescription::Node.

◆ removeField()

bool Ocean::SceneDescription::DynamicNode::removeField ( const std::string &  name)

Removes a field added during runtime.

The remaining fields keep their relative order but are re-indexed, so every index above the removed one is invalidated.

Parameters
nameThe name of the field to remove, must be valid
Returns
True, if the field could be remove

Field Documentation

◆ dynamicFieldIndices_

DynamicFieldIndices Ocean::SceneDescription::DynamicNode::dynamicFieldIndices_
protected

Map mapping names of dynamic fields to indices.

◆ dynamicFields_

DynamicFields Ocean::SceneDescription::DynamicNode::dynamicFields_
protected

Vector holding the dynamic fields.


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