PowerParam.cpp

00001 #include <config/ConfigObject.h>
00002 #include <config/Change.h>
00003 #include "PowerParam.h"
00004 
00005 namespace SCTDAL {
00006   const std::string PowerParam::s_class_name("PowerParam");
00007 
00008     // the constructor
00009 
00010   PowerParam::PowerParam(::Configuration& db, ::ConfigObject& o) :
00011     DalObject(db, o)  {
00012   }
00013 
00014 
00015   void PowerParam::print(unsigned int indent, bool print_header, std::ostream& s) const
00016   {
00017     std::string str(indent, ' ');
00018 
00019     if(print_header) {
00020       s
00021         << str << "SCTDAL PowerParam object:\n"
00022         << str << "  id: \'" << UID() << "\', class name: \'" << class_name() << "\'\n";
00023     }
00024 
00025 
00026       // print direct attributes
00027 
00028     s << str << "  state: " << state() << std::endl;
00029     s << str << "  name: " << name() << std::endl;
00030     s << str << "  value: " << value() << std::endl;
00031     s << str << "  loAlarm: " << loAlarm() << std::endl;
00032     s << str << "  loWarn: " << loWarn() << std::endl;
00033     s << str << "  hiWarn: " << hiWarn() << std::endl;
00034     s << str << "  hiAlarm: " << hiAlarm() << std::endl;
00035   }
00036 
00037 
00038   std::ostream&
00039   operator<<(std::ostream& s, const PowerParam * obj)
00040   {
00041     s << '\'';
00042 
00043     if(obj == 0) {
00044       s << "(null)";
00045     }
00046     else {
00047       obj->config_object().print_ptr(s);
00048     }
00049     s << '\'';
00050 
00051     return s;
00052   }
00053 
00054 
00055   std::ostream&
00056   operator<<(std::ostream& s, const PowerParam & obj)
00057   {
00058     if(&obj == 0) {
00059       s << "(null)";
00060     }
00061     else {
00062       obj.print(0, true, s);
00063     }
00064 
00065     return s;
00066   }
00067 
00068 
00069   void PowerParam::update(::Configuration& conf, const ::ConfigurationChange * change)
00070   {
00071     conf.update<PowerParam>(change->get_modified_objs(), change->get_removed_objs());
00072   }
00073 
00074 
00075   void PowerParam::reset(::Configuration& conf, bool re_initialise_obj)
00076   {
00077     conf.reset_objects<PowerParam>(re_initialise_obj);
00078   }
00079 
00080 
00081   void PowerParam::init(bool /* init_children */)
00082   {
00083     p_was_read = true;
00084     increment_read();
00085     static const char * env = ::getenv("TDAQ_REPORT_DAL_OBJECT_READ");
00086     if(env) { std::cout << "DEBUG: read object " << this << std::endl; }
00087 
00088     if(!p_obj.get("state",m_state)) {
00089       std::cerr << "ERROR: could not find attribute 'state'\n";
00090     }
00091     else {
00092       p_db.convert(m_state, p_obj, "state");
00093     }
00094 
00095     if(!p_obj.get("name",m_name)) {
00096       std::cerr << "ERROR: could not find attribute 'name'\n";
00097     }
00098     else {
00099       p_db.convert(m_name, p_obj, "name");
00100     }
00101 
00102     if(!p_obj.get("value",m_value)) {
00103       std::cerr << "ERROR: could not find attribute 'value'\n";
00104     }
00105     else {
00106       p_db.convert(m_value, p_obj, "value");
00107     }
00108 
00109     if(!p_obj.get("loAlarm",m_loAlarm)) {
00110       std::cerr << "ERROR: could not find attribute 'loAlarm'\n";
00111     }
00112     else {
00113       p_db.convert(m_loAlarm, p_obj, "loAlarm");
00114     }
00115 
00116     if(!p_obj.get("loWarn",m_loWarn)) {
00117       std::cerr << "ERROR: could not find attribute 'loWarn'\n";
00118     }
00119     else {
00120       p_db.convert(m_loWarn, p_obj, "loWarn");
00121     }
00122 
00123     if(!p_obj.get("hiWarn",m_hiWarn)) {
00124       std::cerr << "ERROR: could not find attribute 'hiWarn'\n";
00125     }
00126     else {
00127       p_db.convert(m_hiWarn, p_obj, "hiWarn");
00128     }
00129 
00130     if(!p_obj.get("hiAlarm",m_hiAlarm)) {
00131       std::cerr << "ERROR: could not find attribute 'hiAlarm'\n";
00132     }
00133     else {
00134       p_db.convert(m_hiAlarm, p_obj, "hiAlarm");
00135     }
00136 
00137     p_obj.clear(); // clear resources used by implementation
00138   }
00139 
00140   PowerParam::~PowerParam()
00141   {
00142   }
00143 
00144 }

Generated on Mon Feb 6 14:01:24 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6