• 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         AlarmEventStrategy<T, TPROP, TALARM>(property, eventDispatcher)
00228         {};
00229     
00230     AlarmEventStrategyDisc(Callback_ptr callback_p,
00231                            const CBDescIn& descIn,
00232                            const ACS::TimeInterval& interval,
00233                            TPROP * property,
00234                            EventDispatcher * eventDispatcher) :
00235         AlarmEventStrategy<T, TPROP, TALARM>(callback_p, descIn, interval, property, eventDispatcher)
00236         {};
00237     
00238     virtual void check(BACIValue &value,
00239                        const ACSErr::Completion & c,
00240                        const ACS::CBDescOut & desc);
00241     
00242   private:
00246     void operator=(const AlarmEventStrategyDisc&);
00247 
00251     AlarmEventStrategyDisc(const AlarmEventStrategyDisc&);
00252 
00253     // mutex for thread-safe
00254     ACE_Recursive_Thread_Mutex templateMutex;
00255 };
00256 
00257 /***********************************************************************************************/
00258 /* AlarmEventStrategy implementation for continues types */
00259 
00260 template<class T, class TPROP, class TALARM>
00261 class baci_EXPORT AlarmEventStrategyCont : public AlarmEventStrategy<T, TPROP, TALARM>
00262 {
00263   public:
00264     AlarmEventStrategyCont(TPROP * property, EventDispatcher * eventDispatcher) :
00265         AlarmEventStrategy<T, TPROP, TALARM>(property, eventDispatcher)
00266         {};
00267     
00268     AlarmEventStrategyCont(Callback_ptr callback_p,
00269                            const CBDescIn& descIn,
00270                            const ACS::TimeInterval& interval,
00271                            TPROP * property,
00272                            EventDispatcher * eventDispatcher) :
00273         AlarmEventStrategy<T, TPROP, TALARM>(callback_p, descIn, interval, property, eventDispatcher)
00274         {};
00275     
00276     virtual void check(BACIValue &value,
00277                        const ACSErr::Completion & c,
00278                        const ACS::CBDescOut & desc);
00279     
00280   private:
00284     void operator=(const AlarmEventStrategyCont&);
00285     
00289     AlarmEventStrategyCont(const AlarmEventStrategyCont&);
00290 };
00291 
00292 
00293 /***********************************************************************************************/
00294 /* AlarmEventStrategy implementation for continues sequence types */
00295 
00296 template<class T, class TPROP, class TALARM>
00297 class baci_EXPORT AlarmEventStrategyContSeq : public AlarmEventStrategy<T, TPROP, TALARM>
00298 {
00299   public:
00300     AlarmEventStrategyContSeq(TPROP * property, EventDispatcher * eventDispatcher) :
00301         AlarmEventStrategy<T, TPROP, TALARM>(property, eventDispatcher)
00302         {};
00303     
00304     AlarmEventStrategyContSeq(Callback_ptr callback_p,
00305                               const CBDescIn& descIn,
00306                               const ACS::TimeInterval& interval,
00307                               TPROP * property,
00308                               EventDispatcher * eventDispatcher) :
00309         AlarmEventStrategy<T, TPROP, TALARM>(callback_p, descIn, interval, property, eventDispatcher)
00310         {};
00311     
00312     virtual void check(BACIValue &value,
00313                        const ACSErr::Completion & c,
00314                        const ACS::CBDescOut & desc);
00315   protected:
00316     
00317     int * alarmsRaised_mp;
00318     int alarmsRaisedLength_m;
00319     
00320   private:
00324     void operator=(const AlarmEventStrategyContSeq&);
00325     
00329     AlarmEventStrategyContSeq(const AlarmEventStrategyContSeq&);
00330 
00331     // mutex for thread-safe
00332     ACE_Recursive_Thread_Mutex templateMutex;
00333 };
00334 
00335 /***********************************************************************************************/
00336 /* AlarmEventStrategy implementation for discrete sequence types */
00337 
00338 template<class T, class TPROP, class TALARM>
00339 class baci_EXPORT AlarmEventStrategyDiscSeq : public AlarmEventStrategy<T, TPROP, TALARM>
00340 {
00341   public:
00342     AlarmEventStrategyDiscSeq(TPROP * property, EventDispatcher * eventDispatcher) :
00343         AlarmEventStrategy<T, TPROP, TALARM>(property, eventDispatcher)
00344         {};
00345     
00346     AlarmEventStrategyDiscSeq(Callback_ptr callback_p,
00347                               const CBDescIn& descIn,
00348                               const ACS::TimeInterval& interval,
00349                               TPROP * property,
00350                               EventDispatcher * eventDispatcher) :
00351         AlarmEventStrategy<T, TPROP, TALARM>(callback_p, descIn, interval, property, eventDispatcher)
00352         {};
00353     
00354     virtual void check(BACIValue &value,
00355                        const ACSErr::Completion & c,
00356                        const ACS::CBDescOut & desc);
00357 
00358   protected:
00359     
00360     int * alarmsRaised_mp;
00361     int alarmsRaisedLength_m;
00362     
00363   private:
00367     void operator=(const AlarmEventStrategyDiscSeq&);
00368     
00372     AlarmEventStrategyDiscSeq(const AlarmEventStrategyDiscSeq&);
00373 
00374     // mutex for thread-safe
00375     ACE_Recursive_Thread_Mutex templateMutex;
00376 };
00377 
00378 }; //namespace baci
00379 
00380 #endif 

Generated on Mon Feb 8 2016 16:51:26 for ACS-2016.2 C++ API by  doxygen 1.7.0