Row.cpp

00001 #include <config/ConfigObject.h>
00002 #include <config/Change.h>
00003 #include "Row.h"
00004 
00005 // include files for classes used in relationships
00006 
00007 #include "GeographyMUR.h"
00008 
00009 
00010 namespace SCTDAL {
00011   const std::string Row::s_class_name("Row");
00012 
00013     // the constructor
00014 
00015   Row::Row(::Configuration& db, ::ConfigObject& o) :
00016     DalObject(db, o)  {
00017   }
00018 
00019 
00020   void Row::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 Row object:\n"
00027         << str << "  id: \'" << UID() << "\', class name: \'" << class_name() << "\'\n";
00028     }
00029 
00030 
00031       // print direct attributes
00032 
00033     s << str << "  id: " << id() << std::endl;
00034 
00035 
00036       // print direct relationships
00037 
00038     if( m_murs.empty() ) {
00039       s << str << "  murs value is empty\n";
00040     }
00041     else {
00042       s << str << "  " << m_murs.size() << " object(s) in murs:\n";
00043       for(std::vector<const SCTDAL::GeographyMUR*>::const_iterator i = m_murs.begin(); i != m_murs.end(); ++i) {
00044         (*i)->print(indent + 4, true, s);
00045       }
00046       }
00047   }
00048 
00049 
00050   std::ostream&
00051   operator<<(std::ostream& s, const Row * 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 Row & 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 Row::update(::Configuration& conf, const ::ConfigurationChange * change)
00082   {
00083     conf.update<Row>(change->get_modified_objs(), change->get_removed_objs());
00084   }
00085 
00086 
00087   void Row::reset(::Configuration& conf, bool re_initialise_obj)
00088   {
00089     conf.reset_objects<Row>(re_initialise_obj);
00090   }
00091 
00092 
00093   void Row::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("id",m_id)) {
00101       std::cerr << "ERROR: could not find attribute 'id'\n";
00102     }
00103     else {
00104       p_db.convert(m_id, p_obj, "id");
00105     }
00106     p_db.ref<SCTDAL::GeographyMUR>(p_obj, "murs", m_murs, init_children);
00107 
00108     p_obj.clear(); // clear resources used by implementation
00109   }
00110 
00111   Row::~Row()
00112   {
00113   }
00114 
00115   bool Row::set_murs(const std::vector<const SCTDAL::GeographyMUR*>& a) {
00116     clear();
00117     std::vector<const ConfigObject*> v;
00118     for(std::vector<const SCTDAL::GeographyMUR*>::const_iterator i = a.begin(); i != a.end(); ++i) {
00119       v.push_back(&((*i)->config_object()));
00120     }
00121     return p_obj.set_objs("murs", v);
00122   }
00123 
00124 }

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