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
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
lsst.afw.table::AliasMap Class Reference

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
 

Detailed Description

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.

Member Typedef Documentation

typedef std::map<std::string,std::string> lsst.afw.table::AliasMap::Internal
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.

Constructor & Destructor Documentation

lsst.afw.table::AliasMap::AliasMap ( )
inline

Definition at line 39 of file AliasMap.h.

39 : _internal(), _table(0) {}
lsst.afw.table::AliasMap::AliasMap ( AliasMap const &  other)
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.

46 : _internal(other._internal), _table(0) {}

Member Function Documentation

void lsst.afw.table::AliasMap::_apply ( std::string &  name) const
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:

* m = AliasMap();
* m.set("q", "a");
* m.set("q1", "b");
* assert(m.apply("q3") == "a3");
* assert(m.apply("q12") == "b2");
*
Iterator lsst.afw.table::AliasMap::begin ( void  ) const
inline

Return a iterator to the beginning of the map.

Definition at line 52 of file AliasMap.h.

52 { return _internal.begin(); }
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).

bool lsst.afw.table::AliasMap::empty ( ) const
inline

Return the true if there are no aliases.

Definition at line 61 of file AliasMap.h.

61 { return _internal.empty(); }
Iterator lsst.afw.table::AliasMap::end ( void  ) const
inline

Return a iterator to one past the end of the map.

Definition at line 55 of file AliasMap.h.

55 { return _internal.end(); }
bool lsst.afw.table::AliasMap::erase ( std::string const &  alias)

Remove an alias from the schema if it is present.

Returns
True if an alias was erased, and false if no such alias was found.
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.

Exceptions
pex::exceptions::NotFoundErrorif no alias with the given name exists
bool lsst.afw.table::AliasMap::operator!= ( AliasMap const &  other) const
inline

Equality comparison

Definition at line 105 of file AliasMap.h.

105 { return !(other == *this); }
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.

std::size_t lsst.afw.table::AliasMap::size ( ) const
inline

Return the number of aliases.

Definition at line 58 of file AliasMap.h.

58 { return _internal.size(); }

Friends And Related Function Documentation

friend class BaseTable
friend

Definition at line 115 of file AliasMap.h.

friend class Schema
friend

Definition at line 113 of file AliasMap.h.

friend class SubSchema
friend

Definition at line 114 of file AliasMap.h.

Member Data Documentation

Internal lsst.afw.table::AliasMap::_internal
private

Definition at line 120 of file AliasMap.h.

BaseTable* lsst.afw.table::AliasMap::_table
private

Definition at line 125 of file AliasMap.h.


The documentation for this class was generated from the following file: