#ifndef LOp9uF4R8c3Nq3YZQrpOlN8rCLE #define LOp9uF4R8c3Nq3YZQrpOlN8rCLE #include #include #include #include "mempool.hpp" using std::string; template struct Scalar { explicit Scalar(const string name); inline T & operator() () const; inline T get() const; inline void set(const T value) const; void sync() const; // associated memory container MemPool mem; BOOST_STATIC_ASSERT((width > 0)); private: // Scalar(); }; // Implementation template Scalar::Scalar(const string name) : mem((width + 7) / 8, name) { } template inline T & Scalar::operator() () const { return *((T*) mem()); } template inline T Scalar::get() const { return (*this)(); } template inline void Scalar::set(const T value) const { // only a single value is in a scalar so we do not require bit-level // access (*this)() = value; } template void Scalar::sync() const { mem.sync(); } #endif // LOp9uF4R8c3Nq3YZQrpOlN8rCLE