Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes

nc::SimpleConsumer< T > Class Template Reference

#include <acsncSimpleConsumer.h>

Inheritance diagram for nc::SimpleConsumer< T >:
Inheritance graph
[legend]
Collaboration diagram for nc::SimpleConsumer< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef void(* eventHandlerFunction )(T eventData, void *handlerParam)

Public Member Functions

 SimpleConsumer (const char *channelName, const char *acsNCDomainName=0)
template<class J >
void addSubscription (eventHandlerFunction templateFunction, void *handlerParam=0)
virtual void push_structured_event (const CosNotification::StructuredEvent &notification)
bool stopConsumerThread ()
virtual void disconnect ()
void processEvent ()

Protected Member Functions

virtual ~SimpleConsumer ()

Protected Attributes

eventHandlerFunction templateFunction_mp
void * handlerParam_mp

Private Member Functions

void operator= (const SimpleConsumer &)
 SimpleConsumer (const SimpleConsumer &)
void addSubscription (const char *type_name, eventHandlerFunction templateFunction, void *handlerParam=0)

Static Private Member Functions

static void * dispatchEvent (void *args)

Private Attributes

blocking_queue< T > buffer
bool stop_thread
pthread_t dispatching_thread
RepeatGuard receiverTooSlowLogRepeatGuard
unsigned int numEventsDiscarded

Detailed Description

template<class T>
class nc::SimpleConsumer< T >

SimpleConsumer is used to consume data from a notification channel defined by the string passed to SimpleConsumer's constructor. In a nutshell, this class has been provided so that developers do not have to subclass Consumer and can instead use a generic function to process events.

To begin consuming data, simply invoke the consumerReady method. After that, the eventHandlerFunction will be invoked asynchronously each time an event is received.

TODO:


Member Typedef Documentation

template<class T>
typedef void(* nc::SimpleConsumer< T >::eventHandlerFunction)(T eventData, void *handlerParam)

Constructor & Destructor Documentation

template<class T>
nc::SimpleConsumer< T >::SimpleConsumer ( const char *  channelName,
const char *  acsNCDomainName = 0 
)

Constructor to be used within components.

Parameters:
channelName The channel's name
acsNCDomain name of the ACS NC domain name. This is an optional parameter. It will default to acscommon::NAMESERVICE_BINDING_NC_DOMAIN_DEFAULT if it is not specified.
template<class T>
virtual nc::SimpleConsumer< T >::~SimpleConsumer (  )  [protected, virtual]

Destructor is protected.

template<class T>
nc::SimpleConsumer< T >::SimpleConsumer ( const SimpleConsumer< T > &   )  [private]

ALMA C++ coding standards state copy constructors should be disabled.


Member Function Documentation

template<class T>
template<class J >
void nc::SimpleConsumer< T >::addSubscription ( eventHandlerFunction  templateFunction,
void *  handlerParam = 0 
) [inline]

A special version of the addSubscription method. Not only subscribes to an event_type, but it also saves a function pointer and an extra paremter to the function to be utilized when an event of type_name is received. Currently the implementation only allows this method to be invoked once (and that is done from the ACSNC_NEW_SIMPLE_CONSUMER macro). The template paramter is the type_name of the event to be received.

Parameters:
templateFunction A (static) method which will be invoked each time a type_name event is received. The method must accept a <T> structure as it's first parameter.
handlerParam A void pointer that will be passed to templateFunction (in addition to the actual ICD <T> event) each time a type_name event is received.
Exceptions:
ACSErrTypeCommon::CouldntPerformActionEx 
Returns:
void

template<class T>
void nc::SimpleConsumer< T >::addSubscription ( const char *  type_name,
eventHandlerFunction  templateFunction,
void *  handlerParam = 0 
) [private]

A special version of the addSubscription method. Not only subscribes to an event_type, but it also saves a function pointer and an extra paremter to the function to be utilized when an event of type_name is received. Currently the implementation only allows this method to be invoked once (and that is done from the ACSNC_NEW_SIMPLE_CONSUMER macro).

Parameters:
type_name Type of the event to be received
templateFunction A (static) method which will be invoked each time a type_name event is received. The method must accept a <T> structure as it's first parameter.
handlerParam A void pointer that will be passed to templateFunction (in addition to the actual ICD <T> event) each time a type_name event is received.
Returns:
void

template<class T>
virtual void nc::SimpleConsumer< T >::disconnect (  )  [virtual]

Disconnect from the channel. Call this instead of deleting the object. Once disconnect has been invoked, developers should treat the object as if it has been deleted.

Returns:
void

Reimplemented from nc::Consumer.

template<class T>
static void* nc::SimpleConsumer< T >::dispatchEvent ( void *  args  )  [static, private]

Entry point for the buffer's consumer thread

template<class T>
void nc::SimpleConsumer< T >::operator= ( const SimpleConsumer< T > &   )  [private]

ALMA C++ coding standards state assignment operators should be disabled.

template<class T>
void nc::SimpleConsumer< T >::processEvent (  ) 

It just invokes some function registered via the addSubscription method

template<class T>
virtual void nc::SimpleConsumer< T >::push_structured_event ( const CosNotification::StructuredEvent &  notification  )  [virtual]

This is the abstract method inherited Consumer which must be overridden. In the SimpleConsumer class, it just invokes some function registered via the addSubscription method. In doing this, one does not have to override SimpleConsumer. Note that this method must not be invoked by your code!

Exceptions:
CosEventComm::Disconnected 
Returns:
void

Implements nc::Consumer.

template<class T>
bool nc::SimpleConsumer< T >::stopConsumerThread (  ) 

Member Data Documentation

template<class T>
blocking_queue<T> nc::SimpleConsumer< T >::buffer [private]
template<class T>
pthread_t nc::SimpleConsumer< T >::dispatching_thread [private]
template<class T>
void* nc::SimpleConsumer< T >::handlerParam_mp [protected]

This is a single parameter that will be passed to the handler function in addition to the ICD <T> event.

template<class T>
unsigned int nc::SimpleConsumer< T >::numEventsDiscarded [private]
template<class T>
bool nc::SimpleConsumer< T >::stop_thread [private]
template<class T>
eventHandlerFunction nc::SimpleConsumer< T >::templateFunction_mp [protected]

This function does something with T events.


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