Alexandria  2.14.1
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
75  class PhotometryConstIterator : public std::iterator<std::forward_iterator_tag,
76  const FluxErrorPair> {
77  public:
80  PhotometryConstIterator& operator++();
81  reference operator*();
82  bool operator==(const PhotometryConstIterator& other) const;
83  bool operator!=(const PhotometryConstIterator& other) const;
84  const std::string& filterName() const;
85  private:
88  };
90 
91 
103  std::vector<FluxErrorPair> value_vector) :
104  m_filter_name_vector_ptr(filter_name_vector_ptr), m_value_vector(
105  std::move(value_vector)) {
106  if (m_filter_name_vector_ptr == nullptr) {
107  throw Elements::Exception() << "Photometry filter names vector pointer is null";
108  }
109  // Only check the size, but not the consistency
110  if (m_filter_name_vector_ptr->size() != m_value_vector.size()) {
111  throw Elements::Exception()
112  << "Photometry filter names vector has different size than the values vector";
113  }
114  }
115 
117  virtual ~Photometry() {
118  }
119 
121  return const_iterator { m_filter_name_vector_ptr->cbegin(),
122  m_value_vector.cbegin() };
123  }
124 
125  const_iterator end() const {
126  return const_iterator { m_filter_name_vector_ptr->cend(),
127  m_value_vector.cend() };
128  }
129 
134  std::size_t size() const {
135  return m_filter_name_vector_ptr->size();
136  }
137 
147  std::unique_ptr<FluxErrorPair> find(std::string filter_name) const;
148 
149 private:
150 
153 
156 
157 };
158 // Eof class Photometry
159 
160 } /* namespace SourceCatalog */
161 } // end of namespace Euclid
162 
163 #endif /* PHOTOMETRY_H_ */
const_iterator end() const
Definition: Photometry.h:125
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:102
FluxErrorPair(double flux, double error, bool missing_photometry_flag=false, bool upper_limit_flag=false)
std::vector< FluxErrorPair >::const_iterator m_values_iter
Definition: Photometry.h:87
std::vector< std::string >::const_iterator m_filters_iter
Definition: Photometry.h:86
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:118
const_iterator begin() const
Definition: Photometry.h:120
std::size_t size() const
Return the size of the photometry map.
Definition: Photometry.h:134
STL class.
virtual ~Photometry()
default destructor
Definition: Photometry.h:117
#define ELEMENTS_API
PhotometryConstIterator const_iterator
Definition: Photometry.h:89
bool operator==(const FluxErrorPair &other) const
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:152
std::vector< FluxErrorPair > m_value_vector
The photometry map.
Definition: Photometry.h:155
bool operator!=(const FluxErrorPair &other) const