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

baciBACIProperty.h

Go to the documentation of this file.
00001 #ifndef baciBACIProperty_H
00002 #define baciBACIProperty_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: baciBACIProperty.h,v 1.8 2011/03/30 17:57:23 tstaig Exp $"
00023 *
00024 * who       when      what
00025 * --------  --------  ----------------------------------------------
00026 * dfugate 2005-01-17 created
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 "baciExport.h"
00039 #include "baciThread.h"
00040 #include "baciValue.h"
00041 #include "logging.h"
00042 #include "baciBACIMonitor.h"
00043 #include "baciCharacteristicModelImpl.h"
00044 
00045 #include <vector>
00046 
00047 namespace baci {
00048 
00049 
00050 class BACIComponent;
00051 class BACIProperty;
00052 
00053 /* ------------------------------------------------------------------------ */
00054 
00061 class baci_EXPORT PropertyImplementator 
00062 {
00063 public:
00064 
00072   virtual void getValue(BACIProperty* property,
00073                         BACIValue* value, 
00074                         Completion &completion,
00075                         CBDescOut& descOut) = 0;
00076 
00083   virtual int initialization() { return 0; }
00084 
00086   virtual ~PropertyImplementator() {}
00087 
00088 };  /* PropertyImplementator */
00089 
00090 /* ------------------------------------------------------------------------ */
00091 
00092 
00093 
00100 class baci_EXPORT BACIProperty
00101 {
00102 
00103 public:
00104 
00113   BACIProperty(const ACE_CString& name_,
00114                PropertyImplementator* propertyImplementator_,
00115                CharacteristicModelImpl *characteristicModel_,
00116                const BACIValue& defaultValue_,
00117                BACIComponent* component_p);
00118 
00122   ~BACIProperty();
00123 
00124   /* ---- */
00125 
00126 //  ACE_CString getName() const { return name; }
00127   const char * getName() const { return name_m.c_str(); }
00128 
00129   BACIValue::Type getType() const { return type_m; }
00130 
00131   PropertyImplementator* getPropertyImplementator() const { return propertyImplementator_mp; }
00132 
00133   CharacteristicModelImpl* getCharacteristicModel() const { return characteristicModel_mp; };
00134 
00142   void getValue(BACIProperty* property,
00143                 BACIValue* value, 
00144                 Completion &completion,
00145                 CBDescOut& descOut)
00146   {
00147     if (propertyImplementator_mp!=0)
00148       propertyImplementator_mp->getValue(property,
00149                                       value,
00150                                       completion,
00151                                       descOut);
00152   }
00153 
00154   BACIComponent* getComponent() const { return component_mp; }
00155 
00156   int getMonitorCount() const { return monitorVector_m.size(); }
00157   BACIMonitor* getMonitorAt(int pos) const { return monitorVector_m[pos]; }
00158   
00159   bool hasTriggerOnValueMonitor() const { return triggerOnValueMonitor_m; }
00160   bool hasTriggerOnValuePercentMonitor() const { return triggerOnValuePercentMonitor_m; }
00161 
00162   ACS::TimeInterval getPollInterval() const { return pollInterval_m; }
00163   ACS::TimeInterval getLastPollTime() const { return lastPollTime_m; }
00164   ACS::TimeInterval getMonMinTriggerTime() const { return monMinTriggerTime_m; }
00165   BACIValue getLastValue() const { return lastValue_m; }
00166   //Completion getLastCompletion() const { return lastCompletion; }
00167 
00168   void setPollInterval(const ACS::TimeInterval& _pollInterval) { pollInterval_m=_pollInterval; }
00169   void setLastPollTime(const ACS::TimeInterval& _lastPollTime) { lastPollTime_m=_lastPollTime; }
00170   void setMonMinTriggerTime(const ACS::TimeInterval& _interval) { monMinTriggerTime_m=_interval; }
00171   void setLastValue(const BACIValue& _lastValue) {lastValue_m=_lastValue;}
00172   //void setLastCompletion(const Completion& _lastCompletion) { lastCompletion=_lastCompletion;}
00173 
00174   void dispatchMonitors(Completion& completion, CBDescOut& descOut);
00175   void updateMonitorStates();
00176 
00177   bool isInDestructionState() const { return inDestructionState_m; };
00178 
00179 protected:
00180 
00181   void addMonitor(BACIMonitor* monitor);
00182   void removeMonitor(BACIMonitor* monitor);
00183 
00184   ACS::TimeInterval GCD(ACS::TimeInterval t1, ACS::TimeInterval t2);
00185 
00186 
00187 private:
00188   ACE_CString name_m;
00189 
00190   PropertyImplementator* propertyImplementator_mp;
00191   CharacteristicModelImpl* characteristicModel_mp;
00192 
00193   BACIValue lastValue_m;
00194 
00195   BACIComponent* component_mp;
00196 
00197   BACIMonitorVector monitorVector_m;
00198 
00199   bool triggerOnValueMonitor_m;
00200   bool triggerOnValuePercentMonitor_m;
00201     ACS::TimeInterval pollInterval_m;
00202     ACS::TimeInterval lastPollTime_m;
00203     ACS::TimeInterval monMinTriggerTime_m;
00204   // Completion lastCompletion;
00205 
00206   BACIMonitor* archiver_mp;
00207 
00208   BACIValue::Type type_m;
00209 
00210   bool inDestructionState_m;
00211 
00212   BACIMutex monitorVectorMutex_m;
00213 
00214   friend class BACIComponent;
00215   friend class BACIMonitor;
00216 
00220     void operator=(const BACIProperty&);
00221     
00225     BACIProperty(const BACIProperty&);
00226 
00227 };   /* BACIProperty */
00228 
00232 typedef std::vector<BACIProperty*> BACIPropertyVector;
00233 
00234 
00235 /* ------------------------------------------------------------------------ */
00236 
00237  }; 
00238 
00239 #endif /* baci_H */ 
00240 
00241 

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