21 return (_flags.count(flag) != 0);
27 return _flags.empty();
33 for(
auto flag : _flags) {
34 if(knownFlags.count(flag) == 0) {
44 return _flags == other._flags;
51 return _flags < other._flags;
70 for(
const auto& f : _flags) {
82 return getStringMap().at(flag);
88 std::vector<std::string> names = split(listOfflags);
89 std::set<AccessMode> flagList;
90 for(
const auto& flagName : names) {
91 flagList.insert(getAccessMode(flagName));
98 const std::map<AccessMode, std::string>& AccessModeFlags::getStringMap() {
99 static std::map<AccessMode, std::string> m = {
106 AccessMode AccessModeFlags::getAccessMode(
const std::string& flagName) {
107 static std::map<std::string, AccessMode> reverse_m;
108 for(
const auto& m : getStringMap()) {
109 reverse_m[m.second] = m.first;
112 return reverse_m.at(flagName);
114 catch(std::out_of_range& e) {
121 std::vector<std::string> AccessModeFlags::split(
const std::string& s) {
122 std::vector<std::string> list;
124 char delimiter =
',';
126 std::istringstream stream(s);
127 while(getline(stream, tmp, delimiter)) {
Set of AccessMode flags with additional functionality for an easier handling.
static AccessModeFlags deserialize(const std::string &listOfflags)
Get an AcessModeFlags object from a comma seperated list of flag strings.
bool operator<(const AccessModeFlags &other) const
"Less than" operator, e.g.
void remove(AccessMode flag)
Remove the given flag from the set.
std::string serialize() const
Get a comma seperated list of all flag strings contained in the class.
bool has(AccessMode flag) const
Check if a certain flag is in the set.
AccessModeFlags()=default
bool empty() const
Check if the set is empty (i.e.
void add(AccessMode flag)
Add the given flag to the set.
void checkForUnknownFlags(const std::set< AccessMode > &knownFlags) const
Check of any flag which is not in the given set "knownFlags" is set.
bool operator==(const AccessModeFlags &other) const
Check whether two sets of acces mode flags are the same.
static const std::string & getString(AccessMode flag)
Get a string representation of the given flag.
Exception thrown when a logic error has occured.
AccessMode
Enum type with access mode flags for register accessors.
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...