00001 #include <config/ConfigObject.h>
00002 #include <config/Change.h>
00003 #include "RodMUR.h"
00004
00005
00006
00007 #include "Channel.h"
00008 #include "RodModule.h"
00009 #include "RodRModule.h"
00010
00011
00012 namespace SCTDAL {
00013 const std::string RodMUR::s_class_name("RodMUR");
00014
00015
00016
00017 RodMUR::RodMUR(::Configuration& db, ::ConfigObject& o) :
00018 DalObject(db, o) {
00019 }
00020
00021
00022 void RodMUR::print(unsigned int indent, bool print_header, std::ostream& s) const
00023 {
00024 std::string str(indent, ' ');
00025
00026 if(print_header) {
00027 s
00028 << str << "SCTDAL RodMUR object:\n"
00029 << str << " id: \'" << UID() << "\', class name: \'" << class_name() << "\'\n";
00030 }
00031
00032
00033
00034
00035 s << str << " order: " << order() << std::endl;
00036 s << str << " id: " << id() << std::endl;
00037
00038
00039
00040
00041 if( m_channels.empty() ) {
00042 s << str << " channels value is empty\n";
00043 }
00044 else {
00045 s << str << " " << m_channels.size() << " object(s) in channels:\n";
00046 for(std::vector<const SCTDAL::Channel*>::const_iterator i = m_channels.begin(); i != m_channels.end(); ++i) {
00047 (*i)->print(indent + 4, true, s);
00048 }
00049 }
00050 if( m_rodModules.empty() ) {
00051 s << str << " rodModules value is empty\n";
00052 }
00053 else {
00054 s << str << " " << m_rodModules.size() << " object(s) in rodModules:\n";
00055 for(std::vector<const SCTDAL::RodModule*>::const_iterator i = m_rodModules.begin(); i != m_rodModules.end(); ++i) {
00056 (*i)->print(indent + 4, true, s);
00057 }
00058 }
00059 if( m_rodRModules.empty() ) {
00060 s << str << " rodRModules value is empty\n";
00061 }
00062 else {
00063 s << str << " " << m_rodRModules.size() << " object(s) in rodRModules:\n";
00064 for(std::vector<const SCTDAL::RodRModule*>::const_iterator i = m_rodRModules.begin(); i != m_rodRModules.end(); ++i) {
00065 (*i)->print(indent + 4, true, s);
00066 }
00067 }
00068 }
00069
00070
00071 std::ostream&
00072 operator<<(std::ostream& s, const RodMUR * obj)
00073 {
00074 s << '\'';
00075
00076 if(obj == 0) {
00077 s << "(null)";
00078 }
00079 else {
00080 obj->config_object().print_ptr(s);
00081 }
00082 s << '\'';
00083
00084 return s;
00085 }
00086
00087
00088 std::ostream&
00089 operator<<(std::ostream& s, const RodMUR & obj)
00090 {
00091 if(&obj == 0) {
00092 s << "(null)";
00093 }
00094 else {
00095 obj.print(0, true, s);
00096 }
00097
00098 return s;
00099 }
00100
00101
00102 void RodMUR::update(::Configuration& conf, const ::ConfigurationChange * change)
00103 {
00104 conf.update<RodMUR>(change->get_modified_objs(), change->get_removed_objs());
00105 }
00106
00107
00108 void RodMUR::reset(::Configuration& conf, bool re_initialise_obj)
00109 {
00110 conf.reset_objects<RodMUR>(re_initialise_obj);
00111 }
00112
00113
00114 void RodMUR::init(bool init_children)
00115 {
00116 p_was_read = true;
00117 increment_read();
00118 static const char * env = ::getenv("TDAQ_REPORT_DAL_OBJECT_READ");
00119 if(env) { std::cout << "DEBUG: read object " << this << std::endl; }
00120
00121 if(!p_obj.get("order",m_order)) {
00122 std::cerr << "ERROR: could not find attribute 'order'\n";
00123 }
00124 else {
00125 p_db.convert(m_order, p_obj, "order");
00126 }
00127
00128 if(!p_obj.get("id",m_id)) {
00129 std::cerr << "ERROR: could not find attribute 'id'\n";
00130 }
00131 else {
00132 p_db.convert(m_id, p_obj, "id");
00133 }
00134 p_db.ref<SCTDAL::Channel>(p_obj, "channels", m_channels, init_children);
00135 p_db.ref<SCTDAL::RodModule>(p_obj, "rodModules", m_rodModules, init_children);
00136 p_db.ref<SCTDAL::RodRModule>(p_obj, "rodRModules", m_rodRModules, init_children);
00137
00138 p_obj.clear();
00139 }
00140
00141 RodMUR::~RodMUR()
00142 {
00143 }
00144
00145 bool RodMUR::set_channels(const std::vector<const SCTDAL::Channel*>& a) {
00146 clear();
00147 std::vector<const ConfigObject*> v;
00148 for(std::vector<const SCTDAL::Channel*>::const_iterator i = a.begin(); i != a.end(); ++i) {
00149 v.push_back(&((*i)->config_object()));
00150 }
00151 return p_obj.set_objs("channels", v);
00152 }
00153
00154 bool RodMUR::set_rodModules(const std::vector<const SCTDAL::RodModule*>& a) {
00155 clear();
00156 std::vector<const ConfigObject*> v;
00157 for(std::vector<const SCTDAL::RodModule*>::const_iterator i = a.begin(); i != a.end(); ++i) {
00158 v.push_back(&((*i)->config_object()));
00159 }
00160 return p_obj.set_objs("rodModules", v);
00161 }
00162
00163 bool RodMUR::set_rodRModules(const std::vector<const SCTDAL::RodRModule*>& a) {
00164 clear();
00165 std::vector<const ConfigObject*> v;
00166 for(std::vector<const SCTDAL::RodRModule*>::const_iterator i = a.begin(); i != a.end(); ++i) {
00167 v.push_back(&((*i)->config_object()));
00168 }
00169 return p_obj.set_objs("rodRModules", v);
00170 }
00171
00172 }