H3D API  2.4.1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
H3D::RefCountMField< RefClass > Class Template Reference

RefCountMField is almost like any MField but it encapsulates a vector of RefCoundtedClass pointers. More...

#include <H3D/RefCountMField.h>

Inheritance diagram for H3D::RefCountMField< RefClass >:
Inheritance graph

Classes

class  InvalidIndex
 Thrown if the index given to getValueByIndex() is outside the boundaries. More...
 

Public Member Functions

 RefCountMField ()
 Default constructor. Creates an empty RefCountMField.
 
 RefCountMField (typename FieldInternals::MFNodeAutoRefVector< RefClass >::size_type sz)
 Creates an RefCountMField with space reserved for size nodes.
 
virtual const NodeVectorgetValue (int id=0)
 Get the value of the MField.
 
virtual RefClass * getValueByIndex (typename BaseFieldType::size_type i, int id=0)
 Get the value of the MField.
 
void setValue (typename FieldInternals::MFNodeAutoRefVector< RefClass >::size_type i, const typename FieldInternals::MFNodeAutoRefVector< RefClass >::value_type &v, int id=0)
 Set the value of an element in the field. More...
 
virtual void setValue (const AutoRefVector< RefClass > &v, int id=0)
 Set the value of the field. More...
 
virtual void setValue (const vector< RefClass * > &v, int id=0)
 Set the value of the field. More...
 
virtual void swap (vector< RefClass * > &v, int id=0)
 Swaps the contents of two vectors. More...
 
virtual void erase (RefClass *a, int id=0)
 Erase the first element equal to a. More...
 
virtual void erase (unsigned int pos, int id=0)
 Erase the element at the specified index. More...
 
virtual void insert (unsigned int pos, RefClass *a, int id=0)
 Insert an element before the index given by pos. More...
 
virtual string getTypeName ()
 Returns a string name for this field type i.e. SFNode.
 
- Public Member Functions inherited from H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >
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, RefClass * t=RefClass *(), 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 (FieldInternals::MFNodeAutoRefVector< RefClass > &x, int id=0)
 Swaps the contents of two vectors.
 
void push_back (const RefClass * &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::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 i.e. SFNode.
 
- Static Public Member Functions inherited from H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >
static string classTypeName ()
 Returns a string name for this field type e.g. MFInt32.
 

Protected Member Functions

virtual void update ()
 Make the field up to date given that an event has occured.
 
virtual void onAdd (RefClass *n)
 This function will be called when values of RefCountMField changes. More...
 
virtual void onRemove (RefClass *n)
 This function will be called when values of RefCountMField changes. More...
 
- Protected Member Functions inherited from H3D::TypedField< BaseField, RequiredArgTypes, OptionalArgTypes >
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...
 

Additional Inherited Members

- Public Types inherited from H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >
typedef FieldInternals::MFNodeAutoRefVector< RefClass > vector_type
 The type of the value member.
 
typedef FieldInternals::MFNodeAutoRefVector< RefClass > 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.
 
- Protected Attributes inherited from H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >
FieldInternals::MFNodeAutoRefVector< RefClass > value
 The encapsulated vector.
 

Detailed Description

template<class RefClass>
class H3D::RefCountMField< RefClass >

RefCountMField is almost like any MField but it encapsulates a vector of RefCoundtedClass pointers.

Reference counting on the encapsulated RefCountedClass instances are upheld when changes to the values are made.

Member Function Documentation

◆ erase() [1/2]

template<class RefClass >
virtual void H3D::RefCountMField< RefClass >::erase ( RefClass *  a,
int  id = 0 
)
inlinevirtual

Erase the first element equal to a.

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

References H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >::value.

◆ erase() [2/2]

template<class RefClass >
virtual void H3D::RefCountMField< RefClass >::erase ( unsigned int  pos,
int  id = 0 
)
inlinevirtual

Erase the element at the specified index.

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

References H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >::value.

◆ insert()

template<class RefClass >
virtual void H3D::RefCountMField< RefClass >::insert ( unsigned int  pos,
RefClass *  a,
int  id = 0 
)
inlinevirtual

Insert an element before the index given by pos.

Parameters
posPosition before which to insert.
aValue to insert.
idId of the node calling this function. Used to check access type.

References H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >::value.

◆ onAdd()

template<class RefClass >
virtual void H3D::RefCountMField< RefClass >::onAdd ( RefClass *  n)
inlineprotectedvirtual

◆ onRemove()

template<class RefClass >
virtual void H3D::RefCountMField< RefClass >::onRemove ( RefClass *  n)
inlineprotectedvirtual

This function will be called when values of RefCountMField changes.

As soon as a Node is removed onRemove will be called on the removed value.

Parameters
nThe removed value.

Reimplemented in H3D::NurbsTrimmedSurface::CheckContour, H3D::NurbsTrimmedSurface::RemoveContour, H3D::LayeredRenderer::MFHapticsRendererNode, H3D::Contour2D::CheckTheChildren, and H3D::Contour2D::RemoveTheChildren.

◆ setValue() [1/3]

template<class RefClass >
virtual void H3D::RefCountMField< RefClass >::setValue ( const AutoRefVector< RefClass > &  v,
int  id = 0 
)
inlinevirtual

Set the value of the field.

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

References H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >::value.

◆ setValue() [2/3]

template<class RefClass >
virtual void H3D::RefCountMField< RefClass >::setValue ( const vector< RefClass * > &  v,
int  id = 0 
)
inlinevirtual

Set the value of the field.

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

References H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >::value.

◆ setValue() [3/3]

template<class RefClass >
void H3D::RefCountMField< RefClass >::setValue ( typename FieldInternals::MFNodeAutoRefVector< RefClass >::size_type  i,
const typename FieldInternals::MFNodeAutoRefVector< RefClass >::value_type v,
int  id = 0 
)
inline

Set the value of an element in the field.

Parameters
iIndex of the element.
vThe new value.
idId of the node calling this function. Used to check access type.

References H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >::value.

◆ swap()

template<class RefClass >
virtual void H3D::RefCountMField< RefClass >::swap ( vector< RefClass * > &  v,
int  id = 0 
)
inlinevirtual

Swaps the contents of two vectors.

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

References H3D::MFieldBase< RefClass *, FieldInternals::MFNodeAutoRefVector< RefClass >, Field >::value.


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