Go to the documentation of this file.00001 #ifndef SIMPLE_CONSUMER_H
00002 #define SIMPLE_CONSUMER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00030 #include "acsncConsumer.h"
00031 #include <acsutilAnyAide.h>
00032 #include "acsncErrType.h"
00033 namespace nc {
00034
00050 template <class T> class SimpleConsumer : public Consumer
00051 {
00052 public:
00061 typedef void (*eventHandlerFunction)(T eventData, void *handlerParam);
00063
00067 SimpleConsumer(const char* channelName);
00069
00088 template <class J> void
00089 addSubscription(eventHandlerFunction templateFunction, void *handlerParam=0)
00090 {
00091 ACS_TRACE("SimpleConsumer::addSubscription");
00092
00093
00094
00095 if (templateFunction_mp!=0)
00096 {
00097 ACS_SHORT_LOG((LM_ERROR,
00098 "SimpleConsumer::addSubscription unable to subscribe to multiple event types from this class!"));
00099 ACSErrTypeCommon::CouldntPerformActionExImpl err = ACSErrTypeCommon::CouldntPerformActionExImpl(__FILE__,
00100 __LINE__,
00101 "nc::SimpleConsumer::addSubscription");
00102 throw err.getCouldntPerformActionEx();
00103 }
00104
00105
00106 templateFunction_mp = templateFunction;
00107
00108
00109 handlerParam_mp = handlerParam;
00110
00111
00112 Consumer::addSubscription<J>();
00113 }
00114
00127 virtual void
00128 push_structured_event(const CosNotification::StructuredEvent ¬ification);
00130 protected:
00134 virtual ~SimpleConsumer();
00135
00139 eventHandlerFunction templateFunction_mp;
00144 void *handlerParam_mp;
00145
00146 private:
00150 void operator=(const SimpleConsumer&);
00151
00155 SimpleConsumer(const SimpleConsumer&);
00156
00158
00175 void
00176 addSubscription(const char* type_name, eventHandlerFunction templateFunction, void *handlerParam=0);
00177 };
00178 };
00179
00180 #include "acsncSimpleConsumer.i"
00181
00193 #define ACS_NEW_SIMPLE_CONSUMER(simpConsumer_p, idlStruct, channelName, handlerFunction, handlerParam) \
00194 { \
00195 simpConsumer_p = new nc::SimpleConsumer<idlStruct>(channelName); \
00196 simpConsumer_p->addSubscription<idlStruct>(handlerFunction, handlerParam);\
00197 }
00198
00199 #endif