H3D API  2.4.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
H3D::MFieldBase< Type, VectorClass, BaseField > Class Template Reference

The common base class for MField types and MFNode. More...

#include <H3D/MField.h>

Inheritance diagram for H3D::MFieldBase< Type, VectorClass, BaseField >:
Inheritance graph

Public Types

typedef VectorClass vector_type
 The type of the value member.
 
typedef VectorClass vector_return_type
 The return type of functions that return the value of the field.
 
typedef VectorClass::value_type value_type
 The type of the values stored in the vector.
 
typedef VectorClass::pointer pointer
 Pointer to Type.
 
typedef VectorClass::const_reference const_reference
 Const reference to Type.
 
typedef VectorClass::size_type size_type
 An unsigned integral type.
 
typedef VectorClass::difference_type difference_type
 A signed integral type.
 
typedef VectorClass::const_iterator const_iterator
 Const iterator used to iterate through a vector.
 
typedef VectorClass::const_reverse_iterator const_reverse_iterator
 Const iterator used to iterate backwards through a vector.
 
- Public Types inherited from H3D::Field
enum  AccessType { INITIALIZE_ONLY , OUTPUT_ONLY , INPUT_ONLY , INPUT_OUTPUT }
 The different access types that a field can have. More...
 

Public Member Functions

const_iterator begin (int id=0)
 Returns a const_iterator pointing to the beginning of the vector.
 
const_iterator end (int id=0)
 Returns a const_iterator pointing to the end of the vector.
 
const_reverse_iterator rbegin (int id=0)
 Returns a const_reverse_iterator pointing to the beginning of the reversed vector. More...
 
const_reverse_iterator rend (int id=0)
 Returns a const_reverse_iterator pointing to the end of the reversed vector. More...
 
unsigned int size ()
 Returns the size of the vector.
 
size_type max_size ()
 Returns the largest possible size of the vector.
 
size_type capacity ()
 Number of elements for which memory has been allocated. More...
 
void reserve (size_type s)
 A request for allocation of additional memory. More...
 
void resize (size_type n, Type t=Type(), int id=0)
 Inserts or erases elements at the end such that the size becomes n.
 
bool empty ()
 true if the vector's size is 0.
 
const_reference operator[] (size_type n)
 Returns the n'th element.
 
const_reference front (int id=0)
 Returns the first element.
 
const_reference back (int id=0)
 Returns the last element.
 
void swap (VectorClass &x, int id=0)
 Swaps the contents of two vectors.
 
void push_back (const Type &x, int id=0)
 Inserts a new element at the end.
 
void pop_back (int id=0)
 Removed the last element.
 
void clear (int id=0)
 Erases all of the elements.
 
virtual int setValueFromVoidPtr (const void *data, unsigned int nr_elements, unsigned int len, int id=0)
 Set the value of the field given a pointer to where the value of the field is. More...
 
virtual int getValueAsVoidPtr (void *data, unsigned int &nr_elements, unsigned int len, int id=0)
 Get the value of the data copied into a memory buffer. More...
 
virtual unsigned int valueTypeSize ()
 Returns the size in bytes of the value type the mfield encapsulates.
 
 MFieldBase ()
 Default constructor. Creates an empty MField.
 
 MFieldBase (size_type sz)
 Creates a MField with space reserved for n elements.
 
- Public Member Functions inherited from H3D::ParsableMField
virtual size_t getSize ()=0
 Set the value of the field given a string. More...
 
virtual string getElementAsString (size_t)
 Get the value of an element of the field as a string.
 
virtual void addElementFromString (const string &s)=0
 Add a new element to an MField from a string value.
 
- Public Member Functions inherited from H3D::ParsableField
virtual void setValueFromString (const string &s)=0
 Set the value of the field given a string. More...
 
virtual string getValueAsString (const string &=" ")
 Get the value of the field as a string. More...
 
- Public Member Functions inherited from H3D::Field
 Field ()
 Constructor.
 
virtual ~Field ()
 Destructor.
 
void setName (string _name)
 Sets local the name of the field. Will be used in error reporting.
 
string getName ()
 Gets the name of the field.
 
string getFullName ()
 Get the full name of the field including the name of the owner node if it exists (ownername.fieldname). More...
 
virtual string getTypeName ()
 Returns a string name for this field type.
 
virtual X3DTypes::X3DType getX3DType ()
 Returns the X3DType of the field.
 
virtual void route (Field *, int id=0)
 Set up a route from this field to the field given as argument. More...
 
virtual void routeNoEvent (Field *, int id=0)
 Set up a route from this field to the field given as argument. More...
 
virtual void unroute (Field *)
 Remove the route from this field to the field given as argument.
 
virtual FieldreplaceRoute (Field *f, unsigned int i, int id=0)
 Replace the i:th route to f with a route from this field. More...
 
virtual FieldreplaceRouteNoEvent (Field *f, unsigned int i, int id=0)
 Replace the i:th route to f with a route from this field. More...
 
template<class F >
void route (H3DUniquePtr< F > &f, int id=0)
 Set up a route from this field to the field residing in the H3DUniquePtr given as argument. More...
 
template<class F >
void routeNoEvent (H3DUniquePtr< F > &f, int id=0)
 Set up a route from this field to the field residing in the H3DUniquePtr given as argument. More...
 
template<class F >
void unroute (H3DUniquePtr< F > &f)
 Remove the route from this field to the field residing in the H3DUniquePtr given as argument.
 
void unrouteAll ()
 Remove all the routes from this field.
 
virtual void upToDate ()
 Check that the field is up-to-date, if not update() is called to make it up-to-date.
 
bool isUpToDate ()
 Returns true if the field is up to date, i.e. More...
 
virtual void touch ()
 Generates an event from this field.
 
NodegetOwner ()
 Get the Node that contains this field.
 
void setOwner (Node *n)
 Set the Node that contains this field.
 
void setAccessType (AccessType _access_type)
 Set the access type of the field.
 
AccessType getAccessType ()
 Get the access type of the field.
 
bool routesTo (Field *f)
 Returns true if this field is routed to the field given as argument.
 
bool hasRouteFrom (Field *f)
 Returns true if the field given as argument is routed to this field.
 
const FieldVector & getRoutesIn ()
 Get the Fields that are routed to this Field.
 
const FieldSet & getRoutesOut ()
 Get the Fields this Field is routed to.
 
const EventgetLatestEvent ()
 Get the latest event.
 
void setAccessCheck (bool on)
 Set access type checking on or off. More...
 
bool isAccessCheckOn ()
 Returns true if checking of access types is on.
 
- Public Member Functions inherited from H3D::MFieldClass
virtual ~MFieldClass ()
 Virtual destructor.
 
virtual int setValueFromVoidPtr (void *data, unsigned int nr_elements, unsigned int size, int id=0)
 

Static Public Member Functions

static string classTypeName ()
 Returns a string name for this field type e.g. MFInt32.
 
- Static Public Member Functions inherited from H3D::Field
static string classTypeName ()
 Returns a string name for this field type. More...
 

Protected Attributes

VectorClass value
 The encapsulated vector.
 
- Protected Attributes inherited from H3D::Field
string name
 The name of the field.
 
bool event_lock
 If true, stops events from being propagated. More...
 
bool update_lock
 If true, stops the update() function from being called in the upToDate() function.
 
FieldSet routes_out
 The Fields that this field is routed to.
 
FieldVector routes_in
 The Field that are routed to this field.
 
Event event
 The last event that happened.
 
Nodeowner
 The node that contain this field. More...
 
AccessType access_type
 The type of access to the field.
 
bool access_check_on
 If true, access type checks will be done when getting/setting values and setting up routes. More...
 

Additional Inherited Members

- Protected Member Functions inherited from H3D::TypedField< ParsableMField, void, AnyNumber< MFieldBase< Type, std::vector< Type >, ParsableMField > > >
void checkFieldType (Field *f, int index)
 Function for checking that a field is of a correct type given type specification according to the TypedField template arguments. More...
 
void checkTemplateArguments ()
 Function for checking that a field given TypedField type specification is valid. More...
 
- Protected Member Functions inherited from H3D::Field
virtual void startEvent ()
 Start a new event from this field. More...
 
virtual void propagateEvent (Event e)
 Propagates an event to all Fields we are routed to. More...
 
virtual void routeFrom (Field *, int id)
 Set up a route to this field from the field given as argument.
 
virtual void unrouteFrom (Field *)
 Remove the route to this field from the field given as argument.
 
virtual FieldreplaceRouteFrom (Field *f, unsigned int i, int id)
 Replace the i:th route to this field with the field given as argument.
 
virtual void update ()
 This function will be called to update the field if it has a pending event when the upToDate() function is called.
 
void checkAccessTypeRoute (Field *f, int id)
 Check the access type is correct for performing a route from this field to f. More...
 
void checkAccessTypeRouteFrom (Field *f, int id)
 Check the access type is correct for performing a route from f to this field. More...
 
void checkAccessTypeGet (int id)
 Check the access type is valid for getting the value of a field. More...
 
void checkAccessTypeSet (int id)
 Check the access type is valid for changing the value of a field. More...
 
int ownerId ()
 Gets the id of the owner node, -1 if no owner.
 
bool isProgramSetting ()
 Returns true if this field is part of program settings fields. More...
 
void markProgramSetting (bool used_as_setting)
 Set it this field is used by program settings fields in scene or not.
 

Detailed Description

template<class Type, class VectorClass = std::vector< Type >, class BaseField = ParsableMField>
class H3D::MFieldBase< Type, VectorClass, BaseField >

The common base class for MField types and MFNode.

It defines the common interface between MFNode and MField <>. It encapsulates a vector of values of a certain type with the Field mechanisms.

Parameters
TypeThe type the values in the vector.
VectorClassThe actual vector type.
BaseFieldThe Field base class to inherit from.

Member Function Documentation

◆ capacity()

template<class Type , class VectorClass = std::vector< Type >, class BaseField = ParsableMField>
size_type H3D::MFieldBase< Type, VectorClass, BaseField >::capacity ( )
inline

Number of elements for which memory has been allocated.

capacity() is always greater than or equal to size().

References H3D::Field::upToDate(), and H3D::MFieldBase< Type, VectorClass, BaseField >::value.

◆ getValueAsVoidPtr()

template<class Type , class VectorClass = std::vector< Type >, class BaseField = ParsableMField>
virtual int H3D::MFieldBase< Type, VectorClass, BaseField >::getValueAsVoidPtr ( void *  data,
unsigned int &  nr_elements,
unsigned int  len,
int  id = 0 
)
inlinevirtual

Get the value of the data copied into a memory buffer.

Parameters
dataBuffer to copy the data into.
nr_elementsThis parameter will be set to the nr of values in the mfield.
lenThe size of the buffer.
idId of the node calling this function. Used to check access type.
Returns
If successful: The number of bytes that was copied into the Otherwise -1.

Implements H3D::MFieldClass.

References H3D::Field::upToDate(), and H3D::MFieldBase< Type, VectorClass, BaseField >::value.

◆ rbegin()

template<class Type , class VectorClass = std::vector< Type >, class BaseField = ParsableMField>
const_reverse_iterator H3D::MFieldBase< Type, VectorClass, BaseField >::rbegin ( int  id = 0)
inline

Returns a const_reverse_iterator pointing to the beginning of the reversed vector.

Parameters
idId of the node calling this function. Used to check access type.

References H3D::Field::checkAccessTypeGet(), H3D::Field::upToDate(), and H3D::MFieldBase< Type, VectorClass, BaseField >::value.

◆ rend()

template<class Type , class VectorClass = std::vector< Type >, class BaseField = ParsableMField>
const_reverse_iterator H3D::MFieldBase< Type, VectorClass, BaseField >::rend ( int  id = 0)
inline

Returns a const_reverse_iterator pointing to the end of the reversed vector.

Parameters
idId of the node calling this function. Used to check access type.

References H3D::Field::checkAccessTypeGet(), H3D::Field::upToDate(), and H3D::MFieldBase< Type, VectorClass, BaseField >::value.

◆ reserve()

template<class Type , class VectorClass = std::vector< Type >, class BaseField = ParsableMField>
void H3D::MFieldBase< Type, VectorClass, BaseField >::reserve ( size_type  s)
inline

A request for allocation of additional memory.

If s is less than or equal to capacity(), this call has no effect. Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to s; otherwise, capacity() is unchanged. In either case, size() is unchanged.

References H3D::Field::upToDate(), and H3D::MFieldBase< Type, VectorClass, BaseField >::value.

◆ setValueFromVoidPtr()

template<class Type , class VectorClass = std::vector< Type >, class BaseField = ParsableMField>
virtual int H3D::MFieldBase< Type, VectorClass, BaseField >::setValueFromVoidPtr ( const void *  data,
unsigned int  nr_elements,
unsigned int  len,
int  id = 0 
)
inlinevirtual

Set the value of the field given a pointer to where the value of the field is.

Parameters
dataA pointer to the data.
nr_elementsThe number of values in the mfield.
lenThe size in bytes of the each value stored in the data.
idId of the node calling this function. Used to check access type.
Returns
0 if successful, -1 otherwise.

Implements H3D::MFieldClass.

References H3D::Field::checkAccessTypeSet(), H3D::Field::startEvent(), and H3D::MFieldBase< Type, VectorClass, BaseField >::value.


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