Alexandria  2.19
Please provide a description of the project.
Catalog.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 
27 #ifndef CATALOG_H_
28 #define CATALOG_H_
29 
30 #include <map>
31 #include <memory>
32 
33 #include "ElementsKernel/Export.h"
34 
35 #include "SourceCatalog/Source.h"
36 
37 namespace Euclid {
38 namespace SourceCatalog {
39 
48 
49 public:
63  explicit Catalog(std::vector<Source> source_vector);
64 
66 
70  virtual ~Catalog() = default;
71 
81  return m_source_vector.cbegin();
82  }
83 
92  const_iterator end() const {
93  return m_source_vector.cend();
94  }
95 
105  std::shared_ptr<Source> find(const Source::id_type& source_id) const;
106 
113  size_t size() const {
114  return m_source_vector.size();
115  }
116 
117 private:
118  // Vector of Source objects
119  std::vector<Source> m_source_vector{};
120  // Map of the Source identification and their location
121  // in the Source vector
122  std::map<Source::id_type, size_t> m_source_index_map{};
123 };
124 
125 } /* namespace SourceCatalog */
126 } // end of namespace Euclid
127 
128 #endif /* CATALOG_H_ */
Catalog contains a container of sources.
Definition: Catalog.h:47
virtual ~Catalog()=default
Destructor.
size_t size() const
Get the size of the vector container.
Definition: Catalog.h:113
const_iterator end() const
Get an const_iterator pointing to the last element in the m_source_vector vector.
Definition: Catalog.h:92
const_iterator begin() const
Get a const_iterator pointing to the first element in the m_source_vector vector.
Definition: Catalog.h:80
std::vector< Source >::const_iterator const_iterator
Definition: Catalog.h:65
boost::variant< int64_t, std::string > id_type
Definition: Source.h:51
#define ELEMENTS_API