lintel 0.2.0
Loading...
Searching...
No Matches
PropertyBase.h
Go to the documentation of this file.
1#ifndef LOGGING_PROPERTYBASE_H
2#define LOGGING_PROPERTYBASE_H
3
4#include <ostream>
5#include <string>
6#include <utility>
7
9
10namespace lintel {
13{
14private:
15 std::string m_name;
16 std::string m_instanceName;
17 std::string m_className;
18 std::string m_processName;
19 std::string m_identifier;
20 const bool m_runtimeChange;
21 const std::string m_description;
22 DataStorage m_dataStorage;
23
24protected:
31 PropertyBase(std::string name,
32 std::string instanceName,
33 std::string className,
34 std::string processName,
35 std::string description,
36 bool runtimeChange)
37 : m_name(std::move(name)), m_instanceName(std::move(instanceName)), m_className(std::move(className)),
38 m_processName(std::move(processName)),
39 m_identifier(m_name + "_" + m_instanceName + "_" + m_className + "_" + m_processName),
40 m_runtimeChange(runtimeChange), m_description(std::move(description))
41 {}
42
43public:
44 PropertyBase() = delete;
45
46 virtual ~PropertyBase() = default;
47
49 [[nodiscard]] virtual std::string toString() = 0;
50
52 [[nodiscard]] virtual std::string getType() const = 0;
53
55 [[nodiscard]] const std::string &getName() const { return m_name; }
56
58 [[nodiscard]] const std::string &getInstanceName() const { return m_instanceName; }
59
61 [[nodiscard]] const DataStorage &getDataStorage() const { return m_dataStorage; }
62
64 void setDataStorage(const DataStorage &newDataStorage) { PropertyBase::m_dataStorage = newDataStorage; }
65
67 [[nodiscard]] const std::string &getClassName() const { return m_className; }
68
70 [[nodiscard]] const std::string &getProcessName() const { return m_processName; }
71
73 [[nodiscard]] bool isRuntimeChange() const { return m_runtimeChange; }
74
76 [[nodiscard]] const std::string &getDescription() const { return m_description; }
77
79 [[nodiscard]] const std::string &getIdentifier() const { return m_identifier; }
80
82 virtual void setValueString(const std::string &value) = 0;
83
84 friend std::ostream &operator<<(std::ostream &os, PropertyBase &base)
85 {
86 os << "Property{"
87 << "name:" << base.m_name << ", value:" << base.toString() << ", processName:" << base.m_processName
88 << ", className:" << base.m_className << ", instanceName:" << base.m_instanceName
89 << ", runtimeChange:" << base.m_runtimeChange << ", description:" << base.m_description
90 << ", dataStorage:" << base.m_dataStorage << "}";
91 return os;
92 }
93
94 operator std::string()
95 {
96 std::ostringstream out;
97 out << *this;
98 return out.str();
99 }
100
101 bool operator<(const PropertyBase &rhs) const
102 {
103 if (getProcessName() < rhs.getProcessName()) { return true; }
104 if (rhs.getProcessName() < getProcessName()) { return false; }
105 if (getClassName() < rhs.getClassName()) { return true; }
106 if (rhs.getClassName() < getClassName()) { return false; }
107 return getInstanceName() < rhs.getInstanceName();
108 }
109};
110
111}// namespace lintel
112#endif// LOGGING_PROPERTYBASE_H
Definition DataStorage.h:13
Definition PropertyBase.h:13
const std::string & getProcessName() const
Definition PropertyBase.h:70
friend std::ostream & operator<<(std::ostream &os, PropertyBase &base)
Definition PropertyBase.h:84
bool isRuntimeChange() const
Definition PropertyBase.h:73
virtual ~PropertyBase()=default
PropertyBase(std::string name, std::string instanceName, std::string className, std::string processName, std::string description, bool runtimeChange)
Definition PropertyBase.h:31
const std::string & getIdentifier() const
Definition PropertyBase.h:79
virtual std::string getType() const =0
virtual void setValueString(const std::string &value)=0
const DataStorage & getDataStorage() const
Definition PropertyBase.h:61
virtual std::string toString()=0
bool operator<(const PropertyBase &rhs) const
Definition PropertyBase.h:101
const std::string & getInstanceName() const
Definition PropertyBase.h:58
const std::string & getDescription() const
Definition PropertyBase.h:76
void setDataStorage(const DataStorage &newDataStorage)
Definition PropertyBase.h:64
const std::string & getClassName() const
Definition PropertyBase.h:67
const std::string & getName() const
Definition PropertyBase.h:55
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9