ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
AccessMode.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include <map>
6#include <set>
7#include <sstream>
8#include <vector>
9
10namespace ChimeraTK {
11
12 /********************************************************************************************************************/
13
20 enum class AccessMode {
21
30 raw,
31
37
38 /* IMPORTANT: When extending this class with new flags, don't forget to update AccessModeFlags::getStringMap()! */
39 };
40
41 /********************************************************************************************************************/
42
49 public:
51 explicit AccessModeFlags(std::set<AccessMode> flags);
52
58 AccessModeFlags(const std::initializer_list<AccessMode>& flags);
59
60 AccessModeFlags() = default;
61
65 [[nodiscard]] bool has(AccessMode flag) const;
66
70 [[nodiscard]] bool empty() const;
71
76 void checkForUnknownFlags(const std::set<AccessMode>& knownFlags) const;
77
81 [[nodiscard]] bool operator==(const AccessModeFlags& other) const;
82
86 [[nodiscard]] bool operator<(const AccessModeFlags& other) const;
87
91 void remove(AccessMode flag);
92
96 void add(AccessMode flag);
97
101 [[nodiscard]] std::string serialize() const;
102
106 [[nodiscard]] static const std::string& getString(AccessMode flag);
107
111 [[nodiscard]] static AccessModeFlags deserialize(const std::string& listOfflags);
112
113 private:
114 // set of flags
115 std::set<AccessMode> _flags;
116
120 [[nodiscard]] static const std::map<AccessMode, std::string>& getStringMap();
121
125 [[nodiscard]] static AccessMode getAccessMode(const std::string& flagName);
126
130 [[nodiscard]] static std::vector<std::string> split(const std::string& s);
131 };
132
133 /********************************************************************************************************************/
134
135} /* namespace ChimeraTK */
Set of AccessMode flags with additional functionality for an easier handling.
Definition AccessMode.h:48
static AccessModeFlags deserialize(const std::string &listOfflags)
Get an AcessModeFlags object from a comma seperated list of flag strings.
Definition AccessMode.cc:87
bool operator<(const AccessModeFlags &other) const
"Less than" operator, e.g.
Definition AccessMode.cc:49
void remove(AccessMode flag)
Remove the given flag from the set.
Definition AccessMode.cc:56
std::string serialize() const
Get a comma seperated list of all flag strings contained in the class.
Definition AccessMode.cc:68
bool has(AccessMode flag) const
Check if a certain flag is in the set.
Definition AccessMode.cc:20
bool empty() const
Check if the set is empty (i.e.
Definition AccessMode.cc:26
void add(AccessMode flag)
Add the given flag to the set.
Definition AccessMode.cc:62
void checkForUnknownFlags(const std::set< AccessMode > &knownFlags) const
Check of any flag which is not in the given set "knownFlags" is set.
Definition AccessMode.cc:32
bool operator==(const AccessModeFlags &other) const
Check whether two sets of acces mode flags are the same.
Definition AccessMode.cc:42
static const std::string & getString(AccessMode flag)
Get a string representation of the given flag.
Definition AccessMode.cc:81
AccessMode
Enum type with access mode flags for register accessors.
Definition AccessMode.h:20
@ 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...