MIRA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
ChannelRead< T > Class Template Reference

An object that allows read access to data of a channel. More...

#include <fw/ChannelReadWrite.h>

Inheritance diagram for ChannelRead< T >:
Inheritance graph
[legend]

Public Types

typedef boost::shared_ptr< SharedSharedPtr
 
typedef Shared::ChannelType ChannelType
 

Public Member Functions

 ChannelRead ()
 Default constructor that constructs a ChannelRead object that is invalid at the beginning and contains no data. More...
 
 ChannelRead (ChannelTypePtr channel, Slot *slot)
 Is called by Channel to construct a ChannelRead object. More...
 
 operator const ValueType & () const
 Allows to cast Reading Data from Channels and Writing to Channels easily into a const reference of the wrapped data type. More...
 
const ValueTypeoperator* () const
 Returns a const reference on the data. More...
 
const ValueTypeoperator-> () const
 Returns a const pointer on the data. More...
 
const Buffer< uint8 > & readSerializedValue ()
 
const Buffer< uint8 > & readSerializedValue (uint8 formatVersion, bool orLower)
 
Buffer< uint8 > readSerializedValue (std::list< BinarySerializerCodecPtr > &codecs)
 
Buffer< uint8 > readSerializedValue (std::list< BinarySerializerCodecPtr > &codecs, uint8 formatVersion, bool orLower)
 
void readJSON (JSONValue &oValue)
 
void readJSON (JSONValue &oValue, JSONSerializer &serializer)
 
void finish ()
 Releases the lock explicitly. More...
 
Channel< T > getChannel ()
 Returns a read-only channel proxy object of the underlying channel. More...
 
bool isValid () const
 Returns true, if data was assigned to the ChannelRead or ChannelWrite and if this data is locked. More...
 
const std::string & getChannelID ()
 
std::string getTypename () const
 
TypeMetaPtr getTypeMeta () const
 
const TimegetTimestamp () const
 
int getUseCount () const
 Returns the number of shared instances for this data, may be useful for debugging purposes. More...
 
uint32 getFlags () const
 For internal use only. More...
 
void addFlags (uint32 moreFlags) const
 For internal use only. More...
 

Protected Types

typedef ChannelReadWriteBase
< ChannelRead< T >, T > 
Base
 
typedef Base::Shared Shared
 
typedef Base::ChannelTypePtr ChannelTypePtr
 
typedef Base::Slot Slot
 
typedef Base::ValueType ValueType
 

Protected Member Functions

ValueTypeinternalValue ()
 Returns a reference on the data. More...
 
const ValueTypeinternalValue () const
 Returns a const reference on the data. More...
 
void checkValid () const
 checks if we are still locked, if not it throws a XAccessViolation More...
 
void writeSerializedValue (Buffer< uint8 > data)
 
void writeJSON (const JSONValue &value)
 
void writeJSON (JSONDeserializer &deserializer)
 

Static Protected Member Functions

static void finish (Shared *shared)
 
static void discard (Shared *shared)
 

Protected Attributes

SharedPtr shared
 

Friends

class ChannelReadWriteShared< ChannelRead< T > >
 

Detailed Description

template<typename T>
class mira::ChannelRead< T >

An object that allows read access to data of a channel.

Use Channel::read to obtain access to data of a channel.

The ChannelRead automatically take care that the data is unlocked if the ChannelRead object is no longer used and went out of scope. To explicitly release the data by calling the finish() method.

You can freely copy and reassign the ChannelRead object to other ChannelRead variables. The ChannelRead contains an internal reference counting mechanism. The lock is freed only after all copies have been destroyed or one copy called the finish() method.

Examples:
tutorials/MeanCalculator.C, tutorials/MeanCalculatorWithProperties.C, tutorials/Point2Visualization.C, tutorials/Point3BasicVisualization.C, and tutorials/Point3Visualization.C.

Member Typedef Documentation

typedef ChannelReadWriteBase<ChannelRead<T>,T> Base
protected
typedef Base::Shared Shared
protected
typedef Base::Slot Slot
protected
typedef Base::ValueType ValueType
protected
typedef boost::shared_ptr<Shared> SharedPtr
inherited
typedef Shared::ChannelType ChannelType
inherited

Constructor & Destructor Documentation

ChannelRead ( )
inline

Default constructor that constructs a ChannelRead object that is invalid at the beginning and contains no data.

Before you can use the object you need to assign a valid ChannelWrite object that was obtained using Channel::read().

You can use the isValid() method to check if a ChannelRead object is valid and contains locked data.

ChannelRead ( ChannelTypePtr  channel,
Slot slot 
)
inline

Is called by Channel to construct a ChannelRead object.

Note
You should never need to use this constructor directly!

Member Function Documentation

operator const ValueType & ( ) const
inline

Allows to cast Reading Data from Channels and Writing to Channels easily into a const reference of the wrapped data type.

Exceptions
XRuntime,ifthe lock on the data was lost, e.g. by calling the finish() method.
const ValueType& operator* ( ) const
inline

Returns a const reference on the data.

This is essentially the same as calling internalValue() but simplifies the usage similar to STL-iterators.

Exceptions
XRuntime,ifthe lock on the data was lost, e.g. by calling the finish() method.
const ValueType* operator-> ( ) const
inline

Returns a const pointer on the data.

This simplifies the usage similar to STL-iterators:

stuct MyClass {
void foo();
}
ChannelRead<MyClass> data = ...;
data->foo(); // directly calls foo() of MyClass
Exceptions
XRuntime,ifthe lock on the data was lost, e.g. by calling the finish() method
const Buffer<uint8>& readSerializedValue ( )
inline
const Buffer<uint8>& readSerializedValue ( uint8  formatVersion,
bool  orLower 
)
inline
Buffer<uint8> readSerializedValue ( std::list< BinarySerializerCodecPtr > &  codecs)
inline
Buffer<uint8> readSerializedValue ( std::list< BinarySerializerCodecPtr > &  codecs,
uint8  formatVersion,
bool  orLower 
)
inline
void readJSON ( JSONValue oValue)
inline
void readJSON ( JSONValue oValue,
JSONSerializer serializer 
)
inline
void finish ( )
inline

Releases the lock explicitly.

Note
After calling this method accessing the data results in an XRuntime exception.
Channel<T> getChannel ( )

Returns a read-only channel proxy object of the underlying channel.

static void finish ( Shared shared)
inlinestaticprotected
static void discard ( Shared shared)
inlinestaticprotected
ValueType& internalValue ( )
inlineprotectedinherited

Returns a reference on the data.

Exceptions
ThrowsXRuntime, if the lock on the data was lost, e.g. by calling the finish() method
const ValueType& internalValue ( ) const
inlineprotectedinherited

Returns a const reference on the data.

Exceptions
ThrowsXRuntime, if the lock on the data was lost, e.g. by calling the finish() method
bool isValid ( ) const
inlineinherited

Returns true, if data was assigned to the ChannelRead or ChannelWrite and if this data is locked.

If this method returns true, you can safely access the underlying data.

If this method returns false, no data was assigned to the ChannelRead / ChannelWrite or the lock on the data was lost. Hence, it is not safe to access the underlying data. If you try to access the data anyway you will get an XRuntime exception.

const std::string& getChannelID ( )
inlineinherited
std::string getTypename ( ) const
inlineinherited
TypeMetaPtr getTypeMeta ( ) const
inlineinherited
const Time& getTimestamp ( ) const
inlineinherited
int getUseCount ( ) const
inlineinherited

Returns the number of shared instances for this data, may be useful for debugging purposes.

uint32 getFlags ( ) const
inlineinherited

For internal use only.

Used by remote components of the framework and by player and recorder. Returns current flags of this slot;

void addFlags ( uint32  moreFlags) const
inlineinherited

For internal use only.

Used by remote components of the framework and by player and recorder. Add additional flags to the slots flags.

void checkValid ( ) const
inlineprotectedinherited

checks if we are still locked, if not it throws a XAccessViolation

void writeSerializedValue ( Buffer< uint8 >  data)
inlineprotectedinherited
void writeJSON ( const JSONValue value)
inlineprotectedinherited
void writeJSON ( JSONDeserializer deserializer)
inlineprotectedinherited

Friends And Related Function Documentation

friend class ChannelReadWriteShared< ChannelRead< T > >
friend

Member Data Documentation

SharedPtr shared
protectedinherited

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