LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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:46
A proxy type for name lookups in a Schema.
Definition: Schema.h:330
table::Key< std::string > name
Definition: ApCorrMap.cc:71
bool operator==(AliasMap const &other) const
AliasMap(AliasMap const &other)
Definition: AliasMap.h:46
void set(std::string const &alias, std::string const &target)
Add an alias to the schema or replace an existing one.
Mapping class that holds aliases for a Schema.
Definition: AliasMap.h:34
Iterator begin() const
Return a iterator to the beginning of the map.
Definition: AliasMap.h:52
std::string apply(std::string const &name) const
bool operator!=(AliasMap const &other) const
Definition: AliasMap.h:105
std::map< std::string, std::string > Internal
Definition: AliasMap.h:35
bool erase(std::string const &alias)
Remove an alias from the schema if it is present.
void _apply(std::string &name) const
bool empty() const
Return the true if there are no aliases.
Definition: AliasMap.h:61
Iterator end() const
Return a iterator to one past the end of the map.
Definition: AliasMap.h:55
std::size_t size() const
Return the number of aliases.
Definition: AliasMap.h:58
Base class for all tables.
Definition: BaseTable.h:44
bool contains(AliasMap const &other) const
Return true if all aliases in this are also in other (with the same targets).
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias-&gt;target pairs.
Definition: AliasMap.h:49