8#ifndef META_OCEAN_SCENEDESCRIPTION_NODE_H
9#define META_OCEAN_SCENEDESCRIPTION_NODE_H
48class OCEAN_SCENEDESCRIPTION_EXPORT
Node
87 using FieldPair = std::pair<size_t, FieldAccessType>;
106 inline const std::string&
type()
const;
112 inline unsigned int size()
const;
127 const std::string&
fieldName(
const unsigned int index)
const;
198 inline const std::string&
name()
const;
204 inline const std::string&
type()
const;
246 template <
typename T>
const T&
field(
const std::string& fieldName)
const;
255 template <
typename T> T&
field(
const std::string& fieldName);
263 template <
typename T>
const T&
anyField(
const std::string& fieldName)
const;
272 template <
typename T> T&
anyField(
const std::string& fieldName);
404 return (
unsigned int)(
fields_.size());
426 const Field& unspecificField(
field(fieldName));
428 ocean_assert(unspecificField.
type() == T::fieldType);
429 ocean_assert(unspecificField.
dimension() == T::fieldDimension);
431 return dynamic_cast<const T&
>(unspecificField);
439 ocean_assert(unspecificField.
type() == T::fieldType);
440 ocean_assert(unspecificField.
dimension() == T::fieldDimension);
442 return dynamic_cast<T&
>(unspecificField);
450 ocean_assert(unspecificField.
type() == T::fieldType);
451 ocean_assert(unspecificField.
dimension() == T::fieldDimension);
453 return dynamic_cast<const T&
>(unspecificField);
461 ocean_assert(unspecificField.
type() == T::fieldType);
462 ocean_assert(unspecificField.
dimension() == T::fieldDimension);
464 return dynamic_cast<T&
>(unspecificField);
This class implements a recursive lock object.
Definition Lock.h:31
This template class implements a object reference with an internal reference counter.
Definition base/ObjectRef.h:58
This class is the base class for all scene description fields.
Definition Field.h:36
Type
Definition of scalar field types.
Definition Field.h:43
virtual Type type() const =0
Returns the type of this field.
virtual unsigned int dimension() const =0
Returns the dimension of this field.
This class implements a node specification object.
Definition scenedescription/Node.h:77
FieldAccessType fieldAccessType(const std::string &fieldName) const
Returns the access type of a specified field.
const std::string & type() const
Returns the type of this node.
Definition scenedescription/Node.h:397
std::string type_
Type of the node specified by this specification object.
Definition scenedescription/Node.h:169
std::pair< size_t, FieldAccessType > FieldPair
Definition of a field specification pair.
Definition scenedescription/Node.h:87
const std::string & fieldName(const unsigned int index) const
Returns the name of the specific field.
friend class Node
Definition scenedescription/Node.h:78
NodeSpecification(const std::string &type)
Creates a new node specification object.
void registerField(const size_t objectAddress, const std::string &fieldName, const Field &field, const FieldAccessType accessType)
Registers a new field to a specific node type.
const Field & field(const size_t objectAddress, const std::string &fieldName) const
Returns a specific field of a specific node instance.
bool hasField(const std::string &fieldName) const
Returns whether the node specification holds a specific field.
unsigned int size() const
Returns the number registered fields.
Definition scenedescription/Node.h:402
Field & field(const size_t objectAddress, const std::string &fieldName)
Returns a specific field of a specific node instance.
std::map< std::string, FieldPair > FieldSpecificationMap
Definition of a map mapping field names to field address offsets.
Definition scenedescription/Node.h:92
FieldSpecificationMap fields_
Map mapping field name to address offsets.
Definition scenedescription/Node.h:172
This class is the base class for all scene description nodes.
Definition scenedescription/Node.h:49
virtual bool isDynamic() const
Returns whether this node can hold dynamic generated field.
Node(const Node &node)=delete
Disabled copy constructor.
std::map< std::string, Field * > FieldMap
Definition of a map mapping field names to fields.
Definition scenedescription/Node.h:178
const std::string & name() const
Returns the name of this node.
Definition scenedescription/Node.h:412
NodeId id() const
Returns the unique node id of this node.
Definition scenedescription/Node.h:407
virtual size_t objectAddress() const
Returns the address of the most derived object.
Field::Type fieldType(const std::string &fieldName) const
Returns the type of a special field.
Node & operator=(const Node &node)=delete
Disabled copy operator.
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.
Node()
Creates a new node.
FieldAccessType fieldAccessType(const std::string &fieldName) const
Returns the access type of a specified field.
const std::string & type() const
Returns the type of this node.
Definition scenedescription/Node.h:417
virtual DescriptionType descriptionType() const =0
Returns the scene description type of this node.
NodeId nodeId_
Unique node id.
Definition scenedescription/Node.h:381
std::string name_
Node name.
Definition scenedescription/Node.h:384
virtual Field & anyField(const std::string &fieldName)
Returns the field base of a specified standard or dynamic field.
virtual ~Node()
Destructs a node.
Field & field(const std::string &fieldName)
Returns the field base of a specified (standard) field.
const Field & field(const std::string &fieldName) const
Returns the field base of a specified (standard) field.
FieldAccessType
Definition of different field access types.
Definition scenedescription/Node.h:58
@ ACCESS_GET
Read only field.
Definition scenedescription/Node.h:62
@ ACCESS_SET
Write only field.
Definition scenedescription/Node.h:64
@ ACCESS_EXPLICIT_NOTIFICATION
Field which will produce an explicit update event if it receives a new value.
Definition scenedescription/Node.h:68
@ ACCESS_NONE
No access possible, which can be a static field.
Definition scenedescription/Node.h:60
@ ACCESS_GET_SET
Read and write field.
Definition scenedescription/Node.h:66
virtual const Field & anyField(const std::string &fieldName) const
Returns the field base of a specified standard or dynamic field.
static NodeId nodeIdCounter_
Unique node id counter.
Definition scenedescription/Node.h:394
NodeSpecification * specification_
Pointer to the node specification, guaranteed to exist as long as the node exist.
Definition scenedescription/Node.h:391
static Lock & nodeIdCounterLock()
Returns the lock for the node id counter.
virtual void setName(const std::string &name)
Sets the name of this node.
virtual bool hasAnyField(const std::string &fieldName) const
Returns whether this node has a special standard or dynamic field.
virtual std::string originalFieldName(const std::string &fieldName) const
Tries to translate an alias field name to the original field name.
unsigned int fieldDimension(const std::string &fieldName) const
Return the dimension of a special field.
bool hasField(const std::string &fieldName) const
Returns whether this node has a special (standard) field.
std::vector< NodeRef > NodeRefs
Definition of a vector holding scene description node references.
Definition scenedescription/Node.h:42
DescriptionType
Definition of different scene description types.
Definition SceneDescription.h:64
Ocean::ObjectRef< Node > NodeRef
Definition of a scene description node reference with an internal reference counter.
Definition scenedescription/Node.h:36
size_t NodeId
Definition of a object id.
Definition SceneDescription.h:41
Namespace of the SceneDescription library.
Definition DynamicNode.h:21
The namespace covering the entire Ocean framework.
Definition Accessor.h:15