MIRA
Public Types | Public Member Functions | Protected Attributes | List of all members
AbstractChannel Class Reference

#include <fw/AbstractChannel.h>

Inheritance diagram for AbstractChannel:
Inheritance graph
[legend]

Public Types

typedef ChannelBufferBase::Slot Slot
 

Public Member Functions

 AbstractChannel (const std::string &id, ChannelBufferBase *buffer)
 Constructs a new channel with the given id and the specified underlying channel buffer. More...
 
 ~AbstractChannel ()
 Destructor (KEEP NON VIRTUAL!) More...
 
const std::string & getID () const
 Returns the channel id of this channel. More...
 
int getTypeId () const
 Returns the non-portable typeid of the items that are stored in the slots of the underlying channel buffer. More...
 
Typename getTypename () const
 Returns the platform independent typename of the items that are stored in the slots of the underlying channel buffer. More...
 
void setTypename (const Typename &name)
 Sets the typename of the items that are stored in the slots of the underlying channel buffer. More...
 
TypeMetaPtr getTypeMeta () const
 Returns the type meta information for the slots of the underlying channel buffer. More...
 
void setTypeMeta (TypeMetaPtr meta)
 Sets the type meta information for the slots of the underlying channel buffer. More...
 
void fixateType ()
 Calling this method will fix the type of the underlying ChannelBuffer. More...
 
bool isTyped () const
 Returns true, if the channel is typed and false, if it is untyped. More...
 
ChannelBufferBasegetBuffer ()
 Returns the underlying channel buffer. More...
 
std::size_t getNrOfSlots () const
 Returns the number of slots this channel contains. More...
 
Time getLastSlotTime () const
 Returns the timestamp of the data in the slot that was last written to this channel or an invalid time when there was no data written at all. More...
 
uint64 getNrOfDataChanges () const
 Returns the number of times data was written to this channel. More...
 
bool hasSubscriber () const
 Returns true, if this channel has at least one subscriber. More...
 
bool hasPublisher () const
 Returns true, if this channel has at least one publisher. More...
 
void removeSubscriber ()
 Removes a subscriber that has not subscribed using a channel subscriber, (i.e. More...
 
void removeSubscriber (AbstractChannelSubscriberPtr subscriber)
 Removes the specified subscriber from this channel and calls its detach() method. More...
 
void finishWrite (Slot *s)
 Is called by ChannelWrite to signal that data was changed. More...
 
void discardWrite (Slot *s)
 Is called by ChannelWrite to signal that this slot is discarded. More...
 
template<typename TargetType >
void promote ()
 Promote the channel to TargetType. More...
 
void dbgDump (bool brief=true)
 Output the current buffer to console for debugging. More...
 

Protected Attributes

std::string mID
 
ChannelBufferBasemBuffer
 
ChannelBufferBasemUntypedBuffer
 
boost::mutex mPromoteMutex
 
boost::mutex mSubscribersMutex
 
std::list< AbstractChannelSubscriberPtrmSubscribers
 
uint32 mNrOfSubscribersWithoutChannelSubscriber
 
Time mLastSlotTime
 
uint64 mNrOfDataChanges
 

Detailed Description

Abstract base class for all typed Channel. It allows to store different typed channels within one container.

Member Typedef Documentation

◆ Slot

Constructor & Destructor Documentation

◆ AbstractChannel()

AbstractChannel ( const std::string &  id,
ChannelBufferBase buffer 
)

Constructs a new channel with the given id and the specified underlying channel buffer.

◆ ~AbstractChannel()

Destructor (KEEP NON VIRTUAL!)

Member Function Documentation

◆ getID()

const std::string& getID ( ) const
inline

Returns the channel id of this channel.

◆ getTypeId()

int getTypeId ( ) const
inline

Returns the non-portable typeid of the items that are stored in the slots of the underlying channel buffer.

If the buffer is untyped this method will return -1.

Returns
tpye id

◆ getTypename()

Typename getTypename ( ) const
inline

Returns the platform independent typename of the items that are stored in the slots of the underlying channel buffer.

If the channel is untyped the typename that was set using setTypename() is returned.

Returns
type name

◆ setTypename()

void setTypename ( const Typename name)
inline

Sets the typename of the items that are stored in the slots of the underlying channel buffer.

Calling this method is allowed for untyped channels only. Calling it for typed channels will result in a XRuntime exception.

Exceptions
XRuntimeIf the channel already is a typed channel.
Parameters
[in]nameThe new type name

◆ getTypeMeta()

TypeMetaPtr getTypeMeta ( ) const
inline

Returns the type meta information for the slots of the underlying channel buffer.

◆ setTypeMeta()

void setTypeMeta ( TypeMetaPtr  meta)
inline

Sets the type meta information for the slots of the underlying channel buffer.

◆ fixateType()

void fixateType ( )
inline

Calling this method will fix the type of the underlying ChannelBuffer.

This method currently is used by the polymorphic buffer only. It will set the type of the buffer and hence the channel to the type that the buffer currently has, hence it fixates the type of the buffer and the buffer can not be promoted to any other type of a derived class.

◆ isTyped()

bool isTyped ( ) const
inline

Returns true, if the channel is typed and false, if it is untyped.

◆ getBuffer()

ChannelBufferBase* getBuffer ( )
inline

Returns the underlying channel buffer.

Note that the buffer may change if the channel is promoted.

◆ getNrOfSlots()

std::size_t getNrOfSlots ( ) const
inline

Returns the number of slots this channel contains.

◆ getLastSlotTime()

Time getLastSlotTime ( ) const
inline

Returns the timestamp of the data in the slot that was last written to this channel or an invalid time when there was no data written at all.

◆ getNrOfDataChanges()

uint64 getNrOfDataChanges ( ) const
inline

Returns the number of times data was written to this channel.

◆ hasSubscriber()

bool hasSubscriber ( ) const
inline

Returns true, if this channel has at least one subscriber.

◆ hasPublisher()

bool hasPublisher ( ) const

Returns true, if this channel has at least one publisher.

◆ removeSubscriber() [1/2]

void removeSubscriber ( )

Removes a subscriber that has not subscribed using a channel subscriber, (i.e.

without a callback)

◆ removeSubscriber() [2/2]

void removeSubscriber ( AbstractChannelSubscriberPtr  subscriber)

Removes the specified subscriber from this channel and calls its detach() method.

Note
addSubscriber is implemented in ConcreteChannel since type information is needed there.

◆ finishWrite()

void finishWrite ( Slot s)

Is called by ChannelWrite to signal that data was changed.

Parameters
[in]sSlot to be written into internal queue.

◆ discardWrite()

void discardWrite ( Slot s)

Is called by ChannelWrite to signal that this slot is discarded.

Parameters
sSlot to be discarded

◆ promote()

void promote ( )
inline

Promote the channel to TargetType.

◆ dbgDump()

void dbgDump ( bool  brief = true)
inline

Output the current buffer to console for debugging.

Member Data Documentation

◆ mID

std::string mID
protected

◆ mBuffer

ChannelBufferBase* mBuffer
protected

◆ mUntypedBuffer

ChannelBufferBase* mUntypedBuffer
protected

◆ mPromoteMutex

boost::mutex mPromoteMutex
protected

◆ mSubscribersMutex

boost::mutex mSubscribersMutex
protected

◆ mSubscribers

std::list<AbstractChannelSubscriberPtr > mSubscribers
protected

◆ mNrOfSubscribersWithoutChannelSubscriber

uint32 mNrOfSubscribersWithoutChannelSubscriber
protected

◆ mLastSlotTime

Time mLastSlotTime
protected

◆ mNrOfDataChanges

uint64 mNrOfDataChanges
protected

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