Alexandria  2.16
Please provide a description of the project.
Photometry.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 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 
26 #ifndef PHOTOMETRY_H_
27 #define PHOTOMETRY_H_
28 
29 #include <memory>
30 #include <vector>
31 #include <iterator>
32 
33 #include "ElementsKernel/Export.h"
35 
37 
38 namespace Euclid {
39 namespace SourceCatalog {
40 
41 struct FluxErrorPair {
42  double flux;
43  double error;
46  FluxErrorPair(double flux, double error, bool missing_photometry_flag=false,
47  bool upper_limit_flag=false);
48  FluxErrorPair(const FluxErrorPair&) = default;
49  bool operator==(const FluxErrorPair& other) const;
50  bool operator!=(const FluxErrorPair& other) const;
51 };
52 
68 
69 public:
70 
76  template <bool Const>
78  : public std::iterator<std::forward_iterator_tag, typename std::conditional<Const, const FluxErrorPair, FluxErrorPair>::type> {
79  public:
83 
86 
91 
95  PhotometryIterator& operator++();
96 
100  bool operator == (const PhotometryIterator& other) const;
101 
105  bool operator != (const PhotometryIterator& other) const;
106 
110  reference operator*();
111 
115  pointer operator ->();
116 
120  ssize_t operator - (const PhotometryIterator& other) const;
121 
125  const std::string& filterName() const;
126 
127  protected:
135  PhotometryIterator(const filters_iter_t& filters_iter, const values_iter_t& values_iter);
136 
137  friend class Photometry;
138 
139  private:
142  };
143 
146 
147 
159  std::vector<FluxErrorPair> value_vector) :
160  m_filter_name_vector_ptr(filter_name_vector_ptr), m_value_vector(
161  std::move(value_vector)) {
162  if (m_filter_name_vector_ptr == nullptr) {
163  throw Elements::Exception() << "Photometry filter names vector pointer is null";
164  }
165  // Only check the size, but not the consistency
166  if (m_filter_name_vector_ptr->size() != m_value_vector.size()) {
167  throw Elements::Exception()
168  << "Photometry filter names vector has different size than the values vector";
169  }
170  }
171 
173  virtual ~Photometry() = default;
174 
176  return const_iterator{m_filter_name_vector_ptr->cbegin(), m_value_vector.cbegin()};
177  }
178 
180  return const_iterator{m_filter_name_vector_ptr->cend(), m_value_vector.cend()};
181  }
182 
184  return const_iterator{m_filter_name_vector_ptr->cbegin(), m_value_vector.cbegin()};
185  }
186 
187  const_iterator end() const {
188  return const_iterator{m_filter_name_vector_ptr->cend(), m_value_vector.cend()};
189  }
190 
192  return iterator{m_filter_name_vector_ptr->begin(), m_value_vector.begin()};
193  }
194 
196  return iterator{m_filter_name_vector_ptr->end(), m_value_vector.end()};
197  }
198 
203  std::size_t size() const {
204  return m_filter_name_vector_ptr->size();
205  }
206 
216  std::unique_ptr<FluxErrorPair> find(std::string filter_name) const;
217 
218  const std::shared_ptr<std::vector<std::string>>& getFilterNames() const;
219 
220 private:
221 
224 
227 
228 };
229 // Eof class Photometry
230 
231 #define PHOTOMETRY_IMPL
233 #undef PHOTOMETRY_IMPL
234 
235 } /* namespace SourceCatalog */
236 } // end of namespace Euclid
237 
238 #endif /* PHOTOMETRY_H_ */
STL class.
Attribute interface extended by all source attributes.
Definition: Attribute.h:41
Photometry(std::shared_ptr< std::vector< std::string >> filter_name_vector_ptr, std::vector< FluxErrorPair > value_vector)
Constructor which should never be called directly. Use the PhotometryAttributeHandler to build Photom...
Definition: Photometry.h:158
PhotometryIterator< false > iterator
Definition: Photometry.h:145
std::size_t size() const
Return the size of the photometry map.
Definition: Photometry.h:203
FluxErrorPair(double flux, double error, bool missing_photometry_flag=false, bool upper_limit_flag=false)
typename std::conditional< Const, std::vector< FluxErrorPair >::const_iterator, std::vector< FluxErrorPair >::iterator >::type values_iter_t
Definition: Photometry.h:85
const_iterator end() const
Definition: Photometry.h:187
typename std::conditional< Const, const FluxErrorPair, FluxErrorPair >::type value_t
Definition: Photometry.h:80
STL namespace.
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:149
bool operator!=(const FluxErrorPair &other) const
bool operator==(const FluxErrorPair &other) const
STL class.
const_iterator begin() const
Definition: Photometry.h:183
const_iterator cbegin() const
Definition: Photometry.h:175
#define ELEMENTS_API
PhotometryIterator< true > const_iterator
Definition: Photometry.h:144
typename std::conditional< Const, std::vector< std::string >::const_iterator, std::vector< std::string >::iterator >::type filters_iter_t
Definition: Photometry.h:84
const_iterator cend() const
Definition: Photometry.h:179
STL class.
STL class.
std::shared_ptr< std::vector< std::string > > m_filter_name_vector_ptr
Shared pointer to the common list of filter names.
Definition: Photometry.h:223
std::vector< FluxErrorPair > m_value_vector
The photometry map.
Definition: Photometry.h:226