Control Libraries 7.4.0
Loading...
Searching...
No Matches
DigitalIOState.hpp
1#pragma once
2
3#include "state_representation/IOState.hpp"
4
5namespace state_representation {
6
7class DigitalIOState : public IOState<bool> {
8public:
13
19 explicit DigitalIOState(const std::string& name, unsigned int nb_ios = 0);
20
26 DigitalIOState(const std::string& name, const std::vector<std::string>& io_names);
27
32 DigitalIOState(const DigitalIOState& state);
33
40 static DigitalIOState Zero(const std::string& name, unsigned int nb_ios);
41
48 static DigitalIOState Zero(const std::string& name, const std::vector<std::string>& names);
49
56 static DigitalIOState Random(const std::string& name, unsigned int nb_ios);
57
64 static DigitalIOState Random(const std::string& name, const std::vector<std::string>& names);
65
72
79 bool is_true(const std::string& name) const;
80
87 bool is_true(unsigned int io_index) const;
88
95 bool is_false(const std::string& name) const;
96
103 bool is_false(unsigned int io_index) const;
104
110 void set_true(const std::string& name);
111
117 void set_true(unsigned int io_index);
118
124 void set_false(const std::string& name);
125
131 void set_false(unsigned int io_index);
132
136 DigitalIOState copy() const;
137
141 void reset() override;
142
146 void set_false();
147
154 friend std::ostream& operator<<(std::ostream& os, const DigitalIOState& state);
155
156protected:
162 friend void swap(DigitalIOState& state1, DigitalIOState& state2);
163
167 std::string to_string() const override;
168};
169
170inline void swap(DigitalIOState& state1, DigitalIOState& state2) {
171 swap(static_cast<IOState<bool>&>(state1), static_cast<IOState<bool>&>(state2));
172}
173
174}// namespace state_representation
std::string to_string() const override
Convert the state to its string representation.
void set_false()
Set all digital IOs false.
friend void swap(DigitalIOState &state1, DigitalIOState &state2)
Swap the values of the IO states.
static DigitalIOState Zero(const std::string &name, unsigned int nb_ios)
Constructor for a zero digital IO state.
bool is_true(const std::string &name) const
Check if a digital IO is true by its name, if it exists.
void reset() override
Reset the object to a post-construction state.
DigitalIOState()
Empty constructor for a digital IO state.
DigitalIOState & operator=(const DigitalIOState &state)
Copy assignment operator that has to be defined to the custom assignment operator.
DigitalIOState copy() const
Return a copy of the digital IO state.
bool is_false(const std::string &name) const
Check if a digital IO is false by its name, if it exists.
friend std::ostream & operator<<(std::ostream &os, const DigitalIOState &state)
Overload the ostream operator for printing.
void set_true(const std::string &name)
Set the a digital IO to true by its name.
static DigitalIOState Random(const std::string &name, unsigned int nb_ios)
Constructor for a digital IO state with random data.
Core state variables and objects.
void swap(AnalogIOState &state1, AnalogIOState &state2)