lsst.afw
g3a5ebb7d8a+28b83bf6a5
Toggle main menu visibility
Loading...
Searching...
No Matches
include
lsst
afw
table
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 {
37
using
Internal =
std::map<std::string, std::string>
;
38
39
public
:
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
;
53
AliasMap
&
operator=
(
AliasMap
&&) =
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(); }
122
void
setTable
(
std::shared_ptr<BaseTable>
table
) { _table =
table
; }
123
124
private
:
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.
136
std::weak_ptr<BaseTable>
_table;
137
};
138
}
// namespace table
139
}
// namespace afw
140
}
// namespace lsst
141
142
namespace
std
{
143
template
<>
144
struct
hash
<
lsst
::afw::table::AliasMap> {
145
using
argument_type
=
lsst::afw::table::AliasMap
;
146
using
result_type
=
size_t
;
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
std::string
lsst::afw::table::AliasMap
Mapping class that holds aliases for a Schema.
Definition
AliasMap.h:36
lsst::afw::table::AliasMap::contains
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
lsst::afw::table::AliasMap::operator!=
bool operator!=(AliasMap const &other) const
Definition
AliasMap.h:112
lsst::afw::table::AliasMap::AliasMap
AliasMap(AliasMap &&other)
Definition
AliasMap.h:50
lsst::afw::table::AliasMap::apply
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
lsst::afw::table::AliasMap::AliasMap
AliasMap(AliasMap const &other)
Deep-copy an AliasMap.
Definition
AliasMap.h:48
lsst::afw::table::AliasMap::size
std::size_t size() const
Return the number of aliases.
Definition
AliasMap.h:66
lsst::afw::table::AliasMap::setTable
void setTable(std::shared_ptr< BaseTable > table)
Definition
AliasMap.h:122
lsst::afw::table::AliasMap::getTable
std::shared_ptr< BaseTable > getTable() const
Definition
AliasMap.h:121
lsst::afw::table::AliasMap::begin
Iterator begin() const
Return a iterator to the beginning of the map.
Definition
AliasMap.h:60
lsst::afw::table::AliasMap::AliasMap
AliasMap()
Definition
AliasMap.h:41
lsst::afw::table::AliasMap::Iterator
std::map< std::string, std::string >::const_iterator Iterator
An iterator over alias->target pairs.
Definition
AliasMap.h:57
lsst::afw::table::AliasMap::SubSchema
friend class SubSchema
Definition
AliasMap.h:126
lsst::afw::table::AliasMap::~AliasMap
~AliasMap()=default
lsst::afw::table::AliasMap::Schema
friend class Schema
Definition
AliasMap.h:125
lsst::afw::table::AliasMap::erase
bool erase(std::string const &alias)
Remove an alias from the schema if it is present.
Definition
AliasMap.cc:90
lsst::afw::table::AliasMap::operator=
AliasMap & operator=(AliasMap const &)=default
lsst::afw::table::AliasMap::empty
bool empty() const
Return the true if there are no aliases.
Definition
AliasMap.h:69
lsst::afw::table::AliasMap::get
std::string get(std::string const &alias) const
Return the target of the given alias.
Definition
AliasMap.cc:73
lsst::afw::table::AliasMap::hash_value
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition
AliasMap.cc:101
lsst::afw::table::AliasMap::operator=
AliasMap & operator=(AliasMap &&)=default
lsst::afw::table::AliasMap::set
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
lsst::afw::table::AliasMap::operator==
bool operator==(AliasMap const &other) const
Equality comparison.
Definition
AliasMap.cc:99
lsst::afw::table::AliasMap::end
Iterator end() const
Return a iterator to one past the end of the map.
Definition
AliasMap.h:63
lsst::afw::table::BaseTable
Base class for all tables.
Definition
BaseTable.h:61
std::hash< lsst::afw::table::AliasMap >::hash
T hash(T... args)
std::map
lsst::afw::table
Definition
table.dox:3
lsst::afw
Definition
imageAlgorithm.dox:1
lsst
std
STL namespace.
std::shared_ptr
std::size_t
std::hash< lsst::afw::table::AliasMap >::argument_type
lsst::afw::table::AliasMap argument_type
Definition
AliasMap.h:145
std::hash< lsst::afw::table::AliasMap >::result_type
size_t result_type
Definition
AliasMap.h:146
std::hash< lsst::afw::table::AliasMap >::operator()
size_t operator()(argument_type const &obj) const noexcept
Definition
AliasMap.h:147
std::weak_ptr
Generated on
for lsst.afw by
1.17.0