|
lsst.afw
13.0-91-g2a3e2ee
|
Mapping class that holds aliases for a Schema. More...
#include <AliasMap.h>
Public Types | |
| typedef std::map< std::string, std::string >::const_iterator | Iterator |
| An iterator over alias->target pairs. More... | |
Public Member Functions | |
| AliasMap () | |
| AliasMap (AliasMap const &other) | |
| Deep-copy an AliasMap. More... | |
| 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 | contains (AliasMap const &other) const |
| Return true if all aliases in this are also in other (with the same targets). More... | |
| bool | operator== (AliasMap const &other) const |
| Equality comparison. More... | |
| bool | operator!= (AliasMap const &other) const |
| Equality comparison. 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.
| typedef std::map<std::string, std::string>::const_iterator lsst::afw::table::AliasMap::Iterator |
An iterator over alias->target pairs.
Definition at line 51 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.
| 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");
|
inline |
Return a iterator to the beginning of the map.
Definition at line 54 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).
|
inline |
Return the true if there are no aliases.
Definition at line 63 of file AliasMap.h.
|
inline |
Return a iterator to one past the end of the map.
Definition at line 57 of file AliasMap.h.
| bool lsst::afw::table::AliasMap::erase | ( | std::string const & | alias | ) |
Remove an alias from the schema if it is present.
| 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 |
|
inline |
Equality comparison.
Definition at line 106 of file AliasMap.h.
| bool lsst::afw::table::AliasMap::operator== | ( | AliasMap const & | other | ) | const |
Equality comparison.
| 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.
|
inline |
Return the number of aliases.
Definition at line 60 of file AliasMap.h.
|
friend |
Definition at line 115 of file AliasMap.h.
|
friend |
Definition at line 113 of file AliasMap.h.
|
friend |
Definition at line 114 of file AliasMap.h.
1.8.5