PowerDefaults.cpp

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

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