LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
AliasMap.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 #ifndef AFW_TABLE_AliasMap_h_INCLUDED
3 #define AFW_TABLE_AliasMap_h_INCLUDED
4 
5 #include <map>
6 #include <string>
7 
8 namespace lsst { namespace afw { namespace table {
9 
10 class BaseTable;
11 
34 class AliasMap {
35  typedef std::map<std::string,std::string> Internal;
36 public:
37 
38  // Create an empty AliasMap
39  AliasMap() : _internal(), _table(0) {}
40 
46  AliasMap(AliasMap const & other) : _internal(other._internal), _table(0) {}
47 
49  typedef std::map<std::string,std::string>::const_iterator Iterator;
50 
52  Iterator begin() const { return _internal.begin(); }
53 
55  Iterator end() const { return _internal.end(); }
56 
58  std::size_t size() const { return _internal.size(); }
59 
61  bool empty() const { return _internal.empty(); }
62 
79  std::string apply(std::string const & name) const;
80 
88  std::string get(std::string const & alias) const;
89 
91  void set(std::string const & alias, std::string const & target);
92 
98  bool erase(std::string const & alias);
99 
101 
104  bool operator==(AliasMap const & other) const;
105  bool operator!=(AliasMap const & other) const { return !(other == *this); }
107 
109  bool contains(AliasMap const & other) const;
110 
111 private:
112 
113  friend class Schema;
114  friend class SubSchema;
115  friend class BaseTable;
116 
117  // Internal in-place implementation of apply()
118  void _apply(std::string & name) const;
119 
121 
122  // Table to notify of any changes. We can't use a shared_ptr here because the Table needs to set
123  // this in its own constructor, but the Table does guarantee that this pointer is either valid or
124  // null.
126 };
127 
128 }}} // namespace lsst::afw::table
129 
130 #endif // !AFW_TABLE_AliasMap_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:44
A proxy type for name lookups in a Schema.
Definition: Schema.h:340
bool empty() const
Return the true if there are no aliases.
Definition: AliasMap.h:61
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias-&gt;target pairs.
Definition: AliasMap.h:49
std::size_t size() const
Return the number of aliases.
Definition: AliasMap.h:58
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.
Mapping class that holds aliases for a Schema.
Definition: AliasMap.h:34
bool contains(AliasMap const &other) const
Return true if all aliases in this are also in other (with the same targets).
std::string apply(std::string const &name) const
Apply any aliases that match the given field name and return a de-aliased name.
AliasMap(AliasMap const &other)
Deep-copy an AliasMap.
Definition: AliasMap.h:46
std::map< std::string, std::string > Internal
Definition: AliasMap.h:35
void _apply(std::string &name) const
bool operator==(AliasMap const &other) const
Equality comparison.
Iterator end() const
Return a iterator to one past the end of the map.
Definition: AliasMap.h:55
Iterator begin() const
Return a iterator to the beginning of the map.
Definition: AliasMap.h:52
Base class for all tables.
Definition: BaseTable.h:43
bool operator!=(AliasMap const &other) const
Equality comparison.
Definition: AliasMap.h:105