LSST Applications g180d380827+0f66a164bb,g2079a07aa2+86d27d4dc4,g2305ad1205+7d304bc7a0,g29320951ab+500695df56,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+e42ea45bea,g48712c4677+36a86eeaa5,g487adcacf7+2dd8f347ac,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+c70619cc9d,g5a732f18d5+53520f316c,g5ea96fc03c+341ea1ce94,g64a986408d+f7cd9c7162,g858d7b2824+f7cd9c7162,g8a8a8dda67+585e252eca,g99cad8db69+469ab8c039,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+c92fc63c7e,gbd866b1f37+f7cd9c7162,gc120e1dc64+02c66aa596,gc28159a63d+0e5473021a,gc3e9b769f7+b0068a2d9f,gcf0d15dbbd+e42ea45bea,gdaeeff99f8+f9a426f77a,ge6526c86ff+84383d05b3,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+f7cd9c7162,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
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
8namespace lsst {
9namespace afw {
10namespace table {
11
12class BaseTable;
13
38
39public:
40 // Create an empty AliasMap
41 AliasMap() : _internal(), _table(nullptr) {}
42
48 AliasMap(AliasMap const& other) : _internal(other._internal), _table(nullptr) {}
49 // Delegate to copy-constructor for backwards compatibility
50 AliasMap(AliasMap&& other) : AliasMap(other) {}
51
52 AliasMap& operator=(AliasMap const&) = default;
54 ~AliasMap() = default;
55
57 using Iterator = std::map<std::string, std::string>::const_iterator;
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
117
119 bool contains(AliasMap const& other) const;
120
121private:
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
140namespace std {
141template <>
142struct 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
Key< Flag > const & target
T begin(T... args)
Mapping class that holds aliases for a Schema.
Definition AliasMap.h:36
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
bool operator!=(AliasMap const &other) const
Definition AliasMap.h:112
AliasMap(AliasMap &&other)
Definition AliasMap.h:50
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
AliasMap(AliasMap const &other)
Deep-copy an AliasMap.
Definition AliasMap.h:48
std::size_t size() const
Return the number of aliases.
Definition AliasMap.h:66
Iterator begin() const
Return a iterator to the beginning of the map.
Definition AliasMap.h:60
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias->target pairs.
Definition AliasMap.h:57
bool erase(std::string const &alias)
Remove an alias from the schema if it is present.
Definition AliasMap.cc:89
AliasMap & operator=(AliasMap const &)=default
bool empty() const
Return the true if there are no aliases.
Definition AliasMap.h:69
std::string get(std::string const &alias) const
Return the target of the given alias.
Definition AliasMap.cc:73
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition AliasMap.cc:99
AliasMap & operator=(AliasMap &&)=default
bool operator==(AliasMap const &other) const
Equality comparison.
Definition AliasMap.cc:97
Iterator end() const
Return a iterator to one past the end of the map.
Definition AliasMap.h:63
Tag types used to declare specialized field types.
Definition misc.h:31
Base class for all tables.
Definition BaseTable.h:61
Defines the fields and offsets for a table.
Definition Schema.h:51
A proxy type for name lookups in a Schema.
Definition Schema.h:367
T empty(T... args)
T end(T... args)
daf::base::PropertySet * set
Definition fits.cc:931
STL namespace.
T size(T... args)
size_t operator()(argument_type const &obj) const noexcept
Definition AliasMap.h:145