LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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. | |
Public Member Functions | |
AliasMap () | |
AliasMap (AliasMap const &other) | |
Deep-copy an AliasMap. | |
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. | |
Iterator | end () const |
Return a iterator to one past the end of the map. | |
std::size_t | size () const |
Return the number of aliases. | |
bool | empty () const |
Return the true if there are no aliases. | |
std::string | apply (std::string const &name) const |
Apply any aliases that match the given field name and return a de-aliased name. | |
std::string | get (std::string const &alias) const |
Return the target of the given alias. | |
void | set (std::string const &alias, std::string const &target) |
Add an alias to the schema or replace an existing one. | |
bool | erase (std::string const &alias) |
Remove an alias from the schema if it is present. | |
bool | operator== (AliasMap const &other) const |
Equality comparison. | |
bool | operator!= (AliasMap const &other) const |
std::size_t | hash_value () const noexcept |
Return a hash of this object. | |
bool | contains (AliasMap const &other) const |
Return true if all aliases in this are also in other (with the same targets). | |
std::shared_ptr< BaseTable > | getTable () const |
void | setTable (std::shared_ptr< BaseTable > table) |
Friends | |
class | Schema |
class | SubSchema |
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.
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.
Return true if all aliases in this are also in other (with the same targets).
Definition at line 111 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 90 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.
|
inline |
Definition at line 121 of file AliasMap.h.
|
noexcept |
Return a hash of this object.
Definition at line 101 of file AliasMap.cc.
Definition at line 112 of file AliasMap.h.
Equality comparison.
Definition at line 99 of file AliasMap.cc.
void lsst::afw::table::AliasMap::set | ( | std::string const & | alias, |
std::string const & | target ) |
Add an alias to the schema or replace an existing one.
Definition at line 82 of file AliasMap.cc.
|
inline |
Definition at line 122 of file AliasMap.h.
|
inline |
Definition at line 125 of file AliasMap.h.
Definition at line 126 of file AliasMap.h.