Urbi SDK Remote for C++  2.7.5
urbi::CustomUVar< T > Class Template Reference

UVar wrapper with a custom data field. More...

#include <customuvar.hh>

Inheritance diagram for urbi::CustomUVar< T >:
Collaboration diagram for urbi::CustomUVar< T >:

List of all members.

Public Member Functions

 CustomUVar ()
 CustomUVar (const std::string &, impl::UContextImpl *=0)
 CustomUVar (const std::string &, const std::string &, impl::UContextImpl *=0)
 CustomUVar (UObject &, const std::string &, impl::UContextImpl *=0)
T & data ()
template<typename D >
void operator= (D v)
template<typename U >
void operator= (U v)

Static Public Member Functions

static T & data (UVar &)
static void updateCache (UVar &v)

Private Attributes

data_

Detailed Description

template<typename T>
class urbi::CustomUVar< T >

UVar wrapper with a custom data field.

Since the UVar reference passed as argument to the notifyChange callback is the same as the one given to UNotifyChange, one can inherit from UVar to transmit custom data to the callbacks. This class is designed to ease this process.

Example usage:

 CustomUVar<int> v = new UVar(*this, "motor" + string_cast(mID));
 v->data() = mID;
 UNotifyChange(*v, &Motor::onChange);

 void Motor::onChange(UVar& var)
 {
    int id = CustomUVar<int>::data(var);
    writeMotor(id, (double)var);
 }

Definition at line 42 of file customuvar.hh.


Constructor & Destructor Documentation

template<typename T >
urbi::CustomUVar< T >::CustomUVar ( )

Definition at line 17 of file customuvar.hxx.

template<typename T >
urbi::CustomUVar< T >::CustomUVar ( const std::string &  name,
impl::UContextImpl impl = 0 
)

Definition at line 22 of file customuvar.hxx.

template<typename T >
urbi::CustomUVar< T >::CustomUVar ( const std::string &  a,
const std::string &  b,
impl::UContextImpl c = 0 
)

Definition at line 27 of file customuvar.hxx.

template<typename T >
urbi::CustomUVar< T >::CustomUVar ( UObject a,
const std::string &  b,
impl::UContextImpl c = 0 
)

Definition at line 33 of file customuvar.hxx.


Member Function Documentation

template<typename T >
T & urbi::CustomUVar< T >::data ( )

Definition at line 39 of file customuvar.hxx.

template<typename T >
T & urbi::CustomUVar< T >::data ( UVar v) [static]
Returns:
a reference to the data structure from an UVar. The UVar must be a CustomUVar<T>, or the behavior will be undefined.

Definition at line 45 of file customuvar.hxx.

template<typename T>
template<typename D >
void urbi::CustomUVar< T >::operator= ( v)
template<typename T>
template<typename U >
void urbi::CustomUVar< T >::operator= ( v)

Definition at line 58 of file customuvar.hxx.

References urbi::UVar::operator=().

template<typename T >
void urbi::CustomUVar< T >::updateCache ( UVar v) [static]

Definition at line 51 of file customuvar.hxx.

References urbi::UVar::fill().


Member Data Documentation

template<typename T>
T urbi::CustomUVar< T >::data_ [private]

Definition at line 58 of file customuvar.hh.


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