• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

baciEvent.h

Go to the documentation of this file.
00001 #ifndef baciEvent_H
00002 #define baciEvent_H
00003 
00004 /*******************************************************************
00005 * ALMA - Atacama Large Millimiter Array
00006 * (c) European Southern Observatory, 2003 
00007 *
00008 *This library is free software; you can redistribute it and/or
00009 *modify it under the terms of the GNU Lesser General Public
00010 *License as published by the Free Software Foundation; either
00011 *version 2.1 of the License, or (at your option) any later version.
00012 *
00013 *This library is distributed in the hope that it will be useful,
00014 *but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 *Lesser General Public License for more details.
00017 *
00018 *You should have received a copy of the GNU Lesser General Public
00019 *License along with this library; if not, write to the Free Software
00020 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00021 *
00022 * "@(#) $Id: baciEvent.h,v 1.100 2011/09/02 11:39:00 bjeram Exp $"
00023 *
00024 * who       when        what
00025 * --------  ----------  ----------------------------------------------
00026 * msekoran  2001/03/11  modified
00027 */
00028 
00034 #ifndef __cplusplus
00035 #error This is a C++ include file and cannot be used from plain C
00036 #endif
00037 
00038 #include <acsutil.h>
00039 #include <baci.h>
00040 #include <baciS.h>
00041 #include <vector>
00042 #include <baciRecoverableObject.h>
00043 
00044 #include <ace/Synch.h>
00045 
00046 namespace baci {
00047 
00048 // forward
00049 class EventStrategy;
00050 
00054 // get rid of this stl!!!
00055 typedef std::vector<EventStrategy*> EventStrategyVector;  
00056 
00064 class baci_EXPORT EventDispatcher
00065 {
00066 
00067 public:
00068 
00072   EventDispatcher();
00073 
00078   virtual ~EventDispatcher();
00079 
00085   int subscribe(EventStrategy * event);
00086 
00092   int unsubscribe(EventStrategy * event);
00093 
00098   virtual EventStrategyVector& getSubscribers();
00099 
00103   virtual ACE_Recursive_Thread_Mutex& getMutex();
00104 
00108   virtual void suspend() = 0;
00109 
00113   virtual void resume() = 0;
00114 
00115 protected:
00116 
00120   virtual void destroyEvents();
00121 
00125   EventStrategyVector events_m;
00126 
00130   int active_m;
00131 
00135   ACE_Recursive_Thread_Mutex mutex_m;
00136 
00140   bool shutdown_m;
00141   
00142 };
00143 
00152 class baci_EXPORT EventStrategy : public virtual PortableServer::RefCountServantBase,
00153                       public POA_ACS::Subscription,
00154                       public RecoverableObject
00155 {
00156 
00157 public:
00158 
00162   EventStrategy() {}
00163 
00169   EventStrategy(BACIProperty * property, EventDispatcher * eventDispatcher) {
00170     ACE_UNUSED_ARG(property);
00171     ACE_UNUSED_ARG(eventDispatcher);
00172   }
00173  
00177   virtual ~EventStrategy() {}
00178 
00184   virtual void check(BACIValue &value,
00185                      const ACSErr::Completion & c,
00186                      const ACS::CBDescOut & desc) = 0;
00187 
00191   virtual bool isSuspended() = 0;
00192 
00193   /* ------------------- [ Recoverable interface ] --------------------*/
00194 
00195   virtual int getId(void) = 0;
00196   virtual const char* getName(void) = 0;
00197   virtual const char* getObjectState(void) = 0;
00198   virtual void setObjectState(const char * state) = 0;
00199 
00200   /* ------------------ [ Subscription interface ] -------------------- */ 
00201   
00205   virtual void suspend () = 0;
00206   
00210   virtual void resume () = 0;
00211   
00215   virtual void destroy () = 0;
00216   
00217 };
00218 
00219  }; 
00220 
00221 #endif  /* baciEvent_H */
00222 
00223 
00224 
00225 
00226 

Generated on Thu Jan 12 2012 23:13:50 for ACS-10.0 C++ API by  doxygen 1.7.0