ECSTASY
All in the name
Loading...
Searching...
No Matches
ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs > Class Template Reference

Binary query modifier which performs a xor between at least two queryables. More...

#include <Xor.hpp>

Inheritance diagram for ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >:
Collaboration diagram for ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >:

Public Member Functions

 XorImpl (Q1 &firstOperand, Q2 &secondOperand, Qs &...otherOperands)
 Construct a new Xor Queryable modifier.
 
template<size_t operandId>
ModifierClass::template OperandData< operandId > getOperandData (size_t index)
 Get a std::optional filled with the data of the specified operand at index index if existing.
 
void reloadMask ()
 Update the mask to be up to date with the operands bitmasks.
 
- Public Member Functions inherited from ecstasy::query::modifier::BinaryModifier< XorImpl< AutoLock, Q1, Q2, Qs... >, AutoLock, util::meta::add_optional, Q1, Q2, Qs... >
 BinaryModifier (Q1 &firstOperand, Q2 &secondOperand, Qs &...otherOperands)
 Construct a new binary query modifier.
 
constexpr const util::BitSetgetMask () const noexcept
 Get the Mask of the internal queryables.
 
QueryData getQueryData (size_t index)
 Get the operands data at the given index.
 
- Public Member Functions inherited from ecstasy::query::modifier::Modifier< AutoLock >
virtual ~Modifier ()=default
 Destroy the modifier base object.
 
- Public Member Functions inherited from ecstasy::query::modifier::ModifierBase
virtual ~ModifierBase ()=default
 Destroy the modifier base object.
 

Private Types

using ModifierClass = BinaryModifier< XorImpl< AutoLock, Q1, Q2, Qs... >, AutoLock, util::meta::add_optional, Q1, Q2, Qs... >
 Helper type for the base class.
 

Private Member Functions

void combineMask (const util::BitSet &mask)
 Combine the current bitmask with the given one.
 
template<size_t... ints>
void combineOperandMasks (std::integer_sequence< size_t, ints... > int_seq)
 Combine all the operands' bitmasks.
 

Additional Inherited Members

- Public Types inherited from ecstasy::query::modifier::BinaryModifier< XorImpl< AutoLock, Q1, Q2, Qs... >, AutoLock, util::meta::add_optional, Q1, Q2, Qs... >
using Operands = util::meta::Traits< Q1, Q2, Qs... >
 Modifier constraint.
 
using Internal = std::tuple< queryable_qualifiers_t< Q1, AutoLock >, queryable_qualifiers_t< Q2, AutoLock >, queryable_qualifiers_t< Qs, AutoLock >... >
 
using QueryData = std::tuple< typename util::meta::add_optional< typename Q1::QueryData >::type, typename util::meta::add_optional< typename Q2::QueryData >::type, typename util::meta::add_optional< typename Qs::QueryData >::type... >
 Queryable constaint.
 
using OperandData = std::tuple_element_t< operandId, QueryData >
 QueryData for the given operand.
 
- Protected Member Functions inherited from ecstasy::query::modifier::BinaryModifier< XorImpl< AutoLock, Q1, Q2, Qs... >, AutoLock, util::meta::add_optional, Q1, Q2, Qs... >
QueryData getQueryData (size_t index, std::integer_sequence< size_t, ints... > int_seq)
 Get the query data.
 
OperandData< operandId > getDerivedOperandData (size_t index)
 
- Protected Attributes inherited from ecstasy::query::modifier::BinaryModifier< XorImpl< AutoLock, Q1, Q2, Qs... >, AutoLock, util::meta::add_optional, Q1, Q2, Qs... >
Internal _operands
 Tuple containing the queryables.
 
util::BitSet _mask
 Mask of the queryables.
 

Detailed Description

template<bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
class ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >

Binary query modifier which performs a xor between at least two queryables.

Note
The mask is the result of the operation: Q1 ^ Q2 ^ Qs...
Warning
Since the mask of multiple operands is (Q1 ^ Q2) ^ Qs..., it is true when an odd number of operands match a given id.
Template Parameters
AutoLockLock the Lockable queryables if true.
Q1Left operand queryable type.
Q2Right operand queryable type.
QsAdditional operand queryable types.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-27)

Definition at line 37 of file Xor.hpp.

Member Typedef Documentation

◆ ModifierClass

template<bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
using ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >::ModifierClass = BinaryModifier<XorImpl<AutoLock, Q1, Q2, Qs...>, AutoLock, util::meta::add_optional, Q1, Q2, Qs...>
private

Helper type for the base class.

Definition at line 40 of file Xor.hpp.

Constructor & Destructor Documentation

◆ XorImpl()

template<bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >::XorImpl ( Q1 &  firstOperand,
Q2 &  secondOperand,
Qs &...  otherOperands 
)
inline

Construct a new Xor Queryable modifier.

Parameters
[in]firstOperandleft queryable operand.
[in]secondOperandright queryable operand.
[in]otherOperandsadditional operands (optional).
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-27)

Definition at line 54 of file Xor.hpp.

55 : ModifierClass(firstOperand, secondOperand, otherOperands...)
56 {
57 }
BinaryModifier< XorImpl< AutoLock, Q1, Q2, Qs... >, AutoLock, util::meta::add_optional, Q1, Q2, Qs... > ModifierClass
Helper type for the base class.
Definition Xor.hpp:41

Member Function Documentation

◆ combineMask()

template<bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
void ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >::combineMask ( const util::BitSet mask)
inlineprivate

Combine the current bitmask with the given one.

Parameters
[in]maskEvaluated bitmask.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-21)

Definition at line 116 of file Xor.hpp.

117 {
118 if (this->_mask.size() < mask.size())
119 this->_mask = util::BitSet(mask).inplaceXor(this->_mask);
120 else
121 this->_mask.inplaceXor(mask);
122 }
Mimics the API of std::bitset but with the dynamic properties of std::vector<bool>
Definition BitSet.hpp:35
constexpr std::size_t size() const noexcept
Definition BitSet.hpp:87
BitSet & inplaceXor(BitSet const &other) noexcept
Performs a bitwise XOR with this set and other in place without resizing this.
Definition BitSet.cpp:144

◆ combineOperandMasks()

template<bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
template<size_t... ints>
void ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >::combineOperandMasks ( std::integer_sequence< size_t, ints... >  int_seq)
inlineprivate

Combine all the operands' bitmasks.

Template Parameters
intsSequence values.
Parameters
[in]int_seqSequence containing the queryable ids.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-21)

Definition at line 135 of file Xor.hpp.

136 {
137 (void)int_seq;
138 this->_mask = getQueryableMask(std::get<0>(this->_operands));
139 combineMask(getQueryableMask(std::get<1>(this->_operands)));
140 std::ignore = std::make_tuple((combineMask(getQueryableMask(std::get<ints + 2>(this->_operands))), 0)...);
141 }
void combineMask(const util::BitSet &mask)
Combine the current bitmask with the given one.
Definition Xor.hpp:116
T make_tuple(T... args)
constexpr const util::BitSet & getQueryableMask(const Q &queryable)
Get the mask of the queryable object.

◆ getOperandData()

template<bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
template<size_t operandId>
ModifierClass::template OperandData< operandId > ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >::getOperandData ( size_t  index)
inline

Get a std::optional filled with the data of the specified operand at index index if existing.

Warning
May throw exceptions, look at the specified operand type equivalent method documentation.
Template Parameters
operandIdId of the operand (where 0 is Q1, 1 is Q2...).
Parameters
[in]indexIndex of the entity.
Returns
auto A std::optional filled with the resulting operand data at index index if existing.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-27)

Definition at line 74 of file Xor.hpp.

75 {
76 auto &operand = std::get<operandId>(this->_operands);
77
78 if (index < getQueryableMask(operand).size() && getQueryableMask(operand)[index])
79 return getQueryableData(operand, index);
80 return std::nullopt;
81 }
constexpr queryable_data_t< Q > getQueryableData(Q &queryable, size_t index)
Get the query data at the given index.
T size(T... args)

◆ reloadMask()

template<bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
void ecstasy::query::modifier::XorImpl< AutoLock, Q1, Q2, Qs >::reloadMask ( )
inline

Update the mask to be up to date with the operands bitmasks.

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-27)

Definition at line 89 of file Xor.hpp.

90 {
91 if constexpr (sizeof...(Qs) > 0)
93 else {
94 auto &leftOperand = std::get<0>(this->_operands);
95 auto &rightOperand = std::get<1>(this->_operands);
96
97 if (getQueryableMask(leftOperand).size() > getQueryableMask(rightOperand).size()) {
98 this->_mask = getQueryableMask(leftOperand);
99 this->_mask.inplaceXor(getQueryableMask(rightOperand));
100 } else {
101 this->_mask = getQueryableMask(rightOperand);
102 this->_mask.inplaceXor(getQueryableMask(leftOperand));
103 }
104 }
105 }
void combineOperandMasks(std::integer_sequence< size_t, ints... > int_seq)
Combine all the operands' bitmasks.
Definition Xor.hpp:135

The documentation for this class was generated from the following file: