LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
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 {
9 namespace afw {
10 namespace table {
11 
12 class BaseTable;
13 
36 class AliasMap final {
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  // Delegate to copy-constructor for backwards compatibility
51 
52  AliasMap& operator=(AliasMap const&) = default;
53  AliasMap& operator=(AliasMap&&) = default;
54  ~AliasMap() = default;
55 
58 
60  Iterator begin() const { return _internal.begin(); }
61 
63  Iterator end() const { return _internal.end(); }
64 
66  std::size_t size() const { return _internal.size(); }
67 
69  bool empty() const { return _internal.empty(); }
70 
86  std::string apply(std::string const& name) const;
87 
95  std::string get(std::string const& alias) const;
96 
98  void set(std::string const& alias, std::string const& target);
99 
105  bool erase(std::string const& alias);
106 
108 
111  bool operator==(AliasMap const& other) const;
112  bool operator!=(AliasMap const& other) const { return !(other == *this); }
114 
116  std::size_t hash_value() const noexcept;
117 
119  bool contains(AliasMap const& other) const;
120 
121 private:
122  friend class Schema;
123  friend class SubSchema;
124  friend class BaseTable;
125 
126  // Internal in-place implementation of apply()
127  void _apply(std::string& name) const;
128 
129  Internal _internal;
130 
131  // Table to notify of any changes. We can't use a shared_ptr here because the Table needs to set
132  // this in its own constructor, but the Table does guarantee that this pointer is either valid or
133  // null.
134  BaseTable* _table;
135 };
136 } // namespace table
137 } // namespace afw
138 } // namespace lsst
139 
140 namespace std {
141 template <>
142 struct hash<lsst::afw::table::AliasMap> {
145  size_t operator()(argument_type const& obj) const noexcept { return obj.hash_value(); }
146 };
147 } // namespace std
148 
149 #endif // !AFW_TABLE_AliasMap_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:50
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).
Definition: AliasMap.cc:109
A proxy type for name lookups in a Schema.
Definition: Schema.h:360
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: AliasMap.cc:99
std::size_t size() const
Return the number of aliases.
Definition: AliasMap.h:66
Iterator end() const
Return a iterator to one past the end of the map.
Definition: AliasMap.h:63
AliasMap(AliasMap const &other)
Deep-copy an AliasMap.
Definition: AliasMap.h:48
Mapping class that holds aliases for a Schema.
Definition: AliasMap.h:36
AliasMap & operator=(AliasMap const &)=default
STL namespace.
T end(T... args)
AliasMap(AliasMap &&other)
Definition: AliasMap.h:50
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.
Definition: AliasMap.cc:67
bool operator!=(AliasMap const &other) const
Equality comparison.
Definition: AliasMap.h:112
bool operator==(AliasMap const &other) const
Equality comparison.
Definition: AliasMap.cc:97
bool erase(std::string const &alias)
Remove an alias from the schema if it is present.
Definition: AliasMap.cc:89
Key< Flag > const & target
T size(T... args)
T begin(T... args)
size_t operator()(argument_type const &obj) const noexcept
Definition: AliasMap.h:145
Iterator begin() const
Return a iterator to the beginning of the map.
Definition: AliasMap.h:60
ItemVariant const * other
Definition: Schema.cc:56
bool empty() const
Return the true if there are no aliases.
Definition: AliasMap.h:69
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias->target pairs.
Definition: AliasMap.h:57
Base class for all tables.
Definition: BaseTable.h:44