ChannelMapping.cpp

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

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