20 std::ostringstream text;
21 text <<
"failed to " << op <<
' ' << what <<
" \"" << name <<
"\" of object " << o;
23 text <<
": " <<
error;
45 return m_obj->GetAttributeValue(name)->type;
58 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
64 value = *
reinterpret_cast<T*
>(&data->data);
80 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
85 data =
m_obj->GetAttributeValue(name);
94 std::ostringstream text;
95 text <<
"attribute \"" << name <<
"\" of object " <<
m_obj <<
" is not of a multi-value";
96 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str() );
100 for (
const auto& it : *data->data.LIST)
102 value.push_back(*
reinterpret_cast<T*
>(&it->data));
120 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
122 return m_obj->get_file()->get_full_file_name();
196 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
201 data =
m_obj->GetAttributeValue(name);
210 value = *data->data.STRING;
220 value = data->data.CLASS->get_name();
225 std::ostringstream text;
226 text <<
"read wrong attribute type instead of expected \'string\' for attribute \"" << name <<
"\" of object " <<
m_obj;
227 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str() );
236 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
241 data =
m_obj->GetRelationshipValue(name);
252 std::ostringstream text;
253 text <<
"referenced object " << *data <<
" is not loaded";
257 std::ostringstream text;
258 text <<
"bad value of relationship \"" << name <<
"\" of object " <<
m_obj <<
": ";
262 text <<
"the relationship is multi-value";
266 text <<
"non-object type was read";
268 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
271 if (data->data.OBJECT !=
nullptr)
352 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
357 data =
m_obj->GetAttributeValue(name);
366 std::ostringstream text;
367 text <<
"attribute \"" << name <<
"\" of object " <<
m_obj <<
" is not of a multi-value";
368 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
373 for (
const auto & it : *data->data.LIST)
377 value.emplace_back(*it->data.STRING);
381 value.emplace_back(it->data.CLASS->get_name());
385 value.emplace_back(it->str());
389 std::ostringstream text;
390 text <<
"wrong type of attribute \"" << name <<
"\" of object " <<
m_obj <<
" (instead of expected string)";
391 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str() );
398OksConfigObject::get(
const std::string& name, std::vector<dunedaq::conffwk::ConfigObject>& value)
402 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
416 std::ostringstream text;
417 text <<
"the value of relationship \"" << name <<
"\" of object " <<
m_obj <<
" is not multi-value";
418 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
423 for (
const auto& it : *
data->data.LIST)
427 TLOG_DEBUG(1) <<
"object " << *it <<
" is not loaded (relationship \'" << name <<
"\' of object " <<
m_obj <<
')' ;
429 else if (!it->data.OBJECT)
431 TLOG_DEBUG(1) <<
"skip (null) object in relationship \'" << name <<
"\' of object " <<
m_obj ;
435 value.push_back(conffwk::ConfigObject(
static_cast<OksConfiguration *
>(
m_impl)->new_object(it->data.OBJECT)));
443 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
451 if (di->relationship)
457 if (data->data.OBJECT !=
nullptr)
464 for (
const auto& it : *data->data.LIST)
486OksConfigObject::referenced_by(std::vector<conffwk::ConfigObject>& value,
const std::string& rname,
bool check_composite_only,
unsigned long ,
const std::vector<std::string> * )
const
490 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
493 if (check_composite_only)
495 bool any_name = (rname ==
"*");
497 if (
const std::list<OksRCR *> * rcr =
m_obj->reverse_composite_rels())
499 for (
const auto& i : *rcr)
501 if (any_name || rname == i->relationship->get_name())
512 for (
const auto& i : *objs)
531 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
537 m_obj->SetAttributeValue(name, &data);
539 catch (dunedaq::conffwk::Generic& ex)
552 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
558 m_obj->SetRelationshipValue(name, &data, skip_non_null_check);
560 catch (dunedaq::conffwk::Generic& ex)
585 for (
const auto& i : value)
587 d.data.LIST->push_back(
new OksData(i));
660 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
667 d.data.ENUMERATION = a->get_enum_value(value);
670 catch (std::exception& ex)
688 d.data.CLASS =
nullptr;
693 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
696 const std::list<OksAttribute *> * attrs =
m_obj->GetClass()->all_attributes();
698 if (!attrs || attrs->empty())
705 d.SetValue(value.c_str(), attrs->front());
724 d.SetValue(value.c_str(),
nullptr);
742 d.SetValue(value.c_str(),
nullptr);
831 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
836 for (
const auto& i : value)
843 d.data.LIST->push_back(d2);
845 catch (std::exception& ex)
869 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
872 const std::list<OksAttribute *> * attrs =
m_obj->GetClass()->all_attributes();
874 if (!attrs || attrs->empty())
879 for (
const auto& i : value)
887 d2->
SetValue(i.c_str(), attrs->front());
894 d.data.LIST->push_back(d2);
906 for (
const auto& i : value)
918 d.data.LIST->push_back(d2);
929 for (
const auto& i : value)
941 d.data.LIST->push_back(d2);
955OksConfigObject::set(
const std::string& name,
const std::vector<const conffwk::ConfigObject*>& value,
bool skip_non_null_check)
959 for (
const auto& i : value)
975 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
979 if (
OksFile * new_file_h =
m_obj->GetClass()->get_kernel()->find_data_file(at))
982 if (old_file_h != new_file_h)
988 m_obj->set_file(new_file_h,
false);
998 std::ostringstream text;
999 text <<
"file \"" << at <<
"\" is not loaded";
1000 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
1031 m_obj->set_id(new_id);
1035 std::ostringstream text;
1036 text <<
"cannot rename object " <<
m_obj <<
" to new name \'" << new_id <<
"\' because " << ex.
what();
1037 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,...)
CIB Buffer std::string descriptor Message from std::string descriptor CIB process error
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
const std::string * ENUMERATION