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

MCtestDevIO.h

Go to the documentation of this file.
00001 #ifndef MC_DEVIO_H
00002 #define MC_DEVIO_H
00003 /*******************************************************************************
00004 * ALMA - Atacama Large Millimiter Array
00005 * (c) European Southern Observatory, 2009
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: MCtestDevIO.h,v 1.2 2011/05/23 19:31:44 javarias Exp $"
00022 *
00023 * who       when      what
00024 * --------  --------  ----------------------------------------------
00025 * bjeram  2009-02-11  created
00026 */
00027 
00028 #ifndef __cplusplus
00029 #error This is a C++ include file and cannot be used from plain C
00030 #endif
00031 
00032 #include <baciDevIO.h>
00033 
00034 namespace TMCDB
00035 {
00036 
00037 template <class T> class MCtestDevIO : public DevIO<T>
00038 {
00039  public:
00040 
00046          MCtestDevIO(T &value, ACS::Time& timestamp) :
00047                  value_m(value),
00048                  timestamp_m(timestamp)
00049          {};
00050 
00051     virtual ~MCtestDevIO() {};
00052 
00053     virtual bool initializeValue(){ return true; }
00054 
00058     virtual T read(ACS::Time& timestamp)
00059         {
00060         timestamp_m+= 10000000; //we increase timestamp for 1sec
00061         value_m++;
00062 
00063         timestamp = timestamp_m;
00064             return value_m;
00065         }
00066 
00070     virtual void write(const T& value, ACS::Time& timestamp)
00071         {
00072             timestamp = timestamp_m;
00073             value_m = value;
00074         }
00075 
00076   protected:
00077     T value_m;
00078     ACS::Time& timestamp_m;
00079 };
00080 
00081 template <class T> class MCtestDevIOSeq : public DevIO<T>
00082 {
00083 public:
00084 
00095         MCtestDevIOSeq(T &value, ACS::Time& timestamp) :
00096                 value_m(value),
00097                 timestamp_m(timestamp)
00098                 {};
00099 
00100                 virtual ~MCtestDevIOSeq() {};
00101 
00102                 virtual bool initializeValue(){ return true; }
00103 
00104 
00105 
00106                 T read(ACS::Time& timestamp)
00107                 {
00108                         for(unsigned int i=0;i<this->value_m.length();i++)
00109                                 this->value_m[i]++;
00110 
00111                         this->timestamp_m+= 10000000; //we increase timestamp for 1sec
00112 
00113                         timestamp = this->timestamp_m;
00114                         return this->value_m;
00115                 }
00116 
00117                 virtual void write(const T& value, ACS::Time& timestamp)
00118                 {
00119                         timestamp_m = timestamp;
00120                         value_m = value;
00121                 }
00122 
00123 protected:
00124         T value_m;
00125         ACS::Time& timestamp_m;
00126 };
00127 
00128         template <class T> class MCtestDevIONoIncremental : public DevIO<T>
00129         {
00130           public:
00131         
00137                 MCtestDevIONoIncremental(T &value, ACS::Time& timestamp) :
00138                         value_m(value),
00139                         timestamp_m(timestamp)
00140                 {}
00141         
00142                 virtual ~MCtestDevIONoIncremental() {};
00143                 virtual bool initializeValue(){ return true; }
00144         
00148                 virtual T read(ACS::Time& timestamp)
00149                 {
00150                         timestamp = timestamp_m;
00151                         return value_m;
00152                 }
00153         
00157                  virtual void write(const T& value, ACS::Time& timestamp)
00158                 {
00159                         timestamp = timestamp_m;
00160                         value_m = value;
00161                 }
00162         
00163           protected:
00164                 T value_m;
00165                 ACS::Time& timestamp_m;
00166         };
00167         
00168         template <class T> class MCtestDevIOSeqNoIncremental : public DevIO<T>
00169         {
00170         public:
00171         
00177                 MCtestDevIOSeqNoIncremental(T &value, ACS::Time& timestamp) :
00178                         value_m(value),
00179                         timestamp_m(timestamp)
00180                         {}
00181 
00182                         virtual ~MCtestDevIOSeqNoIncremental() {};
00183                         virtual bool initializeValue(){ return true; }
00184         
00185         
00186         
00187                         T read(ACS::Time& timestamp)
00188                         {
00189                                 timestamp = this->timestamp_m;
00190                                 return this->value_m;
00191                         }
00192         
00193                         virtual void write(const T& value, ACS::Time& timestamp)
00194                         {
00195                                 timestamp_m = timestamp;
00196                                 value_m = value;
00197                         }
00198         
00199         protected:
00200                 T value_m;
00201                 ACS::Time& timestamp_m;
00202         };
00203 
00204 };//namespace TMCDB
00205 
00206 #endif 

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