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

baciAlarm_T.h

Go to the documentation of this file.
00001 #ifndef _baci_alarmT_H_
00002 #define _baci_alarmT_H_
00003 /*******************************************************************************
00004 * ALMA - Atacama Large Millimiter Array
00005 * (c) European Southern Observatory, 2003 
00006 *
00007 *This library is free software; you can redistribute it and/or
00008 *modify it under the terms of the GNU Lesser General Public
00009 *License as published by the Free Software Foundation; either
00010 *version 2.1 of the License, or (at your option) any later version.
00011 *
00012 *This library is distributed in the hope that it will be useful,
00013 *but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 *Lesser General Public License for more details.
00016 *
00017 *You should have received a copy of the GNU Lesser General Public
00018 *License along with this library; if not, write to the Free Software
00019 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 *
00021 * "@(#) $Id: baciAlarm_T.h,v 1.18 2011/09/02 11:39:00 bjeram Exp $"
00022 *
00023 * who       when      what
00024 * --------  --------  ----------------------------------------------
00025 * bjeram  2003-06-11  created
00026 */
00027 
00033 #ifndef __cplusplus
00034 #error This is a C++ include file and cannot be used from plain C
00035 #endif
00036 
00037 #include <baciEvent.h>
00038 #include <ACSErrTypeAlarm.h>
00039 
00040 namespace baci {
00041 
00042 // forward
00043 template<class T, class TCB, class POA_CB>
00044 class EventCB;
00045 
00046 /********************************************************************************************/
00047 
00048 template<class T, class TCB, class POA_CB>
00049 class  baci_EXPORT MonitorEventDispatcher :
00050     public EventDispatcher, public MonitorImplementator
00051 {
00052   public:
00053     MonitorEventDispatcher(const CBDescIn& descIn,
00054                            const ACS::TimeInterval& interval,
00055                            BACIProperty * property);
00056     
00057     virtual ~MonitorEventDispatcher();
00058     
00059     virtual int subscribe(EventStrategy * event);
00060     
00061     virtual int unsubscribe(EventStrategy * event);
00062     
00063     virtual void dispatch(T value,
00064                           const ACSErr::Completion & c,
00065                           const ACS::CBDescOut & desc);
00066     
00067     virtual void suspend();
00068     
00069     virtual void resume();
00070     
00071     virtual void monitorDestroyed(void);
00072     
00073     virtual void monitorStateChanged(void);
00074     
00075   private:
00076     
00077     int callbackID_m;
00078     
00079     BACIMonitor * monitor_mp;
00080     
00081     TCB *monitorCallback_mp;
00082     
00083     EventCB<T, TCB, POA_CB>* callbackServant_mp;  
00084     
00088     void operator=(const MonitorEventDispatcher&);
00089     
00093     MonitorEventDispatcher(const MonitorEventDispatcher&);
00094 };
00095 
00096 /***********************************************************************************************/
00097 
00098 template<class T, class TCB, class POA_CB>
00099 class baci_EXPORT EventCB :  public virtual PortableServer::RefCountServantBase, public POA_CB
00100 {
00101   public:
00102     
00103     EventCB(MonitorEventDispatcher<T, TCB, POA_CB>* dispatcher);
00104     
00105     virtual ~EventCB();
00106     
00107     virtual void disposeDispatcher();
00108     
00109     virtual void working (T value,
00110                           const ACSErr::Completion & c,
00111                           const ACS::CBDescOut & desc);
00112     
00113     virtual void done (T value,
00114                        const ACSErr::Completion & c,
00115                        const ACS::CBDescOut & desc);
00116     
00117     virtual CORBA::Boolean negotiate (ACS::TimeInterval time_to_transmit,
00118                                       const ACS::CBDescOut & desc);
00119     
00120   private:
00121     
00122     MonitorEventDispatcher<T, TCB, POA_CB>* dispatcher_mp;
00123     
00127     void operator=(const EventCB&);
00128 
00132     EventCB(const EventCB&);
00133 };
00134 
00135 /************************************************************************************************/
00136 /* Common class for AlarmEventStrategies */
00137 
00138 template<class T, class TPROP, class TALARM>
00139 class baci_EXPORT AlarmEventStrategy : public EventStrategy
00140 {
00141   public:
00142     
00143     static const int maxFailureCount;
00144     
00145     AlarmEventStrategy(TPROP * property, EventDispatcher * eventDispatcher);
00146     
00147     AlarmEventStrategy(Callback_ptr callback_p,
00148                        const CBDescIn& descIn,
00149                        const ACS::TimeInterval& interval,
00150                        TPROP * property,
00151                        EventDispatcher * eventDispatcher);
00152     
00153     virtual ~AlarmEventStrategy();
00154     
00155     bool failed();
00156     void succeeded();
00157     
00158     CORBA::Object_ptr getCORBAReference() const 
00159         { 
00160             return reference_mp;
00161         }
00162     
00163     virtual bool isSuspended()
00164         {
00165             return suspended_m;
00166         }
00167     
00168     virtual int getId(void);
00169     
00170     virtual const char* getName(void);
00171     
00172     virtual const char* getObjectState(void);
00173     
00174     virtual void setObjectState(const char * state);
00175     
00176     virtual void suspend ();
00177     
00178     virtual void resume ();
00179     
00180     virtual void destroy (); 
00181     
00182   private:
00183     
00184     ACE_CString name_m;
00185     
00186     bool suspended_m;
00187     
00188     int failureCount_m;
00189     
00190     CBDescIn desc_mIn;
00191     
00192     ACS::TimeInterval interval_m;
00193     
00194     EventDispatcher * eventDispatcher_mp;
00195     
00196     CORBA::Object_ptr reference_mp;
00197     
00198     
00202     void operator=(const AlarmEventStrategy&);
00203     
00207     AlarmEventStrategy(const AlarmEventStrategy&);
00208     
00209     
00210   protected:
00211     
00212     TPROP *property_mp;
00213     
00214     TALARM *callback_mp;
00215     
00216     int alarmRaised_m;
00217 };
00218 
00219 /************************************************************************************************/
00220 /* AlarmEventStrategy implementation for discreet types */
00221 
00222 template<class T, class TPROP, class TALARM>
00223 class baci_EXPORT AlarmEventStrategyDisc : public AlarmEventStrategy<T, TPROP, TALARM>
00224 {
00225   public:
00226     AlarmEventStrategyDisc(TPROP * property, EventDispatcher * eventDispatcher);
00227     
00228     AlarmEventStrategyDisc(Callback_ptr callback_p,
00229                            const CBDescIn& descIn,
00230                            const ACS::TimeInterval& interval,
00231                            TPROP * property,
00232                            EventDispatcher * eventDispatcher);
00233     
00234     virtual void check(BACIValue &value,
00235                        const ACSErr::Completion & c,
00236                        const ACS::CBDescOut & desc);
00237     
00238   private:
00242     void operator=(const AlarmEventStrategyDisc&);
00243 
00247     AlarmEventStrategyDisc(const AlarmEventStrategyDisc&);
00248 
00249     // mutex for thread-safe
00250     ACE_Recursive_Thread_Mutex templateMutex;
00251 };
00252 
00253 /***********************************************************************************************/
00254 /* AlarmEventStrategy implementation for continues types */
00255 
00256 template<class T, class TPROP, class TALARM>
00257 class baci_EXPORT AlarmEventStrategyCont : public AlarmEventStrategy<T, TPROP, TALARM>
00258 {
00259   public:
00260     AlarmEventStrategyCont(TPROP * property, EventDispatcher * eventDispatcher);
00261     
00262     AlarmEventStrategyCont(Callback_ptr callback_p,
00263                            const CBDescIn& descIn,
00264                            const ACS::TimeInterval& interval,
00265                            TPROP * property,
00266                            EventDispatcher * eventDispatcher);
00267     
00268     virtual void check(BACIValue &value,
00269                        const ACSErr::Completion & c,
00270                        const ACS::CBDescOut & desc);
00271     
00272   private:
00276     void operator=(const AlarmEventStrategyCont&);
00277     
00281     AlarmEventStrategyCont(const AlarmEventStrategyCont&);
00282 };
00283 
00284 
00285 /***********************************************************************************************/
00286 /* AlarmEventStrategy implementation for continues sequence types */
00287 
00288 template<class T, class TPROP, class TALARM>
00289 class baci_EXPORT AlarmEventStrategyContSeq : public AlarmEventStrategy<T, TPROP, TALARM>
00290 {
00291   public:
00292     AlarmEventStrategyContSeq(TPROP * property, EventDispatcher * eventDispatcher);
00293     
00294     AlarmEventStrategyContSeq(Callback_ptr callback_p,
00295                               const CBDescIn& descIn,
00296                               const ACS::TimeInterval& interval,
00297                               TPROP * property,
00298                               EventDispatcher * eventDispatcher);
00299     
00300     virtual void check(BACIValue &value,
00301                        const ACSErr::Completion & c,
00302                        const ACS::CBDescOut & desc);
00303   protected:
00304     
00305     int * alarmsRaised_mp;
00306     int alarmsRaisedLength_m;
00307     
00308   private:
00312     void operator=(const AlarmEventStrategyContSeq&);
00313     
00317     AlarmEventStrategyContSeq(const AlarmEventStrategyContSeq&);
00318 
00319     // mutex for thread-safe
00320     ACE_Recursive_Thread_Mutex templateMutex;
00321 };
00322 
00323 /***********************************************************************************************/
00324 /* AlarmEventStrategy implementation for discrete sequence types */
00325 
00326 template<class T, class TPROP, class TALARM>
00327 class baci_EXPORT AlarmEventStrategyDiscSeq : public AlarmEventStrategy<T, TPROP, TALARM>
00328 {
00329   public:
00330     AlarmEventStrategyDiscSeq(TPROP * property, EventDispatcher * eventDispatcher);
00331     
00332     AlarmEventStrategyDiscSeq(Callback_ptr callback_p,
00333                               const CBDescIn& descIn,
00334                               const ACS::TimeInterval& interval,
00335                               TPROP * property,
00336                               EventDispatcher * eventDispatcher);
00337     
00338     virtual void check(BACIValue &value,
00339                        const ACSErr::Completion & c,
00340                        const ACS::CBDescOut & desc);
00341 
00342   protected:
00343     
00344     int * alarmsRaised_mp;
00345     int alarmsRaisedLength_m;
00346     
00347   private:
00351     void operator=(const AlarmEventStrategyDiscSeq&);
00352     
00356     AlarmEventStrategyDiscSeq(const AlarmEventStrategyDiscSeq&);
00357 
00358     // mutex for thread-safe
00359     ACE_Recursive_Thread_Mutex templateMutex;
00360 };
00361 
00362 }; //namespace baci
00363 
00364 #endif 

Generated on Fri Apr 15 2016 15:14:17 for ACS-2016.4 C++ API by  doxygen 1.7.0