RodRModule.cpp

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

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