15#ifndef CONFFWK_CONFIGOBJECT_H_
16#define CONFFWK_CONFIGOBJECT_H_
119 bool operator==(const
ConfigObject& other) const noexcept;
123 template <typename T>
126 this->
get(attrname, attrval);
130 template <
typename T>
132 std::vector<T> attrvals;
133 this->
get(attrname, attrvals);
137 template <
typename T>
190 return (
m_impl ==
nullptr);
201 return (
m_impl->is_deleted());
225 const std::string&
UID() const noexcept {
return m_impl->m_id; }
258 return m_impl->contained_in();
285 template<
class T>
void get(
const std::string& name, T& value) {
287 m_impl->convert(value, *
this, name);
304 rel(
const std::string& name, std::vector<ConfigObject>& value)
306 if (
m_impl->rel(name, value))
308 m_impl->convert(value, *
this, name);
335 const std::string& relationship_name =
"*",
336 bool check_composite_only =
true,
337 unsigned long rlevel = 0,
338 const std::vector<std::string> * rclasses =
nullptr )
const {
339 m_impl->referenced_by(value, relationship_name, check_composite_only, rlevel, rclasses);
357 m_impl->set(name, o, skip_non_null_check);
372 void set_objs(
const std::string& name,
const std::vector<const ConfigObject*> & o,
bool skip_non_null_check =
false) {
373 m_impl->set(name, o, skip_non_null_check);
398 template<
class T>
void set_by_val(
const std::string& name, T value) {
419 template<
class T>
void set_by_ref(
const std::string& name, T& value) {
436 void set_enum(
const std::string& name,
const std::string& value) {
437 m_impl->set_enum(name, value);
453 void set_class(
const std::string& name,
const std::string& value) {
454 m_impl->set_class(name, value);
470 void set_date(
const std::string& name,
const std::string& value) {
471 m_impl->set_date(name, value);
487 void set_time(
const std::string& name,
const std::string& value) {
488 m_impl->set_time(name, value);
504 void set_enum(
const std::string& name,
const std::vector<std::string>& value) {
505 m_impl->set_enum(name, value);
521 void set_class(
const std::string& name,
const std::vector<std::string>& value) {
522 m_impl->set_class(name, value);
538 void set_date(
const std::string& name,
const std::vector<std::string>& value) {
539 m_impl->set_date(name, value);
555 void set_time(
const std::string& name,
const std::vector<std::string>& value) {
556 m_impl->set_time(name, value);
571 void move(
const std::string& at) {
587 rename(
const std::string& new_id);
594 void print_ptr(std::ostream& s)
const noexcept;
604 const std::string& prefix =
"",
605 bool show_contained_in =
false
Implements database objects.
Represents database objects.
void set_time(const std::string &name, const std::string &value)
Set attribute time value.
void set_by_val(const std::string &name, T value)
Set attribute value.
ConfigObject * get_obj_pybind(const std::string &attrname)
void set_time(const std::string &name, const std::vector< std::string > &value)
Set attribute vector-of-times value.
T get_value_pybind(const std::string &attrname)
ConfigObject() noexcept
Default constructor.
void set_class(const std::string &name, const std::vector< std::string > &value)
Set attribute vector-of-class value.
friend class Configuration
void set_date(const std::string &name, const std::string &value)
Set attribute date value.
void print_ptr(std::ostream &s) const noexcept
Print object's pointer in format 'obj-id@class-name'.
void set_objs(const std::string &name, const std::vector< const ConfigObject * > &o, bool skip_non_null_check=false)
Set relationship multi-value.
void move(const std::string &at)
Move object to a different database.
const std::string & UID() const noexcept
Return object identity.
void set_enum(const std::string &name, const std::vector< std::string > &value)
Set attribute vector-of-enumerations value.
ConfigObjectImpl * m_impl
Configuration * get_configuration() const
Get pointer to configuration object.
void set_class(const std::string &name, const std::string &value)
Set attribute class value.
void set_by_ref(const std::string &name, T &value)
Set attribute value.
bool is_deleted() const
Check if object was deleted.
void action_on_object_update(Configuration *db, const std::string &name)
friend class ConfigurationImpl
void set_list_pybind(const std::string &attrname, std::vector< T > l)
void set_date(const std::string &name, const std::vector< std::string > &value)
Set attribute vector-of-dates value.
void print_ref(std::ostream &s, Configuration &conf, const std::string &prefix="", bool show_contained_in=false) const noexcept
Print details of object's attributes and relationships.
void get(const std::string &name, T &value)
Get value of object's attribute or relationship.
void set_enum(const std::string &name, const std::string &value)
Set attribute enumeration value.
void referenced_by(std::vector< ConfigObject > &value, const std::string &relationship_name="*", bool check_composite_only=true, unsigned long rlevel=0, const std::vector< std::string > *rclasses=nullptr) const
Get objects which have references to given object.
const std::string full_name() const noexcept
Return full object name.
void set_obj(const std::string &name, const ConfigObject *o, bool skip_non_null_check=false)
Set relationship single-value.
bool is_null() const noexcept
Check if object's implementation points to null.
const ConfigObjectImpl * implementation() const noexcept
Returns pointer on implementation.
void rename(const std::string &new_id)
Rename object.
std::vector< T > get_list_pybind(const std::string &attrname)
const std::string & class_name() const noexcept
Return object's class name.
bool rel(const std::string &name, std::vector< ConfigObject > &value)
Get value of object's relationship.
const std::string contained_in() const
Return the name of the database file this object belongs to.
Defines base class for cache of template objects.
std::ostream & operator<<(std::ostream &, const ConfigurationChange &)