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

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

#include <Or.hpp>

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

Public Member Functions

 OrImpl (Q1 &firstOperand, Q2 &secondOperand, Qs &...otherOperands)
 Construct a new Or 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< OrImpl< 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< OrImpl< 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) noexcept
 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< OrImpl< 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< OrImpl< 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< OrImpl< 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::OrImpl< AutoLock, Q1, Q2, Qs >

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

Note
The mask is the result of the operation: Q1 | Q2 | Qs...
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 35 of file Or.hpp.

Member Typedef Documentation

◆ ModifierClass

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

Helper type for the base class.

Definition at line 38 of file Or.hpp.

Constructor & Destructor Documentation

◆ OrImpl()

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

Construct a new Or 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 52 of file Or.hpp.

53 : ModifierClass(firstOperand, secondOperand, otherOperands...)
54 {
55 }
BinaryModifier< OrImpl< AutoLock, Q1, Q2, Qs... >, AutoLock, util::meta::add_optional, Q1, Q2, Qs... > ModifierClass
Helper type for the base class.
Definition Or.hpp:39

Member Function Documentation

◆ combineMask()

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

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 115 of file Or.hpp.

116 {
117 if (this->_mask.size() < mask.size())
118 this->_mask = util::BitSet(mask).inplaceOr(this->_mask);
119 else
120 this->_mask.inplaceOr(mask);
121 }
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 & inplaceOr(BitSet const &other) noexcept
Performs a bitwise OR with this set and other in place without resizing this.
Definition BitSet.cpp:136

◆ combineOperandMasks()

template<bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
template<size_t... ints>
void ecstasy::query::modifier::OrImpl< 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 134 of file Or.hpp.

135 {
136 (void)int_seq;
137 this->_mask = getQueryableMask(std::get<0>(this->_operands));
138 combineMask(getQueryableMask(std::get<1>(this->_operands)));
139 std::ignore = std::make_tuple((combineMask(getQueryableMask(std::get<ints + 2>(this->_operands))), 0)...);
140 }
void combineMask(const util::BitSet &mask) noexcept
Combine the current bitmask with the given one.
Definition Or.hpp:115
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::OrImpl< 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 72 of file Or.hpp.

73 {
74 auto &operand = std::get<operandId>(this->_operands);
75
76 if (index < getQueryableMask(operand).size() && getQueryableMask(operand)[index])
77 return getQueryableData(operand, index);
78 return std::nullopt;
79 }
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::OrImpl< 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 87 of file Or.hpp.

88 {
89 if constexpr (sizeof...(Qs) > 0)
91 else {
92 auto &leftOperand = std::get<0>(this->_operands);
93 auto &rightOperand = std::get<1>(this->_operands);
94
95 if (ecstasy::query::getQueryableMask(leftOperand).size()
96 > ecstasy::query::getQueryableMask(rightOperand).size()) {
97 this->_mask = ecstasy::query::getQueryableMask(leftOperand);
99 } else {
100 this->_mask = ecstasy::query::getQueryableMask(rightOperand);
102 }
103 }
104 }
void combineOperandMasks(std::integer_sequence< size_t, ints... > int_seq)
Combine all the operands' bitmasks.
Definition Or.hpp:134

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