LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
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
table::Key< std::string > name
Definition: Amplifier.cc:116
Key< Flag > const & target
ItemVariant const * other
Definition: Schema.cc:56
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
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias->target pairs.
Definition: AliasMap.h:57
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
AliasMap & operator=(AliasMap const &)=default
Iterator begin() const
Return a iterator to the beginning of the map.
Definition: AliasMap.h:60
bool erase(std::string const &alias)
Remove an alias from the schema if it is present.
Definition: AliasMap.cc:89
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
AliasMap & operator=(AliasMap &&)=default
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: AliasMap.cc:99
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:97
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
Defines the fields and offsets for a table.
Definition: Schema.h:50
A proxy type for name lookups in a Schema.
Definition: Schema.h:357
T empty(T... args)
T end(T... args)
class[[deprecated("Removed with no replacement (but see lsst::afw::image::TransmissionCurve). Will be " "removed after v22.")]] FilterProperty final
Describe the properties of a Filter (e.g.
Definition: Filter.h:53
A base class for image defects.
STL namespace.
T size(T... args)
size_t operator()(argument_type const &obj) const noexcept
Definition: AliasMap.h:145