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

baciPcommonImpl_T.h

Go to the documentation of this file.
00001 #ifndef _baciPcommonImpl_T_H_
00002 #define _baciPcommonImpl_T_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: baciPcommonImpl_T"
00022 *
00023 * who       when        what
00024 * --------  ----------  ----------------------------------------------
00025 * bjeram    07/02/2003  created
00026 */
00027 
00037 #ifndef __cplusplus
00038 #error This is a C++ include file and cannot be used from plain C
00039 #endif
00040 
00041 #include "baciDB.h"
00042 #include <acsutil.h>
00043 #include <baci.h>
00044 #include <baciS.h>
00045 #include <baciCORBA.h>
00046 #include <baciCORBAMem.h>
00047 #include <baciEvent.h>
00048 #include <baciDevIOMem.h>
00049 #include <baciCharacteristicModelImpl.h>
00050 #include <ACSErrTypeCommon.h>
00051 #include <ACSErrTypeDevIO.h>
00052 #include <baciErrTypeProperty.h>
00053 #include <baciErrTypeDevIO.h>
00054 
00060 #define HISTORY_SIZE 32
00061 
00064 
00068 #define ACS_P_T(T, TC) TC, ACS::CB##T, ACS::T##Seq, ACS::T##Seq_out, ACS::Monitor##T, baci::Monitor##T,TC, TC, TC
00069 //, POA_ACS::RW##T 
00070 
00071 //#define ACS_P_TL(X) X T, X TCB, X TSeq, X TSeq_out, X TMonitor, X TMonitorImpl, X POA_SK, X TBACIValue 
00072 
00076 #define ACS_P_TL T, TCB, TSeq, TSeq_out, TMonitor, TMonitorImpl, TM, TS, TSM, POA_SK
00077 
00081 #define ACS_P_C class T, class TCB, class TSeq, class TSeq_out, class TMonitor, class TMonitorImpl, class TM, class TS, class TSM, class POA_SK
00082 
00083 
00084 namespace baci {
00085 
00089 template <class T>
00090 class CDBconverter
00091 {
00092   public:
00093     static void convertValue(const char *str, T& v)
00094         {
00095             std::istringstream is(str);
00096             (istream&) is >> v;
00097             if (!is)
00098                 throw cdbErrType::WrongCDBDataTypeExImpl(__FILE__, __LINE__, "CDBconverter::converterValue");
00099         }
00100 };
00101 
00102 template<>
00103 class CDBconverter<ACE_CString>
00104 {
00105   public:
00106     static void convertValue(const char *s, ACE_CString& v)
00107         {
00108             v = (const char*)s;
00109         }
00110 };
00111 
00117 template<ACS_P_C>
00118 class baci_EXPORT PcommonImpl:  public virtual POA_SK,  
00119                                 public CharacteristicModelImpl,
00120                                 public PropertyImplementator,
00121                                 public ActionImplementator
00122 {
00123 
00124 
00125 public:
00131     PcommonImpl(const ACE_CString& name, BACIComponent *component_p, DevIO<TM> *devIO, bool flagdeldevIO);
00132 
00136   virtual ~PcommonImpl();
00137 
00138   /*
00139    * Property construction status method
00140    * After contruction of a property, this method will be called
00141    * to check if construction was successful; if not, monitor will be destroyed by parent
00142    * @return 0 on success or any other value (value can indicate cause of faulire) on faulure
00143    */
00144   virtual int initialization() { return initialization_m; }
00145 
00150   CORBA::Object_ptr getCORBAReference() const { return reference_mp;  }
00151 
00155   BACIProperty* getProperty() const { return property_mp; }
00156 
00163    virtual void destroy();
00164 
00168     DevIO<TM>* getDevIO() const { return devIO_mp; }
00169     
00170   /***
00171    * Implementations of async. get_value method
00172    */
00173     virtual ActionRequest getValueAction(BACIComponent* component_p, 
00174                                          int callbackID,
00175                                          const CBDescIn& descIn, 
00176                                          BACIValue* value,
00177                                          Completion& completion, 
00178                                          CBDescOut& descOut);
00179 
00180 
00181   /* --------------- [ Action implementator interface ] -------------- */
00182 
00200   virtual ActionRequest invokeAction(int function,
00201                                      BACIComponent* component_p, 
00202                                      const int &callbackID, 
00203                                      const CBDescIn& descIn, 
00204                                      BACIValue* value, 
00205                                      Completion& completion, 
00206                                      CBDescOut& descOut);
00207 
00208   /* -------------- [ Property implementator interface ] -------------- */
00209 
00217   virtual void getValue(BACIProperty* property,
00218                         BACIValue* value, 
00219                         Completion &completion,
00220                         CBDescOut& descOut);
00221 
00222   /* ----------------------------------------------------------------- */
00223   /* ---------------------- [ CORBA interface ] ---------------------- */
00224   /* ----------------------------------------------------------------- */
00225   
00226   /* --------------------- [ Property interface ] --------------------- */
00227     
00228     virtual char * name ();
00229     
00230     virtual char * characteristic_component_name ();
00231 
00232     /*
00233       already defined bt CharacteristicModelImpl
00234     virtual CosPropertyService::PropertySet_ptr get_all_characteristics ()
00235     */
00236     
00237     /* ----------------- [ TypelessProperty interface ] ----------------- */
00238     
00239     virtual CORBA::Boolean initialize_devio ();
00240     
00241     virtual char * description ();
00242     
00243     virtual char * format ();
00244     
00245     virtual char * units ();
00246     
00247     virtual ACS::pattern resolution ();
00248     
00249     /* -------------------- [ P interface ] -------------------- */
00250     
00251     virtual ACS::TimeInterval default_timer_trigger ();
00252     
00253     virtual ACS::TimeInterval min_timer_trigger ();
00254     
00255     virtual TS default_value ();
00256     
00257     virtual T get_sync (ACSErr::Completion_out c);
00258     
00259     virtual void get_async (TCB *cb,
00260                             const ACS::CBDescIn & desc);
00261     
00262     virtual CORBA::Long get_history (CORBA::Long n_last_values,
00263                                      TSeq_out vs,
00264                                      ACS::TimeSeq_out ts);
00265         
00266     virtual TMonitor* create_monitor (TCB*cb,
00267                                       const ACS::CBDescIn & desc);
00268         
00269     virtual TMonitor* create_postponed_monitor (ACS::Time start_time,
00270                                                 TCB *cb,
00271                                                 const ACS::CBDescIn & desc);
00272   
00273   protected:
00274     
00280     virtual bool readCharacteristics();
00281   
00282     /* --------------------- [ History support ] ---------------------- */
00283     
00284     void addValueToHistory(ACS::Time time, TM &value);
00285     
00287     BACIProperty* property_mp;
00288     
00289     DevIO<TM> *devIO_mp;  
00290     bool deldevIO_m;
00291     TM value_m;
00292     
00294     int initialization_m;
00295     
00308     typedef ActionRequest (PcommonImpl<ACS_P_TL>::*ActionFunction)(BACIComponent* component_p, 
00309                                                                    int callbackID,
00310                                                                    const CBDescIn& descIn, 
00311                                                                    BACIValue* value,
00312                                                                    ACSErr::Completion& completion, 
00313                                                                    CBDescOut& descOut);  
00316 
00317   bool destroyed_m;
00318 
00320   CORBA::Object_ptr reference_mp;
00321 
00323   TM historyValue_m[HISTORY_SIZE];
00324 
00326   ACS::Time historyTime_m[HISTORY_SIZE];
00327 
00329   int historyStart_m;
00330 
00332   bool historyTurnaround_m;
00333 
00337  
00338   bool initializeDevIO_m; 
00339   // Typeless property
00340   ACE_CString  description_m;                   
00341   ACE_CString  format_m;                                
00342   ACE_CString  units_m;                                 
00343   ACS::pattern resolution_m;                    
00344 
00345   // P  
00346   TSM   defaultValue_m;                         
00347   ACS::TimeInterval  defaultTimerTrig_m;                
00348   ACS::TimeInterval  minTimerTrig_m;
00349 
00350   private:
00354     void operator=(const PcommonImpl&);
00355 
00359     PcommonImpl(const PcommonImpl&);
00360 };
00361 
00362 //#include "baciPcommonImpl_T.i"
00363 
00364  }; 
00365 
00366 #endif
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374 
00375 
00376 
00377 
00378 
00379 
00380 
00381 
00382 
00383 
00384 
00385 
00386 
00387 
00388 
00389 

Generated on Thu Jul 8 2010 19:47:46 for ACS-9.0 C++ API by  doxygen 1.7.0