27 std::ostringstream text;
28 text <<
"failed to " << op <<
' ' << what <<
" \"" << name <<
"\" of object " << o;
30 text <<
": " <<
error;
52 return m_obj->GetAttributeValue(name)->type;
65 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
71 value = *
reinterpret_cast<T*
>(&data->data);
87 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
92 data =
m_obj->GetAttributeValue(name);
101 std::ostringstream text;
102 text <<
"attribute \"" << name <<
"\" of object " <<
m_obj <<
" is not of a multi-value";
103 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str() );
107 for (
const auto& it : *data->data.LIST)
109 value.push_back(*
reinterpret_cast<T*
>(&it->data));
127 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
129 return m_obj->get_file()->get_full_file_name();
203 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
208 data =
m_obj->GetAttributeValue(name);
217 value = *data->data.STRING;
227 value = data->data.CLASS->get_name();
232 std::ostringstream text;
233 text <<
"read wrong attribute type instead of expected \'string\' for attribute \"" << name <<
"\" of object " <<
m_obj;
234 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str() );
243 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
248 data =
m_obj->GetRelationshipValue(name);
259 std::ostringstream text;
260 text <<
"referenced object " << *data <<
" is not loaded";
264 std::ostringstream text;
265 text <<
"bad value of relationship \"" << name <<
"\" of object " <<
m_obj <<
": ";
269 text <<
"the relationship is multi-value";
273 text <<
"non-object type was read";
275 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
278 if (data->data.OBJECT !=
nullptr)
359 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
364 data =
m_obj->GetAttributeValue(name);
373 std::ostringstream text;
374 text <<
"attribute \"" << name <<
"\" of object " <<
m_obj <<
" is not of a multi-value";
375 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
380 for (
const auto & it : *data->data.LIST)
384 value.emplace_back(*it->data.STRING);
388 value.emplace_back(it->data.CLASS->get_name());
392 value.emplace_back(it->str());
396 std::ostringstream text;
397 text <<
"wrong type of attribute \"" << name <<
"\" of object " <<
m_obj <<
" (instead of expected string)";
398 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str() );
405OksConfigObject::get(
const std::string& name, std::vector<dunedaq::conffwk::ConfigObject>& value)
409 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
423 std::ostringstream text;
424 text <<
"the value of relationship \"" << name <<
"\" of object " <<
m_obj <<
" is not multi-value";
425 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
430 for (
const auto& it : *
data->data.LIST)
434 TLOG_DEBUG(1) <<
"object " << *it <<
" is not loaded (relationship \'" << name <<
"\' of object " <<
m_obj <<
')' ;
436 else if (!it->data.OBJECT)
438 TLOG_DEBUG(1) <<
"skip (null) object in relationship \'" << name <<
"\' of object " <<
m_obj ;
442 value.push_back(conffwk::ConfigObject(
static_cast<OksConfiguration *
>(
m_impl)->new_object(it->data.OBJECT)));
450 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
458 if (di->relationship)
464 if (data->data.OBJECT !=
nullptr)
471 for (
const auto& it : *data->data.LIST)
493OksConfigObject::referenced_by(std::vector<conffwk::ConfigObject>& value,
const std::string& rname,
bool check_composite_only,
unsigned long ,
const std::vector<std::string> * )
const
497 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
500 if (check_composite_only)
502 bool any_name = (rname ==
"*");
504 if (
const std::list<OksRCR *> * rcr =
m_obj->reverse_composite_rels())
506 for (
const auto& i : *rcr)
508 if (any_name || rname == i->relationship->get_name())
519 for (
const auto& i : *objs)
538 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
544 m_obj->SetAttributeValue(name, &data);
546 catch (dunedaq::conffwk::Generic& ex)
559 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
565 m_obj->SetRelationshipValue(name, &data, skip_non_null_check);
567 catch (dunedaq::conffwk::Generic& ex)
592 for (
const auto& i : value)
594 d.data.LIST->push_back(
new OksData(i));
667 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
674 d.data.ENUMERATION = a->get_enum_value(value);
677 catch (std::exception& ex)
695 d.data.CLASS =
nullptr;
700 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
703 const std::list<OksAttribute *> * attrs =
m_obj->GetClass()->all_attributes();
705 if (!attrs || attrs->empty())
712 d.SetValue(value.c_str(), attrs->front());
731 d.SetValue(value.c_str(),
nullptr);
749 d.SetValue(value.c_str(),
nullptr);
838 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
843 for (
const auto& i : value)
850 d.data.LIST->push_back(d2);
852 catch (std::exception& ex)
876 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
879 const std::list<OksAttribute *> * attrs =
m_obj->GetClass()->all_attributes();
881 if (!attrs || attrs->empty())
886 for (
const auto& i : value)
894 d2->
SetValue(i.c_str(), attrs->front());
901 d.data.LIST->push_back(d2);
913 for (
const auto& i : value)
925 d.data.LIST->push_back(d2);
936 for (
const auto& i : value)
948 d.data.LIST->push_back(d2);
962OksConfigObject::set(
const std::string& name,
const std::vector<const conffwk::ConfigObject*>& value,
bool skip_non_null_check)
966 for (
const auto& i : value)
982 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
986 if (
OksFile * new_file_h =
m_obj->GetClass()->get_kernel()->find_data_file(at))
989 if (old_file_h != new_file_h)
995 m_obj->set_file(new_file_h,
false);
1005 std::ostringstream text;
1006 text <<
"file \"" << at <<
"\" is not loaded";
1007 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
1038 m_obj->set_id(new_id);
1042 std::ostringstream text;
1043 text <<
"cannot rename object " <<
m_obj <<
" to new name \'" << new_id <<
"\' because " << ex.
what();
1044 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
static std::string mk_error_text(const char *op, const char *what, const std::string &name, const OksObject *o, const char *error)
static std::string mk_get_error_text(const char *what, const std::string &name, const OksObject *o, const char *error=nullptr)
static std::string mk_set_error_text(const char *what, const std::string &name, const OksObject *o, const char *error=nullptr)
dunedaq::conffwk::ObjectState m_state
const std::string * m_class_name
void throw_if_deleted() const
ConfigObjectImpl(ConfigurationImpl *impl, const std::string &id, dunedaq::conffwk::ObjectState state=dunedaq::conffwk::Valid) noexcept
The constructor stores configuration implementation pointer.
ConfigurationImpl * m_impl
Represents database objects.
const ConfigObjectImpl * implementation() const noexcept
Returns pointer on implementation.
Provides pure virtual interface used by the Configuration class.
Provides interface to the OKS XML schema and data files.
OksObject describes instance of OksClass.
OksData * GetRelationshipValue(const std::string &) const
Get value of relationship by name.
std::list< OksObject *, boost::fast_pool_allocator< OksObject * > > FList
virtual const char * what() const noexcept
void set_vector(const std::string &name, const std::vector< T > &value)
virtual const std::string contained_in() const
Virtual method to get object's database file name.
virtual void set_date(const std::string &attribute, const std::string &value)
Virtual method to set date attribute value.
void set_value(const std::string &name, const T &value)
virtual void set_enum(const std::string &attribute, const std::string &value)
Virtual method to set enumeration attribute value.
virtual void set(const std::string &name, bool value)
Virtual method to set boolean attribute value.
virtual void move(const std::string &at)
Virtual method to move object to a file.
virtual ~OksConfigObject() noexcept
void set_attr_value(const std::string &name, oks::OksData &value)
virtual void set_class(const std::string &attribute, const std::string &value)
Virtual method to set enumeration attribute value.
void set_rel_value(const std::string &name, oks::OksData &value, bool skip_non_null_check)
void get_value(const std::string &name, T &value)
void get_vector(const std::string &name, std::vector< T > &value)
virtual void set_time(const std::string &attribute, const std::string &value)
Virtual method to set time attribute value.
virtual void referenced_by(std::vector< conffwk::ConfigObject > &value, const std::string &association, bool check_composite_only, unsigned long rlevel, const std::vector< std::string > *rclasses) const
oks::OksData::Type get_type(const std::string &attribute) const
virtual void get(const std::string &name, bool &value)
Virtual method to read boolean attribute value.
virtual void rename(const std::string &new_id)
Virtual method to change object ID.
virtual bool rel(const std::string &name, std::vector< conffwk::ConfigObject > &value)
OksConfigObject(oks::OksObject *obj, conffwk::ConfigurationImpl *impl) noexcept
friend class OksConfiguration
virtual void reset()
Virtual method to reset the implementation object from unknown state.
#define TLOG_DEBUG(lvl,...)
Struct OKS data information.
the structure to pass common parameters to various read() methods of OksData and OksObject class
union dunedaq::oks::OksData::Data data
std::list< OksData *, boost::fast_pool_allocator< OksData * > > List
void SetValue(const char *s, const OksAttribute *a)
enum dunedaq::oks::OksData::Type type
Factory couldn t std::string alg_name Invalid configuration error
const std::string * ENUMERATION