![]() |
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. | |
| IdentifierField (element_type value) | |
| Create a unique value (understood as : low bound = high bound = value) | |
| IdentifierField (element_type minimum, element_type maximum) | |
| Create a full range specification (with explicit min and max) | |
| IdentifierField (const element_vector &values) | |
| Create with enumerated values. | |
| bool | wrap_around () const |
| element_type | get_minimum () const |
| Query the values. | |
| 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. | |
| 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. | |
| 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. | |
| bool | overlaps_with (const IdentifierField &other) const |
| Check whether two IdentifierFields overlap (Are there any values which satisfy the constraints of both fields?) | |
| void | clear () |
| Set methods. | |
| 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. | |
| operator std::string () const | |
| bool | operator== (const IdentifierField &other) const |
| void | show (std::ostream &out=std::cout) const |
| void | show (MsgStream &out) const |
| bool | check_for_both_bounded () |
| Check mode - switch from enumerated to both_bounded if possible. | |
| void | optimize () |
| Optimize - try to switch mode to both_bounded, set up lookup table for finding index from value. | |
| bool | empty () const |
| If true, this field does not have any constraints, and may hold any value representable by element_type. | |
| 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. | |
| 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 84 of file IdentifierField.h.
| using IdentifierField::BoundedRange = std::pair<element_type, element_type> |
Definition at line 91 of file IdentifierField.h.
Definition at line 87 of file IdentifierField.h.
| using IdentifierField::element_vector = std::vector <element_type> |
Definition at line 89 of file IdentifierField.h.
| using IdentifierField::index_vector = std::vector <size_type> |
Definition at line 90 of file IdentifierField.h.
Definition at line 88 of file IdentifierField.h.
| Enumerator | |
|---|---|
| none | |
| has_next | |
| has_previous | |
| has_both | |
| has_wrap_around | |
Definition at line 96 of file IdentifierField.h.
|
default |
Create a wild-card value.
| IdentifierField::IdentifierField | ( | element_type | value | ) |
Create a unique value (understood as : low bound = high bound = value)
Definition at line 84 of file IdentifierField.cxx.
| IdentifierField::IdentifierField | ( | element_type | minimum, |
| element_type | maximum ) |
Create a full range specification (with explicit min and max)
Definition at line 94 of file IdentifierField.cxx.
| IdentifierField::IdentifierField | ( | const element_vector & | values | ) |
Create with enumerated values.
Definition at line 100 of file IdentifierField.cxx.
| void IdentifierField::add_value | ( | element_type | value | ) |
Definition at line 251 of file IdentifierField.cxx.
| bool IdentifierField::check_for_both_bounded | ( | ) |
Check mode - switch from enumerated to both_bounded if possible.
Definition at line 444 of file IdentifierField.cxx.
| void IdentifierField::clear | ( | ) |
Set methods.
Definition at line 225 of file IdentifierField.cxx.
|
private |
Create index table from value table.
Create index table from value table
Definition at line 458 of file IdentifierField.cxx.
|
inlineprivate |
Definition at line 198 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 185 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 41 of file IdentifierField.cxx.
|
inline |
Definition at line 143 of file IdentifierField.h.
|
inline |
Definition at line 142 of file IdentifierField.h.
|
inline |
Definition at line 132 of file IdentifierField.h.
|
inline |
|
inline |
Definition at line 127 of file IdentifierField.h.
| bool IdentifierField::get_next | ( | element_type | current, |
| element_type & | next ) const |
Definition at line 150 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 107 of file IdentifierField.cxx.
|
inline |
Definition at line 212 of file IdentifierField.h.
| ExpandedIdentifier::size_type IdentifierField::get_value_index | ( | element_type | value | ) | const |
Definition at line 50 of file IdentifierField.cxx.
|
inline |
Definition at line 135 of file IdentifierField.h.
|
inline |
Definition at line 187 of file IdentifierField.h.
|
inline |
Definition at line 188 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 72 of file IdentifierField.cxx.
| IdentifierField::operator std::string | ( | ) | const |
Definition at line 344 of file IdentifierField.cxx.
| bool IdentifierField::operator== | ( | const IdentifierField & | other | ) | const |
Definition at line 375 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 320 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 436 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 195 of file IdentifierField.cxx.
| void IdentifierField::set | ( | bool | wraparound | ) |
Definition at line 288 of file IdentifierField.cxx.
| void IdentifierField::set | ( | const element_vector & | values | ) |
| void IdentifierField::set | ( | element_type | minimum, |
| element_type | maximum ) |
Definition at line 238 of file IdentifierField.cxx.
|
private |
|
private |
| void IdentifierField::set_next | ( | int | next | ) |
Definition at line 296 of file IdentifierField.cxx.
| void IdentifierField::set_previous | ( | int | previous | ) |
Definition at line 308 of file IdentifierField.cxx.
| void IdentifierField::show | ( | MsgStream & | out | ) | const |
Definition at line 426 of file IdentifierField.cxx.
| void IdentifierField::show | ( | std::ostream & | out = std::cout | ) | const |
Definition at line 383 of file IdentifierField.cxx.
|
inline |
Definition at line 118 of file IdentifierField.h.
|
staticconstexpr |
Definition at line 94 of file IdentifierField.h.
|
private |
Definition at line 208 of file IdentifierField.h.
|
private |
Definition at line 202 of file IdentifierField.h.
|
private |
Definition at line 207 of file IdentifierField.h.
|
private |
Definition at line 203 of file IdentifierField.h.
|
private |
Definition at line 201 of file IdentifierField.h.
|
staticconstexprprivate |
Definition at line 191 of file IdentifierField.h.
|
private |
Definition at line 200 of file IdentifierField.h.
|
private |
Definition at line 206 of file IdentifierField.h.
|
private |
Definition at line 205 of file IdentifierField.h.
|
private |
Definition at line 204 of file IdentifierField.h.
|
staticconstexpr |
Definition at line 93 of file IdentifierField.h.
|
staticconstexpr |
Definition at line 92 of file IdentifierField.h.