MDSTk Libraries  1.1.0
Medical Data Segmentation Toolkit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
mds::mod::CSignal< R, P1, P2, P3, P4 > Class Template Reference

Class provides simple communication and data transfer mechanism between different classes. More...

#include <mdsSignal.h>

Inheritance diagram for mds::mod::CSignal< R, P1, P2, P3, P4 >:
Inheritance graph
[legend]

List of all members.

Classes

struct  SHandlerInfo
 Helper structure containing info about signal handler. More...

Public Types

enum  { NUM_OF_PARAMS = tHandler::NUM_OF_PARAMS }
 Number of handler parameters. More...
enum  { CLASS_OBJECT }
 Templates that require members of the CObject class can use this enum to check the existence. More...
enum  { HEAP_OBJECT = 0x70616568 }
 Signature used to recognize objects on the heap. More...
typedef mds::base::CFunctor< R,
P1, P2, P3, P4 > 
tHandler
 Handler type.
typedef
mds::base::CLibraryLockableObject
< CSignal >::CLock 
tLock
 Lock that may be used to provide mutual access.
typedef tHandler::tParam1 tParam1
typedef tHandler::tParam2 tParam2
typedef tHandler::tParam3 tParam3
typedef tHandler::tParam4 tParam4
typedef tHandler::tResult tResult
 Handler parameters.

Public Member Functions

void block (tSignalConnection &sc)
 Blocks a given signal handler.
void blockAllButThis (tSignalConnection &sc)
 Blocks all others signal handlers.
template<typename F >
tSignalConnection connect (F Func)
template<class O , typename F >
tSignalConnection connect (const O &pObject, F pMemFunc)
tSignalConnection connect (const tHandler &handler)
 Registers a new signal handler.
template<typename F >
tSignalConnection connect (F Func)
 Registers a new signal handler.
template<class O , typename F >
tSignalConnection connect (const O &pObject, F pMemFunc)
 Constructor creates functor encapsulating pointer to member function.
 CSignal ()
 Default constructor.
void disconnect (tSignalConnection &sc)
 Unregisters an existing signal handler.
void disconnectAll ()
 Unregisters all existing signal handlers.
int getNumOfConnections ()
 Returns the number of registered handlers.
int getReferencesCount () const
 Returns the number of references.
void invoke ()
 Invokes the signal.
void invoke (tParam1 p1)
void invoke (tParam1 p1, tParam2 p2)
void invoke (tParam1 p1, tParam2 p2, tParam3 p3)
void invoke (tParam1 p1, tParam2 p2, tParam3 p3, tParam4 p4)
tResult invoke2 ()
 Invokes the signal and returns value obtained by combining all values returned by individual handlers.
tResult invoke2 (tParam1 p1)
tResult invoke2 (tParam1 p1, tParam2 p2)
tResult invoke2 (tParam1 p1, tParam2 p2, tParam3 p3)
tResult invoke2 (tParam1 p1, tParam2 p2, tParam3 p3, tParam4 p4)
bool isBlocked (tSignalConnection &sc)
 Returns true if a given signal is blocked.
bool isOnHeap () const
 Returns true if the object is allocated on the heap.
void lock ()
 Locks the object.
 MDS_SHAREDPTR (CSignal)
 Smart pointer type.
void unblock (tSignalConnection &sc)
 Unblocks a given signal handler.
void unblockAll ()
 Unblocks all signal handlers.
void unlock ()
 Locks the object.
 ~CSignal ()
 Destructor of the class.

Static Public Member Functions

static void * operator new (std::size_t Size)
 Allocates a new object on the heap.

Protected Types

typedef
CSignalConnection::tConnectionId 
tConnectionId
 Connection identifier.
typedef std::map
< tConnectionId, SHandlerInfo
tHandlers
 Map of registered signal handlers.

Protected Member Functions

void addReference () const
 Increase the reference counter.
bool delReference () const
 Decrease the reference counter.
tConnectionId getUniqueId ()
 Creates a new unique connection number.

Protected Attributes

tHandlers m_Handlers
 All registered signal handlers.
int m_iHeapObject
 Flag initialized if the object is on the heap.
int m_iReferences
 The number of references to the object.
tConnectionId m_NextId
 Next free connection identifier.

Detailed Description

template<typename R, typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
class mds::mod::CSignal< R, P1, P2, P3, P4 >

Class provides simple communication and data transfer mechanism between different classes.

It encapsulates a group of registered handlers, which are invoked when the signal is sent.


Member Typedef Documentation

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef CSignalConnection::tConnectionId mds::mod::CSignal< R, P1, P2, P3, P4 >::tConnectionId [protected]

Connection identifier.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef mds::base::CFunctor<R, P1, P2, P3, P4> mds::mod::CSignal< R, P1, P2, P3, P4 >::tHandler

Handler type.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef std::map<tConnectionId, SHandlerInfo> mds::mod::CSignal< R, P1, P2, P3, P4 >::tHandlers [protected]

Map of registered signal handlers.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef mds::base::CLibraryLockableObject<CSignal>::CLock mds::mod::CSignal< R, P1, P2, P3, P4 >::tLock

Lock that may be used to provide mutual access.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef tHandler::tParam1 mds::mod::CSignal< R, P1, P2, P3, P4 >::tParam1
template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef tHandler::tParam2 mds::mod::CSignal< R, P1, P2, P3, P4 >::tParam2
template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef tHandler::tParam3 mds::mod::CSignal< R, P1, P2, P3, P4 >::tParam3
template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef tHandler::tParam4 mds::mod::CSignal< R, P1, P2, P3, P4 >::tParam4
template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
typedef tHandler::tResult mds::mod::CSignal< R, P1, P2, P3, P4 >::tResult

Handler parameters.


Member Enumeration Documentation

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
anonymous enum

Number of handler parameters.

Enumerator:
NUM_OF_PARAMS 
anonymous enum [inherited]

Templates that require members of the CObject class can use this enum to check the existence.

Enumerator:
CLASS_OBJECT 
anonymous enum [inherited]

Signature used to recognize objects on the heap.

Enumerator:
HEAP_OBJECT 

Constructor & Destructor Documentation

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
mds::mod::CSignal< R, P1, P2, P3, P4 >::CSignal ( )

Default constructor.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
mds::mod::CSignal< R, P1, P2, P3, P4 >::~CSignal ( )

Destructor of the class.


Member Function Documentation

void mds::base::CObject::addReference ( ) const [protected, inherited]

Increase the reference counter.

template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::block ( tSignalConnection sc)

Blocks a given signal handler.

template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::blockAllButThis ( tSignalConnection sc)

Blocks all others signal handlers.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
template<typename F >
tSignalConnection mds::mod::CSignal< R, P1, P2, P3, P4 >::connect ( Func)
template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
template<class O , typename F >
tSignalConnection mds::mod::CSignal< R, P1, P2, P3, P4 >::connect ( const O &  pObject,
pMemFunc 
)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
tSignalConnection CSignal::connect ( const tHandler handler)

Registers a new signal handler.

  • Returns unique connection identifier.
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
template<typename F >
tSignalConnection mds::mod::CSignal< R, P1, P2, P3, P4 >::connect ( Func)

Registers a new signal handler.

  • Returns unique connection identifier.
  • Parameter F is a function type.
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
template<class O , typename F >
tSignalConnection mds::mod::CSignal< R, P1, P2, P3, P4 >::connect ( const O &  pObject,
pMemFunc 
)

Constructor creates functor encapsulating pointer to member function.

  • Parameter O is pointer to an object.
  • M is pointer to the object member function.
bool mds::base::CObject::delReference ( ) const [protected, inherited]

Decrease the reference counter.

  • Returns true if the decremented number of references is lower or equal to zero and object must be deleted.
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::disconnect ( tSignalConnection sc)

Unregisters an existing signal handler.

template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::disconnectAll ( )

Unregisters all existing signal handlers.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
int mds::mod::CSignal< R, P1, P2, P3, P4 >::getNumOfConnections ( )

Returns the number of registered handlers.

Returns the number of references.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
tConnectionId mds::mod::CSignal< R, P1, P2, P3, P4 >::getUniqueId ( ) [protected]

Creates a new unique connection number.

template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::invoke ( )

Invokes the signal.

  • Use method with appropriate number of parameters!
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::invoke ( tParam1  p1)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::invoke ( tParam1  p1,
tParam2  p2 
)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::invoke ( tParam1  p1,
tParam2  p2,
tParam3  p3 
)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::invoke ( tParam1  p1,
tParam2  p2,
tParam3  p3,
tParam4  p4 
)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
CSignal< R, P1, P2, P3, P4 >::tResult CSignal::invoke2 ( )

Invokes the signal and returns value obtained by combining all values returned by individual handlers.

  • Use method with appropriate number of parameters!
  • Allowed only for non-void return types!
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
CSignal< R, P1, P2, P3, P4 >::tResult CSignal::invoke2 ( tParam1  p1)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
CSignal< R, P1, P2, P3, P4 >::tResult CSignal::invoke2 ( tParam1  p1,
tParam2  p2 
)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
CSignal< R, P1, P2, P3, P4 >::tResult CSignal::invoke2 ( tParam1  p1,
tParam2  p2,
tParam3  p3 
)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
CSignal< R, P1, P2, P3, P4 >::tResult CSignal::invoke2 ( tParam1  p1,
tParam2  p2,
tParam3  p3,
tParam4  p4 
)
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
bool CSignal::isBlocked ( tSignalConnection sc)

Returns true if a given signal is blocked.

bool mds::base::CObject::isOnHeap ( ) const [inherited]

Returns true if the object is allocated on the heap.

void mds::base::CLockableObject< CSignal< R, P1, P2, P3, P4 > >::lock ( ) [inherited]

Locks the object.

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
mds::mod::CSignal< R, P1, P2, P3, P4 >::MDS_SHAREDPTR ( CSignal< R, P1, P2, P3, P4 >  )

Smart pointer type.

  • Declares type tSmartPtr.
static void* mds::base::CObject::operator new ( std::size_t  Size) [static, inherited]

Allocates a new object on the heap.

template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::unblock ( tSignalConnection sc)

Unblocks a given signal handler.

template<typename R , typename P1 , typename P2 , typename P3 , typename P4 >
void CSignal::unblockAll ( )

Unblocks all signal handlers.

void mds::base::CLockableObject< CSignal< R, P1, P2, P3, P4 > >::unlock ( ) [inherited]

Locks the object.


Member Data Documentation

template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
tHandlers mds::mod::CSignal< R, P1, P2, P3, P4 >::m_Handlers [protected]

All registered signal handlers.

int mds::base::CObject::m_iHeapObject [mutable, protected, inherited]

Flag initialized if the object is on the heap.

int mds::base::CObject::m_iReferences [mutable, protected, inherited]

The number of references to the object.

  • Zero if there is no reference.
template<typename R , typename P1 = tNull, typename P2 = tNull, typename P3 = tNull, typename P4 = tNull>
tConnectionId mds::mod::CSignal< R, P1, P2, P3, P4 >::m_NextId [protected]

Next free connection identifier.


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