Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SharedObject< MC > Class Template Reference

This templated class allows convenient creation of any type of class wrapped in a shared memory region. More...

#include <SharedObject.h>

Inheritance diagram for SharedObject< MC >:

Detailed Description

template<class MC>
class SharedObject< MC >

This templated class allows convenient creation of any type of class wrapped in a shared memory region.

See also:
MotionManager for an example on how to use this.

Definition at line 60 of file SharedObject.h.

List of all members.

Public Member Functions

 SharedObject (const SharedObjectBase::NoInit &)
 a no-op constructor, so you can transfer a SharedObject created elsewhere with operator=() later
 SharedObject (const SharedObject &sh)
 copy constructor adds a reference to the underlying RCRegion, allowing the SharedObject instances to "share" the region
 SharedObject (RCRegion *r)
 Constructs from a pre-existing region, laying claim to the caller's reference to the region - region's creator is responsible for initialization.
virtual ~SharedObject ()
 destructor, removes reference to shared region
MC * operator-> () const
 smart pointer to the underlying class
MC & operator* () const
 smart pointer to the underlying class
MC & operator[] (int i) const
 smart pointer to the underlying class
templated contructors - allows you to pass constructor arguments on to the object being created

if you really need more than 5 arguments for your class, well, you're one crazy puppy but if you really want to, just make more like shown... (yay templates!)

 SharedObject ()
 Creates the class with the default constructor.
template<class T1 >
 SharedObject (const T1 &t1)
 Creates the class, passing its constructor t1.
template<class T1 , class T2 >
 SharedObject (const T1 &t1, const T2 &t2)
 Creates the class, passing its constructor t1 and t2.
template<class T1 , class T2 , class T3 >
 SharedObject (const T1 &t1, const T2 &t2, const T3 &t3)
 Creates the class, passing its constructor t1, t2, and t3.
template<class T1 , class T2 , class T3 , class T4 >
 SharedObject (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
 Creates the class, passing its constructor t1, t2, t3 and t4.
template<class T1 , class T2 , class T3 , class T4 , class T5 >
 SharedObject (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5)
 Creates the class, passing its constructor t1, t2, t3, t4 and t5 - if you need more arguments, just add them.

Protected Member Functions

MC * dataCasted () const
 returns a correctly typed pointer to the object's memory
virtual void removeRef ()
 removes a reference from rcr, and if necessary, destructs its data

Static Protected Member Functions

static RCRegioncreateRCRegion ()
 creates and returns RCRegion of correct size for current class. Adds a reference (which is removed in the destructor)
static unsigned int calcsize ()
 Calculates the size of the memory region to be used, (on Aperios, rounding up to the nearest page size).

Constructor & Destructor Documentation

template<class MC>
SharedObject< MC >::SharedObject (  ) 

Creates the class with the default constructor.

Definition at line 67 of file SharedObject.h.

template<class MC>
template<class T1 >
SharedObject< MC >::SharedObject ( const T1 &  t1  )  [explicit]

Creates the class, passing its constructor t1.

Definition at line 72 of file SharedObject.h.

template<class MC>
template<class T1 , class T2 >
SharedObject< MC >::SharedObject ( const T1 &  t1,
const T2 &  t2 
)

Creates the class, passing its constructor t1 and t2.

Definition at line 77 of file SharedObject.h.

template<class MC>
template<class T1 , class T2 , class T3 >
SharedObject< MC >::SharedObject ( const T1 &  t1,
const T2 &  t2,
const T3 &  t3 
)

Creates the class, passing its constructor t1, t2, and t3.

Definition at line 82 of file SharedObject.h.

template<class MC>
template<class T1 , class T2 , class T3 , class T4 >
SharedObject< MC >::SharedObject ( const T1 &  t1,
const T2 &  t2,
const T3 &  t3,
const T4 &  t4 
)

Creates the class, passing its constructor t1, t2, t3 and t4.

Definition at line 87 of file SharedObject.h.

template<class MC>
template<class T1 , class T2 , class T3 , class T4 , class T5 >
SharedObject< MC >::SharedObject ( const T1 &  t1,
const T2 &  t2,
const T3 &  t3,
const T4 &  t4,
const T5 &  t5 
)

Creates the class, passing its constructor t1, t2, t3, t4 and t5 - if you need more arguments, just add them.

Definition at line 92 of file SharedObject.h.

template<class MC>
SharedObject< MC >::SharedObject ( const SharedObjectBase::NoInit  ) 

a no-op constructor, so you can transfer a SharedObject created elsewhere with operator=() later

Definition at line 99 of file SharedObject.h.

template<class MC>
SharedObject< MC >::SharedObject ( const SharedObject< MC > &  sh  ) 

copy constructor adds a reference to the underlying RCRegion, allowing the SharedObject instances to "share" the region

Definition at line 102 of file SharedObject.h.

template<class MC>
SharedObject< MC >::SharedObject ( RCRegion r  )  [explicit]

Constructs from a pre-existing region, laying claim to the caller's reference to the region - region's creator is responsible for initialization.

In other words, this SharedObject doesn't addReference, but will removeReference when the time is right (upon destruction). If you want to maintain an reference of your own to the region, you will need to call addReference yourself.

In comparison, the copy constructor will add a reference to the underlying RCRegion and "share" the RCRegion with the original SharedObject

Definition at line 113 of file SharedObject.h.

template<class MC>
virtual SharedObject< MC >::~SharedObject (  )  [virtual]

destructor, removes reference to shared region

Definition at line 126 of file SharedObject.h.


Member Function Documentation

template<class MC>
static unsigned int SharedObject< MC >::calcsize (  )  [static, protected]

Calculates the size of the memory region to be used, (on Aperios, rounding up to the nearest page size).

Not sure this is completely necessary, but may be nice. Of course, this also means even small regions are going to be at least 4K (current page size) If memory gets tight or we get a lot of little regions floating around, this might be worth checking into

PLATFORM_APERIOS

Definition at line 174 of file SharedObject.h.

Referenced by SharedObject< UPennWalkMC >::createRCRegion().

template<class MC>
static RCRegion* SharedObject< MC >::createRCRegion (  )  [static, protected]

creates and returns RCRegion of correct size for current class. Adds a reference (which is removed in the destructor)

Definition at line 150 of file SharedObject.h.

Referenced by SharedObject< UPennWalkMC >::SharedObject().

template<class MC>
MC* SharedObject< MC >::dataCasted (  )  const [protected]
template<class MC>
MC& SharedObject< MC >::operator* (  )  const

smart pointer to the underlying class

Definition at line 129 of file SharedObject.h.

template<class MC>
MC* SharedObject< MC >::operator-> (  )  const

smart pointer to the underlying class

Definition at line 128 of file SharedObject.h.

template<class MC>
MC& SharedObject< MC >::operator[] ( int  i  )  const

smart pointer to the underlying class

Definition at line 130 of file SharedObject.h.

template<class MC>
virtual void SharedObject< MC >::removeRef (  )  [protected, virtual]

removes a reference from rcr, and if necessary, destructs its data

Implements SharedObjectBase.

Definition at line 136 of file SharedObject.h.

Referenced by SharedObject< UPennWalkMC >::~SharedObject().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:16 2016 by Doxygen 1.6.3