20 std::ostringstream text;
21 text <<
"failed to " << op <<
' ' << what <<
" \"" << name <<
"\" of object " << o;
23 text <<
": " <<
error;
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);
94 std::ostringstream text;
95 text <<
"attribute \"" << name <<
"\" of object " <<
m_obj <<
" is not of a multi-value";
100 for (
const auto& it : *data->data.LIST)
102 value.push_back(*
reinterpret_cast<T*
>(&it->data));
108 ConfigObjectImpl (impl, obj->GetId()),
120 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
196 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
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;
236 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
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";
271 if (data->data.OBJECT !=
nullptr)
352 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
366 std::ostringstream text;
367 text <<
"attribute \"" << name <<
"\" of object " <<
m_obj <<
" is not of a multi-value";
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)";
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";
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 ;
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 ==
"*");
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);
552 std::lock_guard<std::mutex> scoped_lock(
m_mutex);
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);
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);
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);
982 if (old_file_h != new_file_h)
998 std::ostringstream text;
999 text <<
"file \"" << at <<
"\" is not loaded";
1035 std::ostringstream text;
1036 text <<
"cannot rename object " <<
m_obj <<
" to new name \'" << new_id <<
"\' because " << ex.
what();
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
ConfigurationImpl * m_impl
Represents database objects.
const ConfigObjectImpl * implementation() const noexcept
Returns pointer on implementation.
Provides pure virtual interface used by the Configuration class.
Generic configuration exception.
OksDataInfo * get_data_info(const std::string &s) const noexcept
Get OKS data information for attribute or relationship.
const std::list< OksAttribute * > * all_attributes() const noexcept
OksKernel * get_kernel() const noexcept
OksAttribute * find_attribute(const std::string &name) const noexcept
Find attribute (search in this and base classes).
Provides interface to the OKS XML schema and data files.
const std::string & get_full_file_name() const
OksFile * find_data_file(const std::string &s) const
Finds OKS data file.
OksObject describes instance of OksClass.
const std::list< OksRCR * > * reverse_composite_rels() const
Return information about composite parents. The method returns list of the OKS object's reverse compo...
OksData * GetRelationshipValue(const std::string &) const
Get value of relationship by name.
OksFile * get_file() const
void SetRelationshipValue(const std::string &name, OksData *data, bool skip_non_null_check=false)
Set value of relationship by name.
void set_file(OksFile *file, bool update_owner=true)
Move object to different file.
FList * get_all_rels(const std::string &name="*") const
Return objects referencing this one via relationship with given name.
const OksClass * GetClass() const
void set_id(const std::string &id)
Set object ID.
void SetAttributeValue(const std::string &name, OksData *data)
Set value of attribute by name.
std::list< OksObject *, boost::fast_pool_allocator< OksObject * > > FList
OksData * GetAttributeValue(const std::string &name) const
Get value of attribute by name.
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
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