SCT_Module.cpp

00001 #include <config/ConfigObject.h>
00002 #include <config/Change.h>
00003 #include "SCT_Module.h"
00004 
00005 // include files for classes used in relationships
00006 
00007 #include "SCT_Chip.h"
00008 
00009 
00010 namespace SCTDAL {
00011   const std::string SCT_Module::s_class_name("SCT_Module");
00012 
00013     // the constructor
00014 
00015   SCT_Module::SCT_Module(::Configuration& db, ::ConfigObject& o) :
00016     DalObject(db, o)  {
00017   }
00018 
00019 
00020   void SCT_Module::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 SCT_Module object:\n"
00027         << str << "  id: \'" << UID() << "\', class name: \'" << class_name() << "\'\n";
00028     }
00029 
00030 
00031       // print direct attributes
00032 
00033     s << str << "  sn: " << sn() << std::endl;
00034     s << str << "  source: " << source() << std::endl;
00035     s << str << "  location: " << location() << std::endl;
00036     s << str << "  active: " << active() << std::endl;
00037     s << str << "  select: " << select() << std::endl;
00038 
00039 
00040       // print direct relationships
00041 
00042     if( m_Chips.empty() ) {
00043       s << str << "  Chips value is empty\n";
00044     }
00045     else {
00046       s << str << "  " << m_Chips.size() << " object(s) in Chips:\n";
00047       for(std::vector<const SCTDAL::SCT_Chip*>::const_iterator i = m_Chips.begin(); i != m_Chips.end(); ++i) {
00048         (*i)->print(indent + 4, true, s);
00049       }
00050       }
00051   }
00052 
00053 
00054   std::ostream&
00055   operator<<(std::ostream& s, const SCT_Module * obj)
00056   {
00057     s << '\'';
00058 
00059     if(obj == 0) {
00060       s << "(null)";
00061     }
00062     else {
00063       obj->config_object().print_ptr(s);
00064     }
00065     s << '\'';
00066 
00067     return s;
00068   }
00069 
00070 
00071   std::ostream&
00072   operator<<(std::ostream& s, const SCT_Module & obj)
00073   {
00074     if(&obj == 0) {
00075       s << "(null)";
00076     }
00077     else {
00078       obj.print(0, true, s);
00079     }
00080 
00081     return s;
00082   }
00083 
00084 
00085   void SCT_Module::update(::Configuration& conf, const ::ConfigurationChange * change)
00086   {
00087     conf.update<SCT_Module>(change->get_modified_objs(), change->get_removed_objs());
00088   }
00089 
00090 
00091   void SCT_Module::reset(::Configuration& conf, bool re_initialise_obj)
00092   {
00093     conf.reset_objects<SCT_Module>(re_initialise_obj);
00094   }
00095 
00096 
00097   void SCT_Module::init(bool init_children)
00098   {
00099     p_was_read = true;
00100     increment_read();
00101     static const char * env = ::getenv("TDAQ_REPORT_DAL_OBJECT_READ");
00102     if(env) { std::cout << "DEBUG: read object " << this << std::endl; }
00103 
00104     if(!p_obj.get("sn",m_sn)) {
00105       std::cerr << "ERROR: could not find attribute 'sn'\n";
00106     }
00107     else {
00108       p_db.convert(m_sn, p_obj, "sn");
00109     }
00110 
00111     if(!p_obj.get("source",m_source)) {
00112       std::cerr << "ERROR: could not find attribute 'source'\n";
00113     }
00114     else {
00115       p_db.convert(m_source, p_obj, "source");
00116     }
00117 
00118     if(!p_obj.get("location",m_location)) {
00119       std::cerr << "ERROR: could not find attribute 'location'\n";
00120     }
00121     else {
00122       p_db.convert(m_location, p_obj, "location");
00123     }
00124 
00125     if(!p_obj.get("active",m_active)) {
00126       std::cerr << "ERROR: could not find attribute 'active'\n";
00127     }
00128     else {
00129       p_db.convert(m_active, p_obj, "active");
00130     }
00131 
00132     if(!p_obj.get("select",m_select)) {
00133       std::cerr << "ERROR: could not find attribute 'select'\n";
00134     }
00135     else {
00136       p_db.convert(m_select, p_obj, "select");
00137     }
00138     p_db.ref<SCTDAL::SCT_Chip>(p_obj, "Chips", m_Chips, init_children);
00139 
00140     p_obj.clear(); // clear resources used by implementation
00141   }
00142 
00143   SCT_Module::~SCT_Module()
00144   {
00145   }
00146 
00147   bool SCT_Module::set_Chips(const std::vector<const SCTDAL::SCT_Chip*>& a) {
00148     clear();
00149     std::vector<const ConfigObject*> v;
00150     for(std::vector<const SCTDAL::SCT_Chip*>::const_iterator i = a.begin(); i != a.end(); ++i) {
00151       v.push_back(&((*i)->config_object()));
00152     }
00153     return p_obj.set_objs("Chips", v);
00154   }
00155 
00156 }

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