Alexandria  2.19
Please provide a description of the project.
Source.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef SOURCE_H_
26 #define SOURCE_H_
27 
28 #include <boost/variant.hpp>
29 #include <memory>
30 #include <string>
31 #include <vector>
32 
34 
39 
40 namespace Euclid {
41 namespace SourceCatalog {
42 
48 class Source {
49 
50 public:
51  typedef boost::variant<int64_t, std::string> id_type;
52 
61  : m_source_id(source_id), m_attribute_vector(std::move(attributeVector)) {}
62 
64  virtual ~Source() {}
65 
70  id_type getId() const {
71  return m_source_id;
72  }
73 
87  template <typename T>
89 
90 private:
91  // Source identification
93 
94  // Vector of shared pointers to attribute
96 };
97 // Eof class Source
98 
105 class CastSourceIdVisitor : public boost::static_visitor<Source::id_type> {
106  template <typename From>
107  static constexpr bool is_integer() {
109  }
110 
111 public:
113 
115  return from;
116  }
117 
118  template <typename From>
119  Source::id_type operator()(const From& from, typename std::enable_if<is_integer<From>()>::type* = 0) const {
120  return Source::id_type(static_cast<int64_t>(from));
121  }
122 
123  template <typename From>
124  Source::id_type operator()(const From&, typename std::enable_if<!is_integer<From>()>::type* = 0) const {
125  throw Elements::Exception() << "Only std::string and int64_t are supported types for a source ID, got " << typeid(From).name()
126  << " instead";
127  }
128 };
129 
130 #define SOURCE_IMPL
132 #undef SOURCE_IMPL
133 
134 } /* namespace SourceCatalog */
135 } // end of namespace Euclid
136 
137 #if BOOST_VERSION < 105800
138 namespace boost {
139 
146  return !(a == b);
147 }
148 
149 } // namespace boost
150 #endif
151 
152 #endif /* SOURCE_H_ */
Coordinates.h
std::is_same
std::string
STL class.
std::shared_ptr
STL class.
Euclid::SourceCatalog::CastSourceIdVisitor::operator()
Source::id_type operator()(const From &from, typename std::enable_if< is_integer< From >()>::type *=0) const
Definition: Source.h:119
Euclid::SourceCatalog::CastSourceIdVisitor::operator()
Source::id_type operator()(const From &, typename std::enable_if<!is_integer< From >()>::type *=0) const
Definition: Source.h:124
Euclid::SourceCatalog::CastSourceIdVisitor::operator()
Source::id_type operator()(const std::string &from) const
Definition: Source.h:114
std::vector
STL class.
Photometry.h
Euclid::SourceCatalog::Source::Source
Source(id_type source_id, std::vector< std::shared_ptr< Attribute >> attributeVector)
Constructor.
Definition: Source.h:60
boost::operator!=
bool operator!=(const Euclid::SourceCatalog::Source::id_type &a, const Euclid::SourceCatalog::Source::id_type &b)
boost::variant specifies an equality operator (==), but, in older boost versions, not an inequality o...
Definition: Source.h:145
boost
Definition: array.h:33
Euclid::SourceCatalog::Source::getAttribute
std::shared_ptr< T > getAttribute() const
Get a pointer to source attribute of type T or a null pointer if the source do not contain an attribu...
Euclid::SourceCatalog::Source::getId
id_type getId() const
Get the source ID.
Definition: Source.h:70
std::enable_if
Euclid::SourceCatalog::Source::m_source_id
id_type m_source_id
Definition: Source.h:92
Euclid::SourceCatalog::CastSourceIdVisitor::CastSourceIdVisitor
CastSourceIdVisitor()
Definition: Source.h:112
Exception.h
Elements::Exception
Euclid::SourceCatalog::Source::m_attribute_vector
std::vector< std::shared_ptr< Attribute > > m_attribute_vector
Definition: Source.h:95
Euclid::SourceCatalog::CastSourceIdVisitor::is_integer
static constexpr bool is_integer()
Definition: Source.h:107
std::is_integral
Euclid::SourceCatalog::Source
The Source class includes all information related to a sky source.
Definition: Source.h:48
SpectroscopicRedshift.h
Source.icpp
std
STL namespace.
Euclid::SourceCatalog::Source::id_type
boost::variant< int64_t, std::string > id_type
Definition: Source.h:51
Euclid::SourceCatalog::Source::~Source
virtual ~Source()
Virtual default destructor.
Definition: Source.h:64
Euclid::SourceCatalog::CastSourceIdVisitor
This type can be used together with boost::apply_visitor to cast boost::variant with an unknown under...
Definition: Source.h:105
Euclid
Definition: InstOrRefHolder.h:29
Attribute.h