mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-08-02 08:41:54 +00:00
Added ALL_STATES define
This commit is contained in:
parent
93a4112f59
commit
96147df269
@ -59,7 +59,7 @@ namespace sta
|
||||
/**
|
||||
* @brief Register a thread to be managed by the manager.
|
||||
*/
|
||||
void registerThread(std::shared_ptr<TacosThread> thread, std::list<uint16_t> states);
|
||||
void registerThread(std::shared_ptr<TacosThread> thread, std::set<uint16_t> states);
|
||||
|
||||
void init() override;
|
||||
|
||||
|
@ -69,6 +69,23 @@
|
||||
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Addresses all states from 0 to STA_TACOS_NUM_STATES-1.
|
||||
*
|
||||
* @ingroup tacos_statemachine
|
||||
*/
|
||||
#define ALL_STATES std::set<uint16_t>{[]{ std::set<uint16_t> states; for (uint16_t i = 0; i < STA_TACOS_NUM_STATES; ++i) states.insert(i); return states; }() }
|
||||
|
||||
/**
|
||||
* @brief Shorthand to make own sets of states. Primarily for exlcusion via "-" operator.
|
||||
*
|
||||
* @ingroup tacos_statemachine
|
||||
*/
|
||||
#define state_set std::set<uint16_t>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
@ -204,4 +221,12 @@ namespace sta
|
||||
|
||||
#endif // STA_TACOS_NUM_STATES
|
||||
|
||||
/// Overwrite "-" operator for set.
|
||||
template <typename T>
|
||||
std::set<T> operator-(const std::set<T>& set1, const std::set<T>& set2) {
|
||||
std::set<T> result;
|
||||
std::set_difference(set1.begin(), set1.end(), set2.begin(), set2.end(), std::inserter(result, result.begin()));
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_TACOS_STATEMACHINE_HPP_ */
|
||||
|
@ -18,7 +18,7 @@ namespace sta
|
||||
{
|
||||
namespace tacos
|
||||
{
|
||||
void Manager::registerThread(std::shared_ptr<TacosThread> thread, std::list<uint16_t> states)
|
||||
void Manager::registerThread(std::shared_ptr<TacosThread> thread, std::set<uint16_t> states)
|
||||
{
|
||||
for (uint16_t state : states)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user