8 #ifndef META_OCEAN_SCENEDESCRIPTION_NODE_H
9 #define META_OCEAN_SCENEDESCRIPTION_NODE_H
22 namespace SceneDescription
48 class OCEAN_SCENEDESCRIPTION_EXPORT
Node
66 ACCESS_GET_SET = ACCESS_GET | ACCESS_SET,
68 ACCESS_EXPLICIT_NOTIFICATION = 4
87 typedef std::pair<size_t, FieldAccessType>
FieldPair;
106 inline const std::string& type()
const;
112 inline unsigned int size()
const;
127 const std::string&
fieldName(
const unsigned int index)
const;
144 const Field&
field(
const size_t objectAddress,
const std::string& fieldName)
const;
153 Field&
field(
const size_t objectAddress,
const std::string& fieldName);
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);
286 virtual void setName(
const std::string& name);
404 return (
unsigned int)(fields_.size());
423 template <
typename T>
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);
434 template <
typename T>
439 ocean_assert(unspecificField.
type() == T::fieldType);
440 ocean_assert(unspecificField.
dimension() == T::fieldDimension);
442 return dynamic_cast<T&
>(unspecificField);
445 template <
typename T>
450 ocean_assert(unspecificField.
type() == T::fieldType);
451 ocean_assert(unspecificField.
dimension() == T::fieldDimension);
453 return dynamic_cast<const T&
>(unspecificField);
456 template <
typename T>
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
Field & field(const size_t objectAddress, const std::string &fieldName)
Returns a specific field of a specific node instance.
const std::string & fieldName(const unsigned int index) const
Returns the name of the specific field.
NodeSpecification(const std::string &type)
Creates a new node specification object.
const Field & field(const size_t objectAddress, const std::string &fieldName) const
Returns a specific field of a specific node instance.
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.
bool hasField(const std::string &fieldName) const
Returns whether the node specification holds a specific field.
std::map< std::string, FieldPair > FieldSpecificationMap
Definition of a map mapping field names to field address offsets.
Definition: scenedescription/Node.h:92
unsigned int size() const
Returns the number registered fields.
Definition: scenedescription/Node.h:402
std::pair< size_t, FieldAccessType > FieldPair
Definition of a field specification pair.
Definition: scenedescription/Node.h:87
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.
virtual const Field & anyField(const std::string &fieldName) const
Returns the field base of a specified standard or dynamic field.
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.
static Lock & nodeIdCounterLock()
Returns the lock for the node id counter.
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.
virtual Field & anyField(const std::string &fieldName)
Returns the field base of a specified standard or dynamic 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.
Node & operator=(const Node &node)=delete
Disabled copy operator.
NodeId nodeId_
Unique node id.
Definition: scenedescription/Node.h:381
std::string name_
Node name.
Definition: scenedescription/Node.h:384
virtual ~Node()
Destructs a node.
const Field & field(const std::string &fieldName) const
Returns the field base of a specified (standard) field.
std::map< std::string, Field * > FieldMap
Definition of a map mapping field names to fields.
Definition: scenedescription/Node.h:178
FieldAccessType
Definition of different field access types.
Definition: scenedescription/Node.h:58
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
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.
Field & field(const std::string &fieldName)
Returns the field base of a specified (standard) field.
Ocean::ObjectRef< Node > NodeRef
Definition of a scene description node reference with an internal reference counter.
Definition: scenedescription/Node.h:29
DescriptionType
Definition of different scene description types.
Definition: SceneDescription.h:64
std::vector< NodeRef > NodeRefs
Definition of a vector holding scene description node references.
Definition: scenedescription/Node.h:42
size_t NodeId
Definition of a object id.
Definition: SceneDescription.h:41
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15