8#ifndef CONFFWK_CONFIGOBJECT_H_
9#define CONFFWK_CONFIGOBJECT_H_
112 bool operator==(const
ConfigObject& other) const noexcept;
116 template <typename T>
119 this->
get(attrname, attrval);
123 template <
typename T>
125 std::vector<T> attrvals;
126 this->
get(attrname, attrvals);
130 template <
typename T>
183 return (
m_impl ==
nullptr);
194 return (
m_impl->is_deleted());
218 const std::string&
UID() const noexcept {
return m_impl->m_id; }
251 return m_impl->contained_in();
278 template<
class T>
void get(
const std::string& name, T& value) {
280 m_impl->convert(value, *
this, name);
297 rel(
const std::string& name, std::vector<ConfigObject>& value)
299 if (
m_impl->rel(name, value))
301 m_impl->convert(value, *
this, name);
328 const std::string& relationship_name =
"*",
329 bool check_composite_only =
true,
330 unsigned long rlevel = 0,
331 const std::vector<std::string> * rclasses =
nullptr )
const {
332 m_impl->referenced_by(value, relationship_name, check_composite_only, rlevel, rclasses);
350 m_impl->set(name, o, skip_non_null_check);
365 void set_objs(
const std::string& name,
const std::vector<const ConfigObject*> & o,
bool skip_non_null_check =
false) {
366 m_impl->set(name, o, skip_non_null_check);
391 template<
class T>
void set_by_val(
const std::string& name, T value) {
412 template<
class T>
void set_by_ref(
const std::string& name, T& value) {
429 void set_enum(
const std::string& name,
const std::string& value) {
430 m_impl->set_enum(name, value);
446 void set_class(
const std::string& name,
const std::string& value) {
447 m_impl->set_class(name, value);
463 void set_date(
const std::string& name,
const std::string& value) {
464 m_impl->set_date(name, value);
480 void set_time(
const std::string& name,
const std::string& value) {
481 m_impl->set_time(name, value);
497 void set_enum(
const std::string& name,
const std::vector<std::string>& value) {
498 m_impl->set_enum(name, value);
514 void set_class(
const std::string& name,
const std::vector<std::string>& value) {
515 m_impl->set_class(name, value);
531 void set_date(
const std::string& name,
const std::vector<std::string>& value) {
532 m_impl->set_date(name, value);
548 void set_time(
const std::string& name,
const std::vector<std::string>& value) {
549 m_impl->set_time(name, value);
564 void move(
const std::string& at) {
580 rename(
const std::string& new_id);
587 void print_ptr(std::ostream& s)
const noexcept;
597 const std::string& prefix =
"",
598 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 &)