Loading [MathJax]/extensions/tex2jax.js
LSST Applications 28.0.2,g0fba68d861+5b923b673a,g1fd858c14a+7a7b9dd5ed,g2c84ff76c0+5548bfee71,g30358e5240+f0e04ebe90,g35bb328faa+fcb1d3bbc8,g436fd98eb5+bdc6fcdd04,g4af146b050+742274f7cd,g4d2262a081+3efd3f8190,g4e0f332c67+cb09b8a5b6,g53246c7159+fcb1d3bbc8,g5a012ec0e7+477f9c599b,g5edb6fd927+826dfcb47f,g60b5630c4e+bdc6fcdd04,g67b6fd64d1+2218407a0c,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g87b7deb4dc+f9ac2ab1bd,g8852436030+ebf28f0d95,g89139ef638+2218407a0c,g9125e01d80+fcb1d3bbc8,g989de1cb63+2218407a0c,g9f33ca652e+42fb53f4c8,g9f7030ddb1+11b9b6f027,ga2b97cdc51+bdc6fcdd04,gab72ac2889+bdc6fcdd04,gabe3b4be73+1e0a283bba,gabf8522325+3210f02652,gb1101e3267+9c79701da9,gb58c049af0+f03b321e39,gb89ab40317+2218407a0c,gcf25f946ba+ebf28f0d95,gd6cbbdb0b4+e8f9c9c900,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+a08f294619,ge278dab8ac+3ef3db156b,ge410e46f29+2218407a0c,gf67bdafdda+2218407a0c
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
36class AliasMap final {
38
39public:
40 // Create an empty AliasMap
41 AliasMap() : _internal(), _table() {}
42
48 AliasMap(AliasMap const& other) : _internal(other._internal), _table() {}
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
116 std::size_t hash_value() const noexcept;
117
119 bool contains(AliasMap const& other) const;
120
121 std::shared_ptr<BaseTable> getTable() const { return _table.lock(); }
123
124private:
125 friend class Schema;
126 friend class SubSchema;
127
128 // Internal in-place implementation of apply()
129 void _apply(std::string& name) const;
130
131 Internal _internal;
132
133 // Table to notify of any changes. We can't use a shared_ptr here because the Table needs to set
134 // this in its own constructor, but the Table does guarantee that this pointer is either valid or
135 // null.
137};
138} // namespace table
139} // namespace afw
140} // namespace lsst
141
142namespace std {
143template <>
144struct hash<lsst::afw::table::AliasMap> {
147 size_t operator()(argument_type const& obj) const noexcept { return obj.hash_value(); }
148};
149} // namespace std
150
151#endif // !AFW_TABLE_AliasMap_h_INCLUDED
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:111
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
void setTable(std::shared_ptr< BaseTable > table)
Definition AliasMap.h:122
std::shared_ptr< BaseTable > getTable() const
Definition AliasMap.h:121
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:90
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:101
AliasMap & operator=(AliasMap &&)=default
void set(std::string const &alias, std::string const &target)
Add an alias to the schema or replace an existing one.
Definition AliasMap.cc:82
bool operator==(AliasMap const &other) const
Equality comparison.
Definition AliasMap.cc:99
Iterator end() const
Return a iterator to one past the end of the map.
Definition AliasMap.h:63
Base class for all tables.
Definition BaseTable.h:61
STL namespace.
lsst::afw::table::AliasMap argument_type
Definition AliasMap.h:145
size_t operator()(argument_type const &obj) const noexcept
Definition AliasMap.h:147