sdbus-c++ 1.2.0
High-level C++ D-Bus library based on systemd D-Bus implementation
Flags.h
Go to the documentation of this file.
1
27#ifndef SDBUS_CXX_FLAGS_H_
28#define SDBUS_CXX_FLAGS_H_
29
30#include <bitset>
31#include <cstdint>
32
33namespace sdbus {
34
35 // D-Bus interface, method, signal or property flags
36 class Flags
37 {
38 public:
39 enum GeneralFlags : uint8_t
40 { DEPRECATED = 0
41 , METHOD_NO_REPLY = 1
42 , PRIVILEGED = 2
43 };
44
45 enum PropertyUpdateBehaviorFlags : uint8_t
46 { EMITS_CHANGE_SIGNAL = 3
47 , EMITS_INVALIDATION_SIGNAL = 4
48 , EMITS_NO_SIGNAL = 5
49 , CONST_PROPERTY_VALUE = 6
50 };
51
52 enum : uint8_t
53 { FLAG_COUNT = 7
54 };
55
56 Flags()
57 {
58 // EMITS_CHANGE_SIGNAL is on by default
59 flags_.set(EMITS_CHANGE_SIGNAL, true);
60 }
61
62 void set(GeneralFlags flag, bool value = true)
63 {
64 flags_.set(flag, value);
65 }
66
67 void set(PropertyUpdateBehaviorFlags flag, bool value = true)
68 {
69 flags_.set(EMITS_CHANGE_SIGNAL, false);
70 flags_.set(EMITS_INVALIDATION_SIGNAL, false);
71 flags_.set(EMITS_NO_SIGNAL, false);
72 flags_.set(CONST_PROPERTY_VALUE, false);
73
74 flags_.set(flag, value);
75 }
76
77 bool test(GeneralFlags flag) const
78 {
79 return flags_.test(flag);
80 }
81
82 bool test(PropertyUpdateBehaviorFlags flag) const
83 {
84 return flags_.test(flag);
85 }
86
87 uint64_t toSdBusInterfaceFlags() const;
88 uint64_t toSdBusMethodFlags() const;
89 uint64_t toSdBusSignalFlags() const;
90 uint64_t toSdBusPropertyFlags() const;
91 uint64_t toSdBusWritablePropertyFlags() const;
92
93 private:
94 std::bitset<FLAG_COUNT> flags_;
95 };
96
97}
98
99#endif /* SDBUS_CXX_FLAGS_H_ */
Definition: Flags.h:37