]> granicus.if.org Git - icinga2/blob - lib/db_ido/dbvalue.hpp
Merge pull request #7124 from Icinga/bugfix/namespace-thread-safe
[icinga2] / lib / db_ido / dbvalue.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef DBVALUE_H
4 #define DBVALUE_H
5
6 #include "db_ido/i2-db_ido.hpp"
7 #include "base/object.hpp"
8 #include "base/value.hpp"
9
10 namespace icinga
11 {
12
13 enum DbValueType
14 {
15         DbValueTimestamp,
16         DbValueObjectInsertID
17 };
18
19 /**
20  * A database value.
21  *
22  * @ingroup ido
23  */
24 struct DbValue final : public Object
25 {
26 public:
27         DECLARE_PTR_TYPEDEFS(DbValue);
28
29         DbValue(DbValueType type, Value value);
30
31         static Value FromTimestamp(const Value& ts);
32         static Value FromValue(const Value& value);
33         static Value FromObjectInsertID(const Value& value);
34
35         static bool IsTimestamp(const Value& value);
36         static bool IsObjectInsertID(const Value& value);
37
38         static Value ExtractValue(const Value& value);
39
40         DbValueType GetType() const;
41
42         Value GetValue() const;
43         void SetValue(const Value& value);
44
45 private:
46         DbValueType m_Type;
47         Value m_Value;
48 };
49
50 }
51
52 #endif /* DBVALUE_H */