ECSTASY
All in the name
Loading...
Searching...
No Matches
Not.hpp
Go to the documentation of this file.
1
11
12#ifndef ECSTASY_QUERY_MODIFIER_NOT_HPP_
13#define ECSTASY_QUERY_MODIFIER_NOT_HPP_
14
15#include "Modifier.hpp"
17#include "util/BitSet.hpp"
18
20{
34 template <Queryable Q, bool AutoLock = false>
35 class Not : public Modifier<AutoLock> {
36 public:
39
42
45
54 Not(Q &internal) : _internal(internal), _mask(getQueryableMask(internal))
55 {
56 _mask.flip();
57 }
58
69 [[nodiscard]] constexpr const util::BitSet &getMask() const noexcept
70 {
71 return _mask;
72 }
73
89 [[nodiscard]] QueryData getQueryData(size_t index)
90 {
91 return getQueryableData(_internal, index);
92 }
93
101 {
102 _mask = ~getQueryableMask(_internal);
103 }
104
115 constexpr void adjustMask(size_t maxSize)
116 {
117 if (maxSize > _mask.size()) {
118 _mask.resize(maxSize);
119 _mask.setAll();
121 }
122 }
123
124 private:
129 };
130} // namespace ecstasy::query::modifier
131
132#endif /* !ECSTASY_QUERY_MODIFIER_NOT_HPP_ */
Contains the concepts for queryable objects.
Query modifier which simply inverts the bits.
Definition Not.hpp:35
constexpr const util::BitSet & getMask() const noexcept
Get the flipped mask of the internal queryable.
Definition Not.hpp:69
constexpr void adjustMask(size_t maxSize)
Adjust the mask to be at least the maxSize.
Definition Not.hpp:115
queryable_data_t< Q > QueryData
Queryable constaint.
Definition Not.hpp:44
util::BitSet _mask
Mask of the internal queryable.
Definition Not.hpp:128
void reloadMask()
Update the mask to be up to date with the internal bitmask.
Definition Not.hpp:100
queryable_qualifiers_t< Q, AutoLock > Internal
Wrapped queryable.
Definition Not.hpp:38
QueryData getQueryData(size_t index)
Get the internal query data at the given index.
Definition Not.hpp:89
Not(Q &internal)
Construct a new Not Queryable modifier.
Definition Not.hpp:54
Internal _internal
Wrapped queryable.
Definition Not.hpp:126
Mimics the API of std::bitset but with the dynamic properties of std::vector<bool>
Definition BitSet.hpp:35
void resize(std::size_t size)
Changes the number of bits stored in this set.
Definition BitSet.hpp:199
constexpr std::size_t size() const noexcept
Definition BitSet.hpp:87
BitSet & setAll(bool value=true) noexcept
Sets all bits to the given value.
Definition BitSet.cpp:34
BitSet & inplaceXor(BitSet const &other) noexcept
Performs a bitwise XOR with this set and other in place without resizing this.
Definition BitSet.cpp:144
BitSet & flip() noexcept
Flips all the bits in the set.
Definition BitSet.cpp:52
Defines a query modifier type.
Definition Modifier.hpp:31
Type erased base class for all query modifiers.
Namespaces regrouping all the available query modifiers.
Definition And.hpp:19
typename queryable_data< Q >::type queryable_data_t
Alias for the query data type of a queryable object.
typename queryable_qualifiers< Q, AutoLock >::type queryable_qualifiers_t
Alias for the queryable type with the correct qualifiers.
constexpr queryable_data_t< Q > getQueryableData(Q &queryable, size_t index)
Get the query data at the given index.
constexpr const util::BitSet & getQueryableMask(const Q &queryable)
Get the mask of the queryable object.
Empty parameter pack helper type.
Definition Traits.hpp:28