Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

acsncSimpleConsumer.h

Go to the documentation of this file.
00001 #ifndef SIMPLE_CONSUMER_H 00002 #define SIMPLE_CONSUMER_H 00003 /* @(#) $Id: acsncSimpleConsumer.h,v 1.11 2008/10/01 03:14:56 cparedes Exp $ 00004 * ALMA - Atacama Large Millimiter Array 00005 * (c) Associated Universities Inc., 2002 00006 * (c) European Southern Observatory, 2002 00007 * Copyright by ESO (in the framework of the ALMA collaboration) 00008 * and Cosylab 2002, All rights reserved 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 //yikes...the developer is trying to subscribe to multiple event 00095 //types from a singly templated class. 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 //save a reference to the eventHandlerFunction 00107 templateFunction_mp = templateFunction; 00108 00109 //save the parameter to handler 00110 handlerParam_mp = handlerParam; 00111 00112 //just call superclass implementation 00113 Consumer::addSubscription<J>(); 00114 } 00115 00128 virtual void 00129 push_structured_event(const CosNotification::StructuredEvent &notification); 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

Generated on Thu Apr 30 02:30:49 2009 for ACS C++ API by doxygen 1.3.8