LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
Mapping class that holds aliases for a Schema. More...
#include <AliasMap.h>
Public Types | |
using | Iterator = std::map< std::string, std::string >::const_iterator |
An iterator over alias->target pairs. More... | |
Public Member Functions | |
AliasMap () | |
AliasMap (AliasMap const &other) | |
Deep-copy an AliasMap. More... | |
AliasMap (AliasMap &&other) | |
AliasMap & | operator= (AliasMap const &)=default |
AliasMap & | operator= (AliasMap &&)=default |
~AliasMap ()=default | |
Iterator | begin () const |
Return a iterator to the beginning of the map. More... | |
Iterator | end () const |
Return a iterator to one past the end of the map. More... | |
std::size_t | size () const |
Return the number of aliases. More... | |
bool | empty () const |
Return the true if there are no aliases. More... | |
std::string | apply (std::string const &name) const |
Apply any aliases that match the given field name and return a de-aliased name. More... | |
std::string | get (std::string const &alias) const |
Return the target of the given alias. More... | |
void | set (std::string const &alias, std::string const &target) |
Add an alias to the schema or replace an existing one. More... | |
bool | erase (std::string const &alias) |
Remove an alias from the schema if it is present. More... | |
bool | operator== (AliasMap const &other) const |
Equality comparison. More... | |
bool | operator!= (AliasMap const &other) const |
std::size_t | hash_value () const noexcept |
Return a hash of this object. More... | |
bool | contains (AliasMap const &other) const |
Return true if all aliases in this are also in other (with the same targets). More... | |
Friends | |
class | Schema |
class | SubSchema |
class | BaseTable |
Mapping class that holds aliases for a Schema.
Aliases need not be complete, but they must match to the beginning of a field name to be useful. For example, if "a_b_c" is a true field name, "x_->a_b" is a valid alias that will cause "x_y_c" to map to "a_b_c", but "y_z->b_c" will not cause "a_y_z" to be matched.
Aliases are not checked to see if they match any existing fields, and if an alias has the same name as a field name, it will take precedence and hide the true field.
Unlike the other components of a Schema, aliases can be modified and removed, even after a Table has been constructed from the Schema.
AliasMaps are shared when Schemas are copy-constructed, but can be separated manually by calling Schema::disconnectAliases() or Schema::setAliasMap(). In addition, the AliasMap is deep-copied when used to construct a Table (or Catalog).
In order to allow Tables to react to changes in aliases (which may be used to define cached Keys held by the table, as in SourceTable's "slots" mechanism), an AliasMap that is part of a Schema held by a Table will hold a pointer to that Table, and call BaseTable::handleAliasChanges() when its aliases are set or removed.
Definition at line 36 of file AliasMap.h.
using lsst::afw::table::AliasMap::Iterator = std::map<std::string, std::string>::const_iterator |
An iterator over alias->target pairs.
Definition at line 57 of file AliasMap.h.
|
inline |
Definition at line 41 of file AliasMap.h.
|
inline |
Deep-copy an AliasMap.
The new AliasMap will not be linked to any tables, even if other is.
Definition at line 48 of file AliasMap.h.
|
inline |
Definition at line 50 of file AliasMap.h.
|
default |
std::string lsst::afw::table::AliasMap::apply | ( | std::string const & | name | ) | const |
Apply any aliases that match the given field name and return a de-aliased name.
Given a string that starts with any alias in the map, this returns a string with the part of the string that matches the alias replaced by that alias's target. The longest such alias is used.
For example:
m = AliasMap(); m.set("q", "a"); m.set("q1", "b"); assert(m.apply("q3") == "a3"); assert(m.apply("q12") == "b2");
Definition at line 67 of file AliasMap.cc.
|
inline |
Return a iterator to the beginning of the map.
Definition at line 60 of file AliasMap.h.
bool lsst::afw::table::AliasMap::contains | ( | AliasMap const & | other | ) | const |
Return true if all aliases in this are also in other (with the same targets).
Definition at line 109 of file AliasMap.cc.
|
inline |
Return the true if there are no aliases.
Definition at line 69 of file AliasMap.h.
|
inline |
Return a iterator to one past the end of the map.
Definition at line 63 of file AliasMap.h.
bool lsst::afw::table::AliasMap::erase | ( | std::string const & | alias | ) |
Remove an alias from the schema if it is present.
Definition at line 89 of file AliasMap.cc.
std::string lsst::afw::table::AliasMap::get | ( | std::string const & | alias | ) | const |
Return the target of the given alias.
Unlike apply(), this will not return partial matches.
pex::exceptions::NotFoundError | if no alias with the given name exists |
Definition at line 73 of file AliasMap.cc.
|
noexcept |
Return a hash of this object.
Definition at line 99 of file AliasMap.cc.
|
inline |
Definition at line 112 of file AliasMap.h.
bool lsst::afw::table::AliasMap::operator== | ( | AliasMap const & | other | ) | const |
Equality comparison.
Definition at line 97 of file AliasMap.cc.
void lsst::afw::table::AliasMap::set | ( | std::string const & | alias, |
std::string const & | target | ||
) |
|
inline |
|
friend |
Definition at line 124 of file AliasMap.h.
|
friend |
Definition at line 122 of file AliasMap.h.
|
friend |
Definition at line 123 of file AliasMap.h.