H3D API
2.4.1
|
<> More...
#include <H3D/ThreadSafeFields.h>
Public Member Functions | |
ThreadSafeMField () | |
Constructor. | |
virtual void | setValue (const vector< typename BaseField::value_type > &v, int id=0) |
Set the value of the field. More... | |
virtual void | setValue (typename BaseField::size_type i, const typename BaseField::value_type &t, int id=0) |
Change the value of one element in the MField. More... | |
virtual void | swap (typename BaseField::vector_type &x, int id=0) |
Swaps the contents of two vectors. | |
virtual void | push_back (const typename BaseField::value_type &x, int id=0) |
Inserts a new element at the end. | |
void | pop_back (int id=0) |
Removed the last element. | |
virtual void | clear (int id=0) |
Erases all of the elements. | |
virtual BaseField::const_iterator | begin (int id=0) |
Returns a const_iterator pointing to the beginning of the vector. | |
virtual BaseField::const_iterator | end (int id=0) |
Returns a const_iterator pointing to the end of the vector. | |
virtual BaseField::const_reverse_iterator | rbegin (int id=0) |
Returns a const_reverse_iterator pointing to the beginning of the reversed vector. More... | |
virtual BaseField::const_reverse_iterator | rend (int id=0) |
Returns a const_reverse_iterator pointing to the end of the reversed vector. More... | |
virtual unsigned int | size () |
Returns the size of the vector. | |
virtual BaseField::size_type | max_size () |
Returns the largest possible size of the vector. | |
virtual BaseField::size_type | capacity () |
Number of elements for which memory has been allocated. More... | |
virtual bool | empty () |
true if the vector's size is 0. | |
virtual BaseField::const_reference | operator[] (typename BaseField::size_type n) |
Returns the n'th element. | |
virtual BaseField::const_reference | front (int id=0) |
Returns the first element. | |
virtual BaseField::const_reference | back (int id=0) |
Returns the last element. | |
virtual const BaseField::vector_type & | getValue (int id=0) |
Gets the value of the field. | |
virtual void | upToDate () |
Make sure that the field is up-to-date. More... | |
![]() | |
PeriodicUpdate (H3DFloat _period=0, PeriodType _period_type=COUNT) | |
Constructor. | |
~PeriodicUpdate () | |
Destructor. | |
virtual bool | timeToUpdate () |
Determines if it is time to check that the field is updated. More... | |
void | setPeriodType (PeriodType type) |
Set the type of the period. | |
void | setPeriod (H3DFloat _period) |
Set the period for the update. | |
![]() | |
virtual | ~PeriodicUpdateField () |
Destructor. | |
Protected Member Functions | |
virtual void | update () |
The update function is specialized to synchronize with the haptics threads and copy the new value of the field to the rt_value member in a thread safe way. | |
Static Protected Member Functions | |
static H3DUtil::PeriodicThread::CallbackCode | transferValue (void *_data) |
Callback function to transfer copy a value between two pointers of the same type. | |
Protected Attributes | |
BaseField::vector_type | rt_value |
The copy of the field value to be used in the haptics threads. | |
bool | rt_value_changed |
Flag indicating if the rt_value has been changed by a haptics thread. | |
![]() | |
PeriodType | period_type |
The tye of the period. | |
H3DFloat | period |
The period of automatic updates/. | |
TimeStamp | last_up_to_date |
The time of the last call to upToDate. | |
unsigned int | counter |
The number of calls to timeToUpdate() since the last update. | |
Additional Inherited Members | |
![]() | |
enum | PeriodType |
Type defining how the period should be interpreted. | |
<>
A template modifier to add thread safety to an MField type. The field network should never be accessed from anything else than the main thread. Often though values provided by fields control behaviour of things happening in the haptic threads. Therefore separate copies of the field values have to be maintained for usage in the haptics thread. This field template modifies a normal MField class to contain such a copy. The getValue() and setValue() functions can then be used by both the haptics thread and the main thread and depending on from which thread it is called the copy or the field value is returned. Once per scene-graph loop it is checked whether either the copy or the field network value has changed since last loop and if it has the values are updated in a thread safe manner to contain the same value.
|
inlinevirtual |
Number of elements for which memory has been allocated.
capacity() is always greater than or equal to size().
References H3DUtil::HapticThreadBase::inHapticThread(), H3DUtil::ThreadBase::inMainThread(), and H3D::ThreadSafeMField< BaseField >::rt_value.
|
inlinevirtual |
Returns a const_reverse_iterator pointing to the beginning of the reversed vector.
id | Id of the node calling this function. Used to check access type. |
References H3DUtil::HapticThreadBase::inHapticThread(), H3DUtil::ThreadBase::inMainThread(), and H3D::ThreadSafeMField< BaseField >::rt_value.
|
inlinevirtual |
Returns a const_reverse_iterator pointing to the end of the reversed vector.
id | Id of the node calling this function. Used to check access type. |
References H3DUtil::HapticThreadBase::inHapticThread(), H3DUtil::ThreadBase::inMainThread(), and H3D::ThreadSafeMField< BaseField >::rt_value.
|
inlinevirtual |
Set the value of the field.
v | The new value. |
id | Id of the node calling this function. Used to check access type. |
References H3DUtil::HapticThreadBase::inHapticThread(), H3DUtil::ThreadBase::inMainThread(), H3D::ThreadSafeMField< BaseField >::rt_value, H3D::ThreadSafeMField< BaseField >::rt_value_changed, H3DUtil::HapticThreadBase::synchronousHapticCB(), and H3D::ThreadSafeMField< BaseField >::transferValue().
|
inlinevirtual |
Change the value of one element in the MField.
i | The index of the value to set. |
t | The new value. |
id | Id of the node calling this function. Used to check access type. |
References H3DUtil::HapticThreadBase::inHapticThread(), H3DUtil::ThreadBase::inMainThread(), H3D::ThreadSafeMField< BaseField >::rt_value, H3D::ThreadSafeMField< BaseField >::rt_value_changed, H3DUtil::HapticThreadBase::synchronousHapticCB(), and H3D::ThreadSafeMField< BaseField >::transferValue().
|
inlinevirtual |
Make sure that the field is up-to-date.
upToDate() is specialized to transfer the rt_value to the field if it has been changed.
Reimplemented from H3D::PeriodicUpdate< BaseField >.
References H3DUtil::ThreadBase::inMainThread(), H3D::ThreadSafeMField< BaseField >::rt_value, H3D::ThreadSafeMField< BaseField >::rt_value_changed, H3DUtil::HapticThreadBase::synchronousHapticCB(), H3D::ThreadSafeMField< BaseField >::transferValue(), and H3D::PeriodicUpdate< BaseFieldType >::upToDate().