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
00035
00051 template <class T> class SimpleConsumer : public Consumer
00052 {
00053 public:
00062 typedef void (*eventHandlerFunction)(T eventData, void *handlerParam);
00064
00068 SimpleConsumer(const char* channelName);
00070
00089 template <class J> void
00090 addSubscription(eventHandlerFunction templateFunction, void *handlerParam=0)
00091 {
00092 ACS_TRACE("SimpleConsumer::addSubscription");
00093
00094
00095
00096 if (templateFunction_mp!=0)
00097 {
00098 ACS_SHORT_LOG((LM_ERROR,
00099 "SimpleConsumer::addSubscription unable to subscribe to multiple event types from this class!"));
00100 ACSErrTypeCommon::CouldntPerformActionExImpl err = ACSErrTypeCommon::CouldntPerformActionExImpl(__FILE__,
00101 __LINE__,
00102 "nc::SimpleConsumer::addSubscription");
00103 throw err.getCouldntPerformActionEx();
00104 }
00105
00106
00107 templateFunction_mp = templateFunction;
00108
00109
00110 handlerParam_mp = handlerParam;
00111
00112
00113 Consumer::addSubscription<J>();
00114 }
00115
00128 virtual void
00129 push_structured_event(const CosNotification::StructuredEvent ¬ification);
00131 protected:
00135 virtual ~SimpleConsumer();
00136
00140 eventHandlerFunction templateFunction_mp;
00145 void *handlerParam_mp;
00146
00147 private:
00151 void operator=(const SimpleConsumer&);
00152
00156 SimpleConsumer(const SimpleConsumer&);
00157
00159
00176 void
00177 addSubscription(const char* type_name, eventHandlerFunction templateFunction, void *handlerParam=0);
00178 };
00179 };
00180
00181 #include "acsncSimpleConsumer.i"
00182
00194 #define ACS_NEW_SIMPLE_CONSUMER(simpConsumer_p, idlStruct, channelName, handlerFunction, handlerParam) \
00195 { \
00196 simpConsumer_p = new nc::SimpleConsumer<idlStruct>(channelName); \
00197 simpConsumer_p->addSubscription<idlStruct>(handlerFunction, handlerParam);\
00198 }
00199
00200 #endif