00001 #include <config/ConfigObject.h>
00002 #include <config/Change.h>
00003 #include "Geography.h"
00004
00005
00006
00007 #include "Barrel.h"
00008
00009
00010 namespace SCTDAL {
00011 const std::string Geography::s_class_name("Geography");
00012
00013
00014
00015 Geography::Geography(::Configuration& db, ::ConfigObject& o) :
00016 DalObject(db, o) {
00017 }
00018
00019
00020 void Geography::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 Geography object:\n"
00027 << str << " id: \'" << UID() << "\', class name: \'" << class_name() << "\'\n";
00028 }
00029
00030
00031
00032
00033 if( m_barrels.empty() ) {
00034 s << str << " barrels value is empty\n";
00035 }
00036 else {
00037 s << str << " " << m_barrels.size() << " object(s) in barrels:\n";
00038 for(std::vector<const SCTDAL::Barrel*>::const_iterator i = m_barrels.begin(); i != m_barrels.end(); ++i) {
00039 (*i)->print(indent + 4, true, s);
00040 }
00041 }
00042 }
00043
00044
00045 std::ostream&
00046 operator<<(std::ostream& s, const Geography * obj)
00047 {
00048 s << '\'';
00049
00050 if(obj == 0) {
00051 s << "(null)";
00052 }
00053 else {
00054 obj->config_object().print_ptr(s);
00055 }
00056 s << '\'';
00057
00058 return s;
00059 }
00060
00061
00062 std::ostream&
00063 operator<<(std::ostream& s, const Geography & obj)
00064 {
00065 if(&obj == 0) {
00066 s << "(null)";
00067 }
00068 else {
00069 obj.print(0, true, s);
00070 }
00071
00072 return s;
00073 }
00074
00075
00076 void Geography::update(::Configuration& conf, const ::ConfigurationChange * change)
00077 {
00078 conf.update<Geography>(change->get_modified_objs(), change->get_removed_objs());
00079 }
00080
00081
00082 void Geography::reset(::Configuration& conf, bool re_initialise_obj)
00083 {
00084 conf.reset_objects<Geography>(re_initialise_obj);
00085 }
00086
00087
00088 void Geography::init(bool init_children)
00089 {
00090 p_was_read = true;
00091 increment_read();
00092 static const char * env = ::getenv("TDAQ_REPORT_DAL_OBJECT_READ");
00093 if(env) { std::cout << "DEBUG: read object " << this << std::endl; }
00094 p_db.ref<SCTDAL::Barrel>(p_obj, "barrels", m_barrels, init_children);
00095
00096 p_obj.clear();
00097 }
00098
00099 Geography::~Geography()
00100 {
00101 }
00102
00103 bool Geography::set_barrels(const std::vector<const SCTDAL::Barrel*>& a) {
00104 clear();
00105 std::vector<const ConfigObject*> v;
00106 for(std::vector<const SCTDAL::Barrel*>::const_iterator i = a.begin(); i != a.end(); ++i) {
00107 v.push_back(&((*i)->config_object()));
00108 }
00109 return p_obj.set_objs("barrels", v);
00110 }
00111
00112 }