00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00044 namespace RcuDb
00045 {
00046 class Server;
00047 }
00048
00049 namespace RcuConf
00050 {
00053
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
00267
00268
00269