LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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 { namespace afw { namespace table {
9 
10 class BaseTable;
11 
34 class AliasMap {
35  typedef std::map<std::string,std::string> Internal;
36 public:
37 
38  // Create an empty AliasMap
39  AliasMap() : _internal(), _table(0) {}
40 
46  AliasMap(AliasMap const & other) : _internal(other._internal), _table(0) {}
47 
49  typedef std::map<std::string,std::string>::const_iterator Iterator;
50 
52  Iterator begin() const { return _internal.begin(); }
53 
55  Iterator end() const { return _internal.end(); }
56 
58  std::size_t size() const { return _internal.size(); }
59 
61  bool empty() const { return _internal.empty(); }
62 
79  std::string apply(std::string const & name) const;
80 
88  std::string get(std::string const & alias) const;
89 
91  void set(std::string const & alias, std::string const & target);
92 
98  bool erase(std::string const & alias);
99 
100 private:
101 
102  friend class Schema;
103  friend class SubSchema;
104  friend class BaseTable;
105 
106  // Internal in-place implementation of apply()
107  void _apply(std::string & name) const;
108 
110 
111  // Table to notify of any changes. We can't use a shared_ptr here because the Table needs to set
112  // this in its own constructor, but the Table does guarantee that this pointer is either valid or
113  // null.
115 };
116 
117 }}} // namespace lsst::afw::table
118 
119 #endif // !AFW_TABLE_AliasMap_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
A proxy type for name lookups in a Schema.
Definition: Schema.h:370
AliasMap(AliasMap const &other)
Definition: AliasMap.h:46
void set(std::string const &alias, std::string const &target)
Add an alias to the schema or replace an existing one.
Mapping class that holds aliases for a Schema.
Definition: AliasMap.h:34
Iterator begin() const
Return a iterator to the beginning of the map.
Definition: AliasMap.h:52
std::string apply(std::string const &name) const
std::map< std::string, std::string > Internal
Definition: AliasMap.h:35
bool erase(std::string const &alias)
Remove an alias from the schema if it is present.
void _apply(std::string &name) const
bool empty() const
Return the true if there are no aliases.
Definition: AliasMap.h:61
Iterator end() const
Return a iterator to one past the end of the map.
Definition: AliasMap.h:55
std::size_t size() const
Return the number of aliases.
Definition: AliasMap.h:58
Base class for all tables.
Definition: BaseTable.h:44
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias-&gt;target pairs.
Definition: AliasMap.h:49