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

Template class that adds the Field mechanisms to an encapsulated value of specified type. More...

#include <H3D/SField.h>

Inheritance diagram for H3D::SField< Type >:
Inheritance graph

Public Types

typedef Type value_type
 The type of the value member.
 
- 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

 SField ()
 Constructor.
 
 SField (const Type &_value)
 Constructor.
 
virtual int setValueFromVoidPtr (const void *data, 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 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 sfield encapsulates.
 
virtual void setValue (const Type &v, int id=0)
 Set the value of the field.
 
virtual const Type & getValue (int id=0)
 Get the value of the field.
 
virtual void setValueFromString (const string &s)
 Set the value of the field given a string. More...
 
virtual string getValueAsString (const string &=" ")
 Get the value of the field as a string.
 
virtual string getTypeName ()
 Returns a string name for this field type e.g. SFInt32.
 
- 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 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::SFieldClass
virtual ~SFieldClass ()
 Virtual destructor.
 
virtual int setValueFromVoidPtr (void *data, unsigned int size, int id=0)
 

Static Public Member Functions

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

Protected Member Functions

virtual void update ()
 Make the field up to date given that an event has occured.
 
- Protected Member Functions inherited from H3D::TypedField< ParsableField, void, AnyNumber< SField< Type > > >
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.
 
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.
 

Protected Attributes

Type value
 The encapsulated value.
 
- 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...
 

Detailed Description

template<class Type>
class H3D::SField< Type >

Template class that adds the Field mechanisms to an encapsulated value of specified type.

Parameters
TypeThe type of the value.

Member Function Documentation

◆ getValueAsVoidPtr()

template<class Type >
virtual int H3D::SField< Type >::getValueAsVoidPtr ( void *  data,
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.
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::SFieldClass.

References H3D::SField< Type >::getValue().

◆ setValueFromString()

template<class Type >
virtual void H3D::SField< Type >::setValueFromString ( const string &  s)
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::SField< Type >::setValue().

◆ setValueFromVoidPtr()

template<class Type >
virtual int H3D::SField< Type >::setValueFromVoidPtr ( const void *  data,
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.
lenThe size in bytes of the value stored in data.
idId of the node calling this function. Used to check access type.
Returns
0 if successful, -1 otherwise.

Implements H3D::SFieldClass.

References H3D::SField< Type >::setValue().


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