00001 #ifndef EVENT_LOOP_ALGS__WHITE_BOARD_SVC_H
00002 #define EVENT_LOOP_ALGS__WHITE_BOARD_SVC_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00017
00018
00019
00020 #include <EventLoopAlgs/Global.h>
00021
00022 #include <EventLoop/Algorithm.h>
00023
00024 namespace EL
00025 {
00032 WhiteBoardSvc *getWhiteBoardSvc (Worker *worker);
00033
00034
00035
00036 class WhiteBoardSvc : public EL::Algorithm
00037 {
00038
00039
00040
00041
00044 public:
00045 void testInvariant () const;
00046
00047
00054 public:
00055 WhiteBoardSvc ();
00056
00057
00061 public:
00062 bool hasVar (const std::string& name) const;
00063
00064
00071 public:
00072 float getFloat (const std::string& name) const;
00073 void getArray (const std::string& name, std::size_t& size,
00074 const float*& values) const;
00075 TObject *getTObject (const std::string& name) const;
00076
00077
00083 public:
00084 template<class T> T *retrieve (const std::string& name) const;
00085
00086
00093 public:
00094 void setFloat (const std::string& name, float value);
00095 void setArray (const std::string& name, const std::vector<float>& value);
00096 void setArray (const std::string& name, std::size_t size,
00097 const float *values);
00098 void setTObject (TObject *object, bool swallow = true);
00099
00100
00101
00102
00103
00104
00105
00108 public:
00109 virtual const char *GetName () const;
00110
00111
00112
00113
00114
00115
00116
00121 private:
00122 virtual bool doHasVar (const std::string& name) const;
00123
00124
00132 private:
00133 virtual float doGetFloat (const std::string& name) const;
00134 virtual void doGetArray (const std::string& name, std::size_t& size,
00135 const float*& values) const;
00136 virtual TObject *doGetTObject (const std::string& name) const;
00137
00138
00146 private:
00147 virtual void doSetFloat (const std::string& name, float value);
00148 virtual void doSetArray (const std::string& name, std::size_t size,
00149 const float *values);
00150 virtual void doSetTObject (TObject *object, bool swallow);
00151
00152
00153
00154
00155
00156
00157
00158 ClassDef(WhiteBoardSvc, 1);
00159 };
00160 }
00161
00162 #include <RootCoreUtils/Assert.h>
00163
00164 namespace EL
00165 {
00166
00167
00168
00169
00170 template<class T> T *WhiteBoardSvc ::
00171 retrieve (const std::string& name) const
00172 {
00174 T *const result = dynamic_cast<T*>(getTObject (name));
00175 RCU_ASSERT2_SOFT (result != 0, "object not of correct type");
00176 return result;
00177 }
00178 }
00179
00180 #endif