![]() |
ATLAS Offline Software
|
This is the individual specification for the range of one ExpandedIdentifier IdentifierField. More...
#include <IdentifierField.h>
Public Types | |
enum | continuation_mode { none, has_next, has_previous, has_both, has_wrap_around } |
using | element_type = ExpandedIdentifier::element_type |
using | size_type = ExpandedIdentifier::size_type |
using | element_vector = std::vector< element_type > |
using | index_vector = std::vector< size_type > |
using | BoundedRange = std::pair< element_type, element_type > |
Public Member Functions | |
IdentifierField ()=default | |
Create a wild-card value. More... | |
IdentifierField (element_type value) | |
Create a unique value (understood as : low bound = high bound = value) More... | |
IdentifierField (element_type minimum, element_type maximum) | |
Create a full range specification (with explicit min and max) More... | |
IdentifierField (const element_vector &values) | |
Create with enumerated values. More... | |
bool | wrap_around () const |
element_type | get_minimum () const |
Query the values. More... | |
std::pair< element_type, element_type > | get_minmax () const |
element_type | get_maximum () const |
const element_vector & | get_values () const |
bool | get_previous (element_type current, element_type &previous) const |
Returns false if previous/next is at end of range, or not possible. More... | |
bool | get_next (element_type current, element_type &next) const |
size_type | get_indices () const |
const index_vector & | get_indexes () const |
size_type | get_bits () const |
Return the number of bits needed to store a value of this field. More... | |
element_type | get_value_at (size_type index) const |
size_type | get_value_index (element_type value) const |
bool | match (element_type value) const |
The basic match operation Given a value, test to see if it satisfies the constraints for this field. More... | |
bool | overlaps_with (const IdentifierField &other) const |
Check whether two IdentifierFields overlap (Are there any values which satisfy the constraints of both fields?) More... | |
void | clear () |
Set methods. More... | |
void | set (element_type minimum, element_type maximum) |
void | add_value (element_type value) |
void | set (const element_vector &values) |
void | set (bool wraparound) |
void | set_next (int next) |
void | set_previous (int previous) |
void | operator|= (const IdentifierField &other) |
Find the union of two fields. More... | |
operator std::string () const | |
bool | operator== (const IdentifierField &other) const |
void | show () const |
bool | check_for_both_bounded () |
Check mode - switch from enumerated to both_bounded if possible. More... | |
void | optimize () |
Optimize - try to switch mode to both_bounded, set up lookup table for finding index from value. More... | |
bool | empty () const |
If true, this field does not have any constraints, and may hold any value representable by element_type. More... | |
bool | isBounded () const |
bool | isEnumerated () const |
Static Public Attributes | |
static constexpr auto | minimum_possible = std::numeric_limits<element_type>::min() |
static constexpr auto | maximum_possible = std::numeric_limits<element_type>::max() |
static constexpr auto | invalidValues = element_vector{} |
Private Member Functions | |
void | set_minimum (element_type value) |
void | set_maximum (element_type value) |
void | create_index_table () |
Create index table from value table. More... | |
template<class T > | |
T * | dataPtr () |
Private Attributes | |
element_type | m_minimum {} |
element_type | m_maximum {} |
std::variant< element_vector, BoundedRange > | m_data {} |
index_vector | m_indexes {} |
size_type | m_size {} |
element_type | m_previous {} |
element_type | m_next {} |
bool | m_empty {true} |
continuation_mode | m_continuation_mode {none} |
Static Private Attributes | |
static constexpr int | m_maxNumberOfIndices = 100 |
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
A field specifies a constraint on the values it may contain. This may take one of three forms:
Each valid value is assigned an index, starting with 0. For bounded ranges, this just starts from the minimum value and counts up. For enumerations, it is the index of that particular enumeration value. You can convert between values and indices using get_value_at() and get_value_index(). For value->index conversions, a lookup table is used if optimize() has been called and the spread of values is not too large. get_indices() will return this table.
As far as users of this class see, there is not really a distinction between a dense enumeration and a bounded range. In fact, check_for_both_bounded()/optimize() will convert a dense enumeration to a bounded range.
Given a value, one can ask for the next/previous valid value using get_next()/get_previous(). For an enumeration, this will return the next or previous enumeration value. If you try to call get_next() for the maximum value in the range, or get_previous() from the minimum, then they will by default fail (return false). This can be changed by calling set_next()/set_previous() to specify explictly values to be returned in these cases, or by calling set(true) to enable wraparound mode; in that case, calling get_next() for the maximum value will return the minimum value, and analogously for get_previous().
Other operations include:
match(): Given a value, test whether it satisfies the constraints for this field.
Definition at line 82 of file IdentifierField.h.
using IdentifierField::BoundedRange = std::pair<element_type, element_type> |
Definition at line 89 of file IdentifierField.h.
Definition at line 85 of file IdentifierField.h.
using IdentifierField::element_vector = std::vector <element_type> |
Definition at line 87 of file IdentifierField.h.
using IdentifierField::index_vector = std::vector <size_type> |
Definition at line 88 of file IdentifierField.h.
Definition at line 86 of file IdentifierField.h.
Enumerator | |
---|---|
none | |
has_next | |
has_previous | |
has_both | |
has_wrap_around |
Definition at line 94 of file IdentifierField.h.
|
default |
Create a wild-card value.
IdentifierField::IdentifierField | ( | element_type | value | ) |
IdentifierField::IdentifierField | ( | element_type | minimum, |
element_type | maximum | ||
) |
Create a full range specification (with explicit min and max)
Definition at line 93 of file IdentifierField.cxx.
IdentifierField::IdentifierField | ( | const element_vector & | values | ) |
Create with enumerated values.
Definition at line 99 of file IdentifierField.cxx.
void IdentifierField::add_value | ( | element_type | value | ) |
Definition at line 250 of file IdentifierField.cxx.
bool IdentifierField::check_for_both_bounded | ( | ) |
Check mode - switch from enumerated to both_bounded if possible.
Definition at line 430 of file IdentifierField.cxx.
void IdentifierField::clear | ( | ) |
|
private |
Create index table from value table.
Create index table from value table
Definition at line 444 of file IdentifierField.cxx.
|
inlineprivate |
Definition at line 195 of file IdentifierField.h.
|
inline |
If true, this field does not have any constraints, and may hold any value representable by element_type.
Definition at line 182 of file IdentifierField.h.
ExpandedIdentifier::size_type IdentifierField::get_bits | ( | ) | const |
Return the number of bits needed to store a value of this field.
Definition at line 40 of file IdentifierField.cxx.
|
inline |
Definition at line 141 of file IdentifierField.h.
|
inline |
Definition at line 140 of file IdentifierField.h.
|
inline |
Definition at line 130 of file IdentifierField.h.
|
inline |
|
inline |
Definition at line 125 of file IdentifierField.h.
bool IdentifierField::get_next | ( | element_type | current, |
element_type & | next | ||
) | const |
Definition at line 149 of file IdentifierField.cxx.
bool IdentifierField::get_previous | ( | element_type | current, |
element_type & | previous | ||
) | const |
Returns false if previous/next is at end of range, or not possible.
Definition at line 106 of file IdentifierField.cxx.
|
inline |
Definition at line 209 of file IdentifierField.h.
ExpandedIdentifier::size_type IdentifierField::get_value_index | ( | element_type | value | ) | const |
Definition at line 49 of file IdentifierField.cxx.
|
inline |
Definition at line 133 of file IdentifierField.h.
|
inline |
Definition at line 184 of file IdentifierField.h.
|
inline |
Definition at line 185 of file IdentifierField.h.
bool IdentifierField::match | ( | element_type | value | ) | const |
The basic match operation Given a value, test to see if it satisfies the constraints for this field.
Definition at line 71 of file IdentifierField.cxx.
IdentifierField::operator std::string | ( | ) | const |
Definition at line 343 of file IdentifierField.cxx.
bool IdentifierField::operator== | ( | const IdentifierField & | other | ) | const |
Definition at line 368 of file IdentifierField.cxx.
void IdentifierField::operator|= | ( | const IdentifierField & | other | ) |
Find the union of two fields.
Note: does not correctly handle the cases of an enumeration and a bounded range or two disjoint bounded ranges! If either is empty (meaning no constraint), then the result will be empty.
If there is no overlap we should build a multi-segment specification. The current algorithm is only correct if the overlap in not empty !! A multi-segment specification might also be implemented as an expanded enumerated set (not very optimized !!)
Definition at line 319 of file IdentifierField.cxx.
void IdentifierField::optimize | ( | ) |
Optimize - try to switch mode to both_bounded, set up lookup table for finding index from value.
Check mode - switch from enumerated to both_bounded if possible
Definition at line 422 of file IdentifierField.cxx.
bool IdentifierField::overlaps_with | ( | const IdentifierField & | other | ) | const |
Check whether two IdentifierFields overlap (Are there any values which satisfy the constraints of both fields?)
Definition at line 194 of file IdentifierField.cxx.
void IdentifierField::set | ( | bool | wraparound | ) |
Definition at line 287 of file IdentifierField.cxx.
void IdentifierField::set | ( | const element_vector & | values | ) |
void IdentifierField::set | ( | element_type | minimum, |
element_type | maximum | ||
) |
Definition at line 237 of file IdentifierField.cxx.
|
private |
|
private |
void IdentifierField::set_next | ( | int | next | ) |
Definition at line 295 of file IdentifierField.cxx.
void IdentifierField::set_previous | ( | int | previous | ) |
Definition at line 307 of file IdentifierField.cxx.
void IdentifierField::show | ( | ) | const |
Definition at line 376 of file IdentifierField.cxx.
|
inline |
Definition at line 116 of file IdentifierField.h.
|
staticconstexpr |
Definition at line 92 of file IdentifierField.h.
|
private |
Definition at line 205 of file IdentifierField.h.
|
private |
Definition at line 199 of file IdentifierField.h.
|
private |
Definition at line 204 of file IdentifierField.h.
|
private |
Definition at line 200 of file IdentifierField.h.
|
private |
Definition at line 198 of file IdentifierField.h.
|
staticconstexprprivate |
Definition at line 188 of file IdentifierField.h.
|
private |
Definition at line 197 of file IdentifierField.h.
|
private |
Definition at line 203 of file IdentifierField.h.
|
private |
Definition at line 202 of file IdentifierField.h.
|
private |
Definition at line 201 of file IdentifierField.h.
|
staticconstexpr |
Definition at line 91 of file IdentifierField.h.
|
staticconstexpr |
Definition at line 90 of file IdentifierField.h.