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