H3D API
2.4.1
|
Template class that adds the Field mechanism to a vector of values. More...
#include <H3D/MField.h>
Classes | |
class | InvalidIndex |
Thrown if the index given to getValueByIndex() is outside the boundaries. More... | |
Public Types | |
typedef std::vector< Type >::iterator | iterator |
iterator used to iterate through a vector. | |
![]() | |
typedef std::vector< Type > | vector_type |
The type of the value member. | |
typedef std::vector< Type > | 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. | |
![]() | |
enum | AccessType { INITIALIZE_ONLY , OUTPUT_ONLY , INPUT_ONLY , INPUT_OUTPUT } |
The different access types that a field can have. More... | |
Public Member Functions | |
MField () | |
Default constructor. Creates an empty MField. | |
MField (typename BaseMField::size_type sz) | |
Creates an MField with space reserved for size nodes. | |
virtual const std::vector< Type > & | getValue (int id=0) |
Get the value of the MField. | |
virtual std::vector< Type >::const_reference | getValueByIndex (typename BaseMField::size_type i, int id=0) |
Get the value of an element of the MField. More... | |
virtual void | setValue (const std::vector< Type > &v, int id=0) |
Set the value of the field. More... | |
virtual void | setValue (typename BaseMField::size_type i, const Type &v, int id=0) |
Change the value of one element in the MField. More... | |
virtual void | setValueFromString (const string &s) |
Set the value of the field given a string. More... | |
virtual void | addElementFromString (const string &s) |
Add a new element to an MField from a string value. | |
virtual string | getValueAsString (const string &separator=" ") |
Get the value of the field as a string. More... | |
MField< Type >::const_iterator | insert (typename MField< Type >::const_iterator pos, const Type &x, int id=0) |
Inserts x before pos. | |
template<class InputIterator > | |
void | insert (typename MField< Type >::const_iterator pos, InputIterator first, InputIterator last, int id=0) |
Inserts the range [first, last) before pos. | |
void | insert (typename MField< Type >::const_iterator pos, typename BaseMField::size_type n, const Type &x, int id=0) |
Inserts n copies of x before pos. | |
virtual void | erase (typename MField< Type >::const_iterator pos, int id=0) |
Erases the element at position pos. | |
virtual void | erase (typename MField< Type >::const_iterator first, typename MField< Type >::const_iterator last, int id=0) |
Erases the range [first, last) | |
virtual void | erase (const Type &a, int=0) |
Erase the first element equal to a. | |
virtual string | getTypeName () |
Returns a string name for this field type e.g. MFInt32. | |
virtual size_t | getSize () |
Set the value of the field given a string. More... | |
virtual string | getElementAsString (size_t element) |
Get the value of an element of the field as a string. | |
![]() | |
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 (std::vector< Type > &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. | |
![]() | |
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 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 Field * | replaceRoute (Field *f, unsigned int i, int id=0) |
Replace the i:th route to f with a route from this field. More... | |
virtual Field * | replaceRouteNoEvent (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. | |
Node * | getOwner () |
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 Event & | getLatestEvent () |
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. | |
![]() | |
virtual | ~MFieldClass () |
Virtual destructor. | |
virtual int | setValueFromVoidPtr (void *data, unsigned int nr_elements, unsigned int size, int id=0) |
Protected Member Functions | |
virtual void | update () |
Make the field up to date given that an event has occured. | |
iterator | iteratorFromConst (typename MField< Type >::const_iterator pos) |
Helper function to get an iterator from a const_iterator. | |
![]() | |
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... | |
![]() | |
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 Field * | replaceRouteFrom (Field *f, unsigned int i, int id) |
Replace the i:th route to this field with the field given as argument. | |
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. | |
Additional Inherited Members | |
![]() | |
static string | classTypeName () |
Returns a string name for this field type e.g. MFInt32. | |
![]() | |
static string | classTypeName () |
Returns a string name for this field type. More... | |
![]() | |
std::vector< Type > | value |
The encapsulated vector. | |
![]() | |
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. | |
Node * | owner |
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... | |
Template class that adds the Field mechanism to a vector of values.
Type | The type of the values in the vector. |
|
inlinevirtual |
Set the value of the field given a string.
By default we try to parse the values according to the X3D/XML specification.
Implements H3D::ParsableMField.
References H3D::MField< Type >::getValue().
|
inlinevirtual |
Get the value of the field as a string.
If the field contains multiple values the separator string is used between the values.
Reimplemented from H3D::ParsableField.
Reimplemented in H3D::MFString, and H3D::MFBool.
References H3D::MField< Type >::getValue().
|
inlinevirtual |
Get the value of an element of the MField.
i | The index of the element. |
id | Id of the node calling this function. Used to check access type. |
References H3D::Field::checkAccessTypeGet(), H3D::Field::getFullName(), H3D_FULL_LOCATION, H3D::Field::name, H3D::Field::upToDate(), and H3D::MFieldBase< Type, std::vector< Type >, ParsableMField >::value.
Referenced by H3D::GeometryGroup::MFVec3fPerIndex::update().
|
inlinevirtual |
Set the value of the field.
v | The new value. |
id | Id of the node calling this function. Used to check access type. |
Referenced by H3D::MField< Type >::setValueFromString().
|
inlinevirtual |
Change the value of one element in the MField.
i | The index of the value to set. |
v | The new value. |
id | Id of the node calling this function. Used to check access type. |
References H3D::Field::checkAccessTypeSet(), H3D::Field::name, H3D::Field::startEvent(), and H3D::MFieldBase< Type, std::vector< Type >, ParsableMField >::value.
|
inlinevirtual |
Set the value of the field given a string.
By default we try to parse the values according to the X3D/XML specification.
Implements H3D::ParsableField.
References H3D::MField< Type >::setValue().