LSSTApplications
10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
|
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) | |
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 |
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 |
bool | operator!= (AliasMap const &other) const |
Private Types | |
typedef std::map< std::string, std::string > | Internal |
Private Member Functions | |
void | _apply (std::string &name) const |
Private Attributes | |
Internal | _internal |
BaseTable * | _table |
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 34 of file AliasMap.h.
|
private |
Definition at line 35 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 49 of file AliasMap.h.
|
inline |
Definition at line 39 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 46 of file AliasMap.h.
|
private |
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:
|
inline |
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 |
|
inline |
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 |
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 |
|
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.
|
private |
Definition at line 120 of file AliasMap.h.
|
private |
Definition at line 125 of file AliasMap.h.