LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
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.