-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SavedConfig: changed CachedCards memory layout
- Loading branch information
Showing
6 changed files
with
96 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef CACHEDCARDS_HPP | ||
#define CACHEDCARDS_HPP | ||
|
||
#include <array> | ||
|
||
#include "FabUser.hpp" | ||
#include "conf.hpp" | ||
#include "card.hpp" | ||
|
||
namespace fabomatic | ||
{ | ||
struct CachedCard | ||
{ | ||
card::uid_t uid; | ||
FabUser::UserLevel level; | ||
constexpr CachedCard() : uid(card::INVALID), level(FabUser::UserLevel::Unknown){}; | ||
constexpr CachedCard(card::uid_t uid, FabUser::UserLevel level) : uid(uid), level(level){}; | ||
}; | ||
|
||
struct CachedCards | ||
{ | ||
std::array<card::uid_t, conf::rfid_tags::CACHE_LEN> cards; | ||
std::array<FabUser::UserLevel, conf::rfid_tags::CACHE_LEN> levels; | ||
|
||
constexpr CachedCards() : cards{card::INVALID}, levels{FabUser::UserLevel::Unknown} {}; | ||
|
||
constexpr const CachedCard operator[](int i) const | ||
{ | ||
return {cards[i], levels[i]}; | ||
} | ||
|
||
constexpr void set_at(int idx, const card::uid_t &uid, const FabUser::UserLevel &level) | ||
{ | ||
cards[idx] = uid; | ||
levels[idx] = level; | ||
} | ||
|
||
constexpr size_t size() const | ||
{ | ||
return conf::rfid_tags::CACHE_LEN; | ||
} | ||
}; | ||
|
||
} // namespace fabomatic | ||
|
||
#endif // CACHEDCARDS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters