#ifndef FACT_DimDescriptionService #define FACT_DimDescriptionService #include #include class DimService; class DimDescriptionService { static int fCount; /// Counter to count the number of instatiations static DimService *fService; /// Pointer to the DimService distributing the desscriptions static std::string fData; /// Data to be distributed with the service std::string fDescription; /// Local storage for the applied description public: DimDescriptionService(const std::string &name, const std::string &format); virtual ~DimDescriptionService(); std::string GetDescription() const { return fDescription; } }; #include "dis.hxx" class DimDescribedService : public DimDescriptionService, public DimService { public: template DimDescribedService(const std::string &name, const T &val, const char *desc) : DimDescriptionService(name.c_str(), desc), DimService(name.c_str(), const_cast(val)) { } template DimDescribedService(const std::string &name, const char *format, const T &val, const char *desc) : DimDescriptionService(name.c_str(), desc), DimService(name.c_str(), format, const_cast(&val), sizeof(T)) { } DimDescribedService(const std::string &name, const char *format, const char *desc) : DimDescriptionService(name.c_str(), desc), DimService(name.c_str(), format, (void*)NULL, 0) { // FIXME: compare number of ; with number of | } template void Update(const T &data) { //cout << "Update: " << svc.getName() << " (" << sizeof(T) << ")" << endl; setData(const_cast(&data), sizeof(T)); updateService(); } template void Update(const std::vector &data) { //std::cout << "Update: " << getName() << " " << data.size() << " " << sizeof(T) << std::endl; setData(const_cast(data.data()), data.size()*sizeof(T)); updateService(); } // FIXME: Implement callback with boost::function instead of Pointer to this }; #endif