Component.h

Go to the documentation of this file.
00001 // -*- mode: C++ -*- 
00002 //
00003 // Copyright (C) 2006 Christian Holm Christensen <cholm@nbi.dk>
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public License
00007 // as published by the Free Software Foundation; either version 2.1
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free
00017 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018 // 02111-1307 USA
00019 //
00025 #ifndef RCUCONF_COMPONENT_H
00026 #define RCUCONF_COMPONENT_H
00027 #ifndef RCUCONF_PARAMETER
00028 # include <rcuconf/Parameter.h>
00029 #endif
00030 #ifndef RCUCONF_ADDRESS
00031 # include <rcuconf/Address.h>
00032 #endif
00033 #ifndef __STRING__
00034 # include <string>
00035 #endif
00036 
00037 namespace Rcuxx
00038 {
00039   class AltroRegister;
00040   class AltroCommand;
00041 }
00042 
00043 // Forward decls in DB namespace
00044 namespace RcuDb 
00045 {
00046   class Server;
00047 }
00048 
00049 namespace RcuConf
00050 {
00053   // Forward decls. 
00054   class SingleValue;
00055   class BlobValue;
00056   class Address;
00057   
00058   
00063   class Component 
00064   {
00065   public:
00067     Component() {}
00069     virtual ~Component() {}
00070     
00073     enum {
00075       kSuccess = 0, 
00077       kNotSupported, 
00079       kUnknownParameter, 
00081       kInvalidValue, 
00084       kInvalidAddress,
00086       kFailure 
00087     };
00088         
00094     virtual unsigned int Write(const Parameter&   p, 
00095                                const SingleValue& v) = 0;
00103     virtual unsigned int Write(const Parameter&   p, 
00104                                const SingleValue& v, 
00105                                const Address&     a) { return kNotSupported; }
00111     virtual unsigned int Write(const Parameter&   p, 
00112                                const BlobValue&   v) { return kNotSupported; }
00120     virtual unsigned int Write(const Parameter&   p, 
00121                                const BlobValue&   v, 
00122                                const Address&     a) { return kNotSupported; }
00123 
00129     virtual unsigned int Read(const Parameter&   p, 
00130                               SingleValue&       v) = 0;
00138     virtual unsigned int Read(const Parameter&   p, 
00139                               const Address&     a,
00140                               SingleValue&       v) { return kNotSupported; }
00146     virtual unsigned int Read(const Parameter&   p, 
00147                               BlobValue&         v) { return kNotSupported; }
00155     virtual unsigned int Read(const Parameter&   p, 
00156                               const Address&     a,
00157                               BlobValue&         v) { return kNotSupported; }
00158   protected:
00167     static void Create(RcuDb::Server& s, const std::string& name, 
00168                        Parameter::Where dest, bool isBlob, 
00169                        unsigned int mask) throw(bool);    
00170   };
00171 
00172   //__________________________________________________________________
00177   class BusComponent : public Component 
00178   {
00179   public:
00181     BusComponent() {}
00183     virtual ~BusComponent() {}
00184 
00190     virtual unsigned int Write(const Parameter&   p, 
00191                                const SingleValue& v) 
00192     {
00193       return DoWrite(p, v, -1, 0, 0);
00194     }
00202     virtual unsigned int Write(const Parameter&   p, 
00203                                const SingleValue& v, 
00204                                const Address&     a)
00205     {
00206       return DoWrite(p, v, a.Board(), a.Chip(), a.Channel());
00207     }
00208 
00214     virtual unsigned int Read(const Parameter&   p, 
00215                               SingleValue&       v)
00216     {
00217       return DoRead(p, v, -1, 0, 0);
00218     }
00226     virtual unsigned int Read(const Parameter&   p, 
00227                               const Address&     a,
00228                               SingleValue&       v)
00229     {
00230       return DoRead(p, v, a.Board(), a.Chip(), a.Channel());
00231     }
00232 
00233   protected:
00235     virtual Rcuxx::AltroRegister* Name2Register(const std::string& name) = 0;
00237     virtual Rcuxx::AltroCommand* Name2Command(const std::string& name) = 0;
00246     virtual unsigned int DoWrite(const Parameter&   p, 
00247                                  const SingleValue& v, 
00248                                  int board, unsigned int chip, 
00249                                  unsigned int channel);
00258     virtual unsigned int DoRead(const Parameter&   p, 
00259                                 SingleValue&       v,
00260                                 int board, unsigned int chip, 
00261                                 unsigned int channel);
00262   };
00263 }
00264 #endif
00265 //
00266 // EOF
00267 //
00268 
00269   
Top of page Last update Fri Apr 27 01:54:15 2007
Copyright © 2004 Christian Holm Created by DoxyGen 1.3.5