LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
DetectorCollection.h
Go to the documentation of this file.
1 /*
2  * Developed for the LSST Data Management System.
3  * This product includes software developed by the LSST Project
4  * (https://www.lsst.org).
5  * See the COPYRIGHT file at the top-level directory of this distribution
6  * for details of code ownership.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef LSST_AFW_CAMERAGEOM_DETECTORCOLLECTION_H
23 #define LSST_AFW_CAMERAGEOM_DETECTORCOLLECTION_H
24 
25 #include <map>
26 #include <string>
27 #include <memory>
28 
29 #include "lsst/geom/Box.h"
32 
33 namespace lsst {
34 namespace afw {
35 namespace cameraGeom {
36 
48 template <typename T>
50 public:
51 
55 
56  virtual ~DetectorCollectionBase() noexcept = 0;
57 
59  NameMap const & getNameMap() const noexcept { return _nameDict; }
60 
62  IdMap const & getIdMap() const noexcept { return _idDict; }
63 
67  std::size_t size() const noexcept { return _idDict.size(); }
68 
72  bool empty() const noexcept { return _idDict.empty(); }
73 
81 
88  std::shared_ptr<T> operator[](int id) const;
89 
99  std::shared_ptr<T> get(std::string const & name, std::shared_ptr<T> def=nullptr) const;
100 
110  std::shared_ptr<T> get(int id, std::shared_ptr<T> def=nullptr) const;
111 
112 protected:
113 
114  explicit DetectorCollectionBase(List const & detectorList);
115 
116  DetectorCollectionBase() noexcept = default;
117 
120 
123 
136 
137  void remove(std::string const & name);
138  void remove(int id);
139 
140 private:
141  NameMap _nameDict; //< map keyed on name
142  IdMap _idDict; //< map keyed on id
143 };
144 
145 
149 class DetectorCollection : public DetectorCollectionBase<Detector const>,
150  public table::io::PersistableFacade<DetectorCollection>,
151  public table::io::Persistable {
152 public:
153 
154  DetectorCollection(List const & list);
155 
156  virtual ~DetectorCollection() noexcept;
157 
159  lsst::geom::Box2D const & getFpBBox() const noexcept { return _fpBBox; }
160 
161  // DetectorCollection is immutable, so it cannot be moveable. It is also
162  // always held by shared_ptr, so there is no good reason to copy it.
163  DetectorCollection(DetectorCollection const &) = delete;
165 
166  // DetectorCollection is immutable, so it cannot be assignable.
167  DetectorCollection & operator=(DetectorCollection const &) = delete;
169 
171  bool isPersistable() const noexcept override {
172  return true;
173  }
174 
175 protected:
176 
177  DetectorCollection(table::io::InputArchive const & archive, table::io::CatalogVector const & catalogs);
178 
179  std::string getPersistenceName() const override;
180 
181  std::string getPythonModule() const override;
182 
183  void write(OutputArchiveHandle& handle) const override;
184 
185 private:
186 
187  class Factory;
188 
189  lsst::geom::Box2D _fpBBox; //< bounding box of collection
190 };
191 
192 } // namespace cameraGeom
193 } // namespace afw
194 } // namespace lsst
195 
196 
197 #endif // LSST_AFW_CAMERAGEOM_DETECTORCOLLECTION_H
def write(self, patchRef, catalog)
Write the output.
std::vector< std::shared_ptr< T > > List
void add(std::shared_ptr< T > detector)
Add a detector to the collection.
T empty(T... args)
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
An object passed to Persistable::write to allow it to persist itself.
std::size_t size() const noexcept
Get the number of detectors.
std::shared_ptr< T > operator[](std::string const &name) const
Implement the [name] operator.
An abstract base class for collections of Detectors and specific subclasses thereof.
table::Key< int > id
Definition: Detector.cc:162
STL class.
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
bool empty() const noexcept
Determine if the collection contains any detectors.
lsst::geom::Box2D const & getFpBBox() const noexcept
Return a focal plane bounding box that encompasses all detectors.
A base class for image defects.
NameMap const & getNameMap() const noexcept
Get an unordered map keyed by name.
IdMap const & getIdMap() const noexcept
Get an unordered map keyed by ID.
table::Key< int > detector
An immutable collection of Detectors that can be accessed by name or ID.
T size(T... args)
A vector of catalogs used by Persistable.
Definition: CatalogVector.h:29
STL class.
DetectorCollectionBase & operator=(DetectorCollectionBase const &)=default
A multi-catalog archive object used to load table::io::Persistable objects.
Definition: InputArchive.h:31
bool isPersistable() const noexcept override
DetectorCollections are always persistable.
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
daf::base::PropertyList * list
Definition: fits.cc:903