28 #ifndef __REFCOUNTMFIELD_H__
29 #define __REFCOUNTMFIELD_H__
46 template<
class RefClass >
49 FieldInternals::MFNodeAutoRefVector< RefClass >,
56 FieldInternals::MFNodeAutoRefVector< RefClass >,
66 AUTOREF_DEBUG_NAME(
value,
"RefCountMField::value")
67 this->
value.owner =
this;
73 FieldInternals::MFNodeAutoRefVector< RefClass >,
75 AUTOREF_DEBUG_NAME(
value,
"RefCountMField::value")
76 this->
value.owner =
this;
84 inline virtual const NodeVector &
getValue(
int id = 0 ) {
85 this->checkAccessTypeGet(
id );
94 this->checkAccessTypeGet(
id );
97 if( i >= this->
value.size() ) {
99 s <<
"Trying to access value outside the bounds of field "
100 << this->getFullName() <<
". Field has size " << this->
value.size()
104 return this->
value[i];
115 this->checkAccessTypeSet(
id );
116 this->
value.set( i, v );
127 this->checkAccessTypeSet(
id );
136 inline virtual void setValue(
const vector< RefClass * > &v,
int id = 0 ) {
137 this->checkAccessTypeSet(
id );
146 inline virtual void swap( vector< RefClass * > &v,
int id = 0 ) {
147 this->checkAccessTypeSet(
id );
148 this->checkAccessTypeGet(
id );
150 this->
value.swap( v );
158 inline virtual void erase( RefClass *a,
int id = 0 ) {
159 this->checkAccessTypeSet(
id );
161 this->
value.erase( a );
169 inline virtual void erase(
unsigned int pos,
int id = 0 ) {
170 this->checkAccessTypeSet(
id );
172 this->
value.erase( pos );
181 inline virtual void insert(
unsigned int pos,
184 this->checkAccessTypeSet(
id );
186 this->
value.insert( pos, a );
197 return "RefCountMField";
201 friend class FieldInternals::MFNodeAutoRefVector<RefClass>;
208 virtual RefClass *preOnAdd( RefClass *n ) {
212 virtual RefClass *preOnRemove( RefClass *n ) {
217 H3D_DISABLE_UNUSED_PARAMETER_WARNING()
223 #ifdef REF_COUNT_DEBUG
224 Console(LogLevel::Debug) <<
"RefCountMField::onAdd( " << getFullName() <<
" = " <<
this
225 <<
", n = " << n <<
") " << endl;
234 #ifdef REF_COUNT_DEBUG
235 Console(LogLevel::Debug) <<
"RefCountMField::onRemove( " << getFullName() <<
" = "
236 <<
this <<
", n = " << n <<
") " << endl;
#define H3D_FULL_LOCATION
Contains the MFNodeAutoRefVector class.
Contains base classes used to create multivalued fields.
std::vector< RefCountedClassType * >::size_type size_type
std::vector< RefCountedClassType * >::value_type value_type
The Field class.
Definition: Field.h:46
The common base class for MField types and MFNode.
Definition: MField.h:105
FieldInternals::MFNodeAutoRefVector< RefClass > value
The encapsulated vector.
Definition: MField.h:346
VectorClass::size_type size_type
An unsigned integral type.
Definition: MField.h:118
Thrown if the index given to getValueByIndex() is outside the boundaries.
Definition: RefCountMField.h:61
RefCountMField is almost like any MField but it encapsulates a vector of RefCoundtedClass pointers.
Definition: RefCountMField.h:50
virtual void insert(unsigned int pos, RefClass *a, int id=0)
Insert an element before the index given by pos.
Definition: RefCountMField.h:181
virtual void erase(RefClass *a, int id=0)
Erase the first element equal to a.
Definition: RefCountMField.h:158
RefCountMField(typename FieldInternals::MFNodeAutoRefVector< RefClass >::size_type sz)
Creates an RefCountMField with space reserved for size nodes.
Definition: RefCountMField.h:71
virtual void setValue(const vector< RefClass * > &v, int id=0)
Set the value of the field.
Definition: RefCountMField.h:136
virtual void onRemove(RefClass *n)
This function will be called when values of RefCountMField changes.
Definition: RefCountMField.h:233
virtual string getTypeName()
Returns a string name for this field type i.e. SFNode.
Definition: RefCountMField.h:191
static string classTypeName()
Returns a string name for this field type i.e. SFNode.
Definition: RefCountMField.h:196
virtual const NodeVector & getValue(int id=0)
Get the value of the MField.
Definition: RefCountMField.h:84
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.
Definition: RefCountMField.h:112
virtual void onAdd(RefClass *n)
This function will be called when values of RefCountMField changes.
Definition: RefCountMField.h:222
virtual void setValue(const AutoRefVector< RefClass > &v, int id=0)
Set the value of the field.
Definition: RefCountMField.h:125
virtual RefClass * getValueByIndex(typename BaseFieldType::size_type i, int id=0)
Get the value of the MField.
Definition: RefCountMField.h:91
virtual void update()
Make the field up to date given that an event has occured.
Definition: RefCountMField.h:204
virtual void erase(unsigned int pos, int id=0)
Erase the element at the specified index.
Definition: RefCountMField.h:169
RefCountMField()
Default constructor. Creates an empty RefCountMField.
Definition: RefCountMField.h:65
virtual void swap(vector< RefClass * > &v, int id=0)
Swaps the contents of two vectors.
Definition: RefCountMField.h:146
H3D_VALUE_EXCEPTION(string, InvalidType)
An exception thrown when a field is of the wrong type when it is checked.
H3D API namespace.
Definition: Anchor.h:38
AutoRefVector< Node > NodeVector
NodeVector is a vector of nodes that manages reference counting on the Nodes added to or removed from...
Definition: RefCountMField.h:39