lsst.afw  14.0-25-g0e8fc950e+5
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 {
9 namespace afw {
10 namespace table {
11 
12 class BaseTable;
13 
36 class AliasMap {
38 
39 public:
40  // Create an empty AliasMap
41  AliasMap() : _internal(), _table(0) {}
42 
48  AliasMap(AliasMap const& other) : _internal(other._internal), _table(0) {}
49 
52 
54  Iterator begin() const { return _internal.begin(); }
55 
57  Iterator end() const { return _internal.end(); }
58 
60  std::size_t size() const { return _internal.size(); }
61 
63  bool empty() const { return _internal.empty(); }
64 
80  std::string apply(std::string const& name) const;
81 
89  std::string get(std::string const& alias) const;
90 
92  void set(std::string const& alias, std::string const& target);
93 
99  bool erase(std::string const& alias);
100 
102 
105  bool operator==(AliasMap const& other) const;
106  bool operator!=(AliasMap const& other) const { return !(other == *this); }
108 
110  bool contains(AliasMap const& other) const;
111 
112 private:
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 
120  Internal _internal;
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.
125  BaseTable* _table;
126 };
127 }
128 }
129 } // namespace lsst::afw::table
130 
131 #endif // !AFW_TABLE_AliasMap_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
T empty(T... args)
bool contains(AliasMap const &other) const
Return true if all aliases in this are also in other (with the same targets).
A proxy type for name lookups in a Schema.
Definition: Schema.h:348
std::size_t size() const
Return the number of aliases.
Definition: AliasMap.h:60
table::Key< std::string > name
Definition: ApCorrMap.cc:71
Iterator end() const
Return a iterator to one past the end of the map.
Definition: AliasMap.h:57
AliasMap(AliasMap const &other)
Deep-copy an AliasMap.
Definition: AliasMap.h:48
Mapping class that holds aliases for a Schema.
Definition: AliasMap.h:36
T end(T... args)
STL class.
A base class for image defects.
std::string apply(std::string const &name) const
Apply any aliases that match the given field name and return a de-aliased name.
bool operator!=(AliasMap const &other) const
Equality comparison.
Definition: AliasMap.h:106
bool operator==(AliasMap const &other) const
Equality comparison.
bool erase(std::string const &alias)
Remove an alias from the schema if it is present.
T size(T... args)
T begin(T... args)
Iterator begin() const
Return a iterator to the beginning of the map.
Definition: AliasMap.h:54
bool empty() const
Return the true if there are no aliases.
Definition: AliasMap.h:63
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias->target pairs.
Definition: AliasMap.h:51
Base class for all tables.
Definition: BaseTable.h:44