LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
|
A GenericMap that allows insertion and deletion of arbitrary values. More...
#include <SimpleGenericMap.h>
Public Types | |
using | key_type = K |
using | size_type = std::size_t |
using | difference_type = std::ptrdiff_t |
Public Member Functions | |
SimpleGenericMap ()=default | |
SimpleGenericMap (SimpleGenericMap const &other)=default | |
SimpleGenericMap (SimpleGenericMap &&) noexcept=default | |
SimpleGenericMap (GenericMap< K > const &other) | |
Convert another GenericMap into a SimpleGenericMap. | |
virtual | ~SimpleGenericMap () noexcept=default |
SimpleGenericMap & | operator= (SimpleGenericMap const &other) |
SimpleGenericMap & | operator= (SimpleGenericMap &&) noexcept=default |
SimpleGenericMap & | operator= (GenericMap< K > const &other) |
GenericMap< K >::size_type | size () const noexcept override |
Return the number of key-value pairs in the map. | |
bool | empty () const noexcept override |
Return true if this map contains no key-value pairs. | |
GenericMap< K >::size_type | max_size () const noexcept override |
Return the maximum number of elements the container is able to hold due to system or library implementation limitations. | |
bool | contains (K const &key) const override |
Return true if this map contains a mapping whose key has the specified label. | |
std::vector< K > const & | keys () const noexcept override |
Return the set of all keys, without type information. | |
void | clear () noexcept override |
Remove all of the mappings from this map. | |
template<typename T > | |
bool | insert (Key< K, T > const &key, T const &value) |
Insert an element into the map, if the map doesn't already contain a mapping with the same or a conflicting key. | |
template<typename T > | |
std::pair< Key< K, T >, bool > | insert (K const &key, T const &value) |
Insert an element into the map, if the map doesn't already contain a mapping with a conflicting key. | |
template<typename T > | |
bool | erase (Key< K, T > const &key) |
Remove the mapping for a key from this map, if it exists. | |
template<typename T > | |
size_type | count (Key< K, T > const &key) const |
Return the number of elements mapped to the specified key. | |
template<typename T > | |
bool | contains (Key< K, T > const &key) const |
Return true if this map contains a mapping for the specified key. | |
template<class Visitor > | |
auto | apply (Visitor &&visitor) const |
Apply an operation to each key-value pair in the map. | |
template<class Visitor > | |
auto | apply (Visitor &&visitor) |
Apply a modifying operation to each key-value pair in the map. | |
template<typename T , typename std::enable_if_t<!detail::IS_SMART_PTR< T >, int > = 0> | |
T & | at (Key< K, T > const &key) |
Return a reference to the mapped value of the element with key equal to key . | |
template<typename T , typename std::enable_if_t<!detail::IS_SMART_PTR< T >, int > = 0> | |
T const & | at (Key< K, T > const &key) const |
Return a reference to the mapped value of the element with key equal to key . | |
template<typename T , typename std::enable_if_t< std::is_base_of< Storable, T >::value, int > = 0> | |
std::shared_ptr< T > | at (Key< K, std::shared_ptr< T > > const &key) const |
Return a reference to the mapped value of the element with key equal to key . | |
virtual bool | operator== (GenericMap const &other) const noexcept |
Test for map equality. | |
bool | operator!= (GenericMap const &other) const |
Test for map equality. | |
Protected Types | |
using | StorableType |
The types that can be stored in a map. | |
using | ConstValueReference = decltype(_typeToConstRef(std::declval<StorableType>())) |
A type-agnostic reference to the value stored inside the map. | |
using | ValueReference = decltype(_typeToRef(std::declval<StorableType>())) |
A type-agnostic reference to the value stored inside the map. | |
Protected Member Functions | |
ConstValueReference | unsafeLookup (K key) const override |
Return a reference to the mapped value of the element with key equal to key . | |
bool | unsafeInsert (K key, StorableType &&value) override |
Create a new mapping with key equal to key and value equal to value . | |
bool | unsafeErase (K key) override |
Remove the mapping for a key from this map, if it exists. | |
ValueReference | unsafeLookup (K key) |
Return a reference to the mapped value of the element with key equal to key . | |
A GenericMap that allows insertion and deletion of arbitrary values.
In Python, a SimpleGenericMap behaves like a dict
. In particular, it will iterate over keys in the order they were added.
K | the key type of the map. Must be hashable. |
Definition at line 49 of file SimpleGenericMap.h.
|
protectedinherited |
A type-agnostic reference to the value stored inside the map.
These are the reference equivalents (T const&
or T&
) of StorableType.
Definition at line 369 of file GenericMap.h.
|
inherited |
Definition at line 83 of file GenericMap.h.
|
inherited |
Definition at line 81 of file GenericMap.h.
|
inherited |
Definition at line 82 of file GenericMap.h.
|
protectedinherited |
The types that can be stored in a map.
Keys of any subclass of Storable are implemented using PolymorphicValue to preserve type.
Definition at line 359 of file GenericMap.h.
|
protectedinherited |
A type-agnostic reference to the value stored inside the map.
These are the reference equivalents (T const&
or T&
) of StorableType.
Definition at line 370 of file GenericMap.h.
|
default |
|
default |
|
defaultnoexcept |
|
inline |
Convert another GenericMap into a SimpleGenericMap.
This constructor will insert key-value pairs following other
's iteration order. This may not be the order in which they were inserted into the original map.
Definition at line 65 of file SimpleGenericMap.h.
|
virtualdefaultnoexcept |
|
inlineinherited |
Apply a modifying operation to each key-value pair in the map.
Visitor | a callable that takes a key and a value. Requirements as for apply(Visitor&&) const, except that it may take non-const references to values. |
visitor | the visitor to apply |
Visitor
has a return value, a std::vector
of values returned from applying visitor
to each key in keys, in that order. Otherwise, void
.Visitor
is exception-safe.visitor
. Definition at line 331 of file GenericMap.h.
|
inlineinherited |
Apply an operation to each key-value pair in the map.
Visitor | a callable that takes a key and a value. See below for exact requirements. |
visitor | the visitor to apply |
Visitor
has a return value, a std::vector
of values returned from applying visitor
to each key in keys, in that order. Otherwise, void
.Visitor
, or strong exception safety if Visitor
cannot throw.A Visitor
must define one or more operator()
that take a weakly-typed key and a value. Each operator()
must return the same type (which may be void
). Through any combination of overloading or templates, the visitor must accept values of the following types:
bool
or bool const&
int
or int const&
long
or long const&
long long
or long long const&
float
or float const&
double
or double const&
std::string const&
Storable const&
std::shared_ptr<Storable const>
visitor
.An example visitor that prints each key-value pair to standard output:
template <typename K> class Printer { public: template <typename V> void operator()(K const& key, V const& value) { std::cout << key << ": " << value << "," << std::endl; } void operator()(K const& key, Storable const& value) { std::cout << key << ": "; try { std::cout << value; } catch (UnsupportedOperationException const&) { std::cout << "[unprintable]"; } std::cout << "," << std::endl; } void operator()(K const& key, std::shared_ptr<Storable const> value) { if (value != nullptr) { operator()(key, *value); } else { operator()(key, "null"); } } };
Definition at line 309 of file GenericMap.h.
|
inlineinherited |
Return a reference to the mapped value of the element with key equal to key
.
T | the type of the element mapped to key . It may be the exact type of the element, if known, or any type to which its references or pointers can be implicitly converted (e.g., a superclass). For example, references to built-in types are not convertible, so you can't retrieve an int with T=long . |
key | the key of the element to find |
T
mapped to key
, if one existspex::exceptions::OutOfRangeError | Thrown if the map does not have a T with the specified key |
Definition at line 121 of file GenericMap.h.
|
inlineinherited |
Return a reference to the mapped value of the element with key equal to key
.
T | the type of the element mapped to key . It may be the exact type of the element, if known, or any type to which its references or pointers can be implicitly converted (e.g., a superclass). For example, references to built-in types are not convertible, so you can't retrieve an int with T=long . |
key | the key of the element to find |
T
mapped to key
, if one existspex::exceptions::OutOfRangeError | Thrown if the map does not have a T with the specified key |
Definition at line 109 of file GenericMap.h.
|
inlineinherited |
Return a reference to the mapped value of the element with key equal to key
.
T | the type of the element mapped to key . It may be the exact type of the element, if known, or any type to which its references or pointers can be implicitly converted (e.g., a superclass). For example, references to built-in types are not convertible, so you can't retrieve an int with T=long . |
key | the key of the element to find |
T
mapped to key
, if one existspex::exceptions::OutOfRangeError | Thrown if the map does not have a T with the specified key |
Definition at line 115 of file GenericMap.h.
|
inlineoverridevirtualnoexcept |
Remove all of the mappings from this map.
After this call, the map will be empty.
Implements lsst::afw::typehandling::MutableGenericMap< K >.
Definition at line 99 of file SimpleGenericMap.h.
|
inlineoverridevirtual |
Return true
if this map contains a mapping whose key has the specified label.
More formally, this method returns true
if and only if this map contains a mapping with a key k
such that k.getId() == key
. There can be at most one such mapping.
key | the weakly-typed key to search for |
true
if this map contains a mapping for key
, regardless of value type.Implements lsst::afw::typehandling::GenericMap< K >.
Definition at line 95 of file SimpleGenericMap.h.
|
inlineinherited |
Return true
if this map contains a mapping for the specified key.
This is equivalent to testing whether at(key)
would succeed.
T | the value corresponding to key |
key | the key to search for |
true
if this map contains a mapping from the specified key to a T
true
, it calls unsafeLookup, then uses templates and RTTI to determine if the value is of the expected type. The performance of this method depends strongly on the performance of contains(K const&). Definition at line 194 of file GenericMap.h.
|
inlineinherited |
Return the number of elements mapped to the specified key.
T | the value corresponding to key |
key | key value of the elements to count |
T
with key key
, that is, either 1 or 0.Definition at line 157 of file GenericMap.h.
|
inlineoverridevirtualnoexcept |
Return true
if this map contains no key-value pairs.
Implements lsst::afw::typehandling::GenericMap< K >.
Definition at line 89 of file SimpleGenericMap.h.
|
inlineinherited |
Remove the mapping for a key from this map, if it exists.
T | the type of value the key maps to |
key | the key to remove |
true
if key
was removed, false
if it was not presentDefinition at line 676 of file GenericMap.h.
|
inlineinherited |
Insert an element into the map, if the map doesn't already contain a mapping with a conflicting key.
T | the type of value to insert |
key | key to insert |
value | value to insert |
true
if the insertion took place and false
otherwiseDefinition at line 654 of file GenericMap.h.
|
inlineinherited |
Insert an element into the map, if the map doesn't already contain a mapping with the same or a conflicting key.
T | the type of value to insert |
key | key to insert |
value | value to insert |
true
if the insertion took place, false
otherwiseT
to prevent insertion. Callers can safely assume this->contains(key.getId())
as a postcondition, but not this->contains(key)
.Definition at line 630 of file GenericMap.h.
|
inlineoverridevirtualnoexcept |
Return the set of all keys, without type information.
Implements lsst::afw::typehandling::GenericMap< K >.
Definition at line 97 of file SimpleGenericMap.h.
|
inlineoverridevirtualnoexcept |
Return the maximum number of elements the container is able to hold due to system or library implementation limitations.
Implements lsst::afw::typehandling::GenericMap< K >.
Definition at line 91 of file SimpleGenericMap.h.
|
inlineinherited |
Test for map equality.
Two GenericMap objects are considered equal if they map the same keys to the same values. The two objects do not need to have the same implementation class. If either class orders its keys, the order is ignored.
Definition at line 245 of file GenericMap.h.
|
inline |
Definition at line 77 of file SimpleGenericMap.h.
|
defaultnoexcept |
|
inline |
Definition at line 68 of file SimpleGenericMap.h.
|
inlinevirtualnoexceptinherited |
Test for map equality.
Two GenericMap objects are considered equal if they map the same keys to the same values. The two objects do not need to have the same implementation class. If either class orders its keys, the order is ignored.
Definition at line 229 of file GenericMap.h.
|
inlineoverridevirtualnoexcept |
Return the number of key-value pairs in the map.
Implements lsst::afw::typehandling::GenericMap< K >.
Definition at line 87 of file SimpleGenericMap.h.
|
inlineoverrideprotectedvirtual |
Remove the mapping for a key from this map, if it exists.
key | the key to remove |
true
if key
was removed, false
if it was not presentImplements lsst::afw::typehandling::MutableGenericMap< K >.
Definition at line 131 of file SimpleGenericMap.h.
|
inlineoverrideprotectedvirtual |
Create a new mapping with key equal to key
and value equal to value
.
This method is the primary way to implement the MutableGenericMap interface.
key | the key of the element to insert. The method may assume that the map does not contain key . |
value | a reference to the value to insert. |
true
if the insertion took place, false
otherwiseImplements lsst::afw::typehandling::MutableGenericMap< K >.
Definition at line 118 of file SimpleGenericMap.h.
|
inlineprotectedinherited |
Return a reference to the mapped value of the element with key equal to key
.
This method is the primary way to implement the GenericMap interface.
key | the key of the element to find |
key
, if one existspex::exceptions::OutOfRangeError | Thrown if the map does not have a value with the specified key |
Definition at line 391 of file GenericMap.h.
|
inlineoverrideprotectedvirtual |
Return a reference to the mapped value of the element with key equal to key
.
This method is the primary way to implement the GenericMap interface.
key | the key of the element to find |
key
, if one existspex::exceptions::OutOfRangeError | Thrown if the map does not have a value with the specified key |
Implements lsst::afw::typehandling::GenericMap< K >.
Definition at line 105 of file SimpleGenericMap.h.