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