LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
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 
121  DetectorCollectionBase & operator=(DetectorCollectionBase const &) = default;
123 
135  void add(std::shared_ptr<T> detector);
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 
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.
165 
166  // DetectorCollection is immutable, so it cannot be assignable.
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
lsst::afw::cameraGeom::DetectorCollection::DetectorCollection
DetectorCollection(DetectorCollection &&)=delete
std::string
STL class.
std::shared_ptr
STL class.
Persistable.h
Box.h
std::vector
STL class.
std::map::size
T size(T... args)
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::table::io::InputArchive
A multi-catalog archive object used to load table::io::Persistable objects.
Definition: InputArchive.h:31
lsst::afw::cameraGeom::DetectorCollectionBase::size
std::size_t size() const noexcept
Get the number of detectors.
Definition: DetectorCollection.h:67
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::afw::cameraGeom::DetectorCollectionBase::remove
void remove(std::string const &name)
Definition: DetectorCollection.cc:129
lsst::afw::cameraGeom::DetectorCollectionBase::List
std::vector< std::shared_ptr< T > > List
Definition: DetectorCollection.h:54
lsst::afw::cameraGeom::DetectorCollection::DetectorCollection
DetectorCollection(DetectorCollection const &)=delete
lsst.pipe.tasks.mergeDetections.write
def write(self, patchRef, catalog)
Write the output.
Definition: mergeDetections.py:388
lsst::afw::cameraGeom::DetectorCollectionBase::getNameMap
NameMap const & getNameMap() const noexcept
Get a map keyed and ordered by name.
Definition: DetectorCollection.h:59
lsst::afw::cameraGeom::DetectorCollection::operator=
DetectorCollection & operator=(DetectorCollection const &)=delete
lsst::afw::cameraGeom::DetectorCollectionBase::operator[]
std::shared_ptr< T > operator[](std::string const &name) const
Implement the [name] operator.
Definition: DetectorCollection.cc:36
lsst::afw::cameraGeom::DetectorCollection::isPersistable
bool isPersistable() const noexcept override
DetectorCollections are always persistable.
Definition: DetectorCollection.h:171
lsst::afw::cameraGeom::DetectorCollectionBase::empty
bool empty() const noexcept
Determine if the collection contains any detectors.
Definition: DetectorCollection.h:72
lsst::afw::cameraGeom::DetectorCollection::operator=
DetectorCollection & operator=(DetectorCollection &&)=delete
lsst::afw::cameraGeom::DetectorCollectionBase::get
std::shared_ptr< T > get(std::string const &name, std::shared_ptr< T > def=nullptr) const
Retrieve a detector by name, or fall back to a default.
Definition: DetectorCollection.cc:56
lsst::afw::table::io::CatalogVector
A vector of catalogs used by Persistable.
Definition: CatalogVector.h:29
lsst::afw::cameraGeom::DetectorCollectionBase::~DetectorCollectionBase
virtual ~DetectorCollectionBase() noexcept=0
std::map< int, std::shared_ptr< Detector::InCameraBuilder > >
lsst::afw::cameraGeom::DetectorCollectionBase::getIdMap
IdMap const & getIdMap() const noexcept
Get a map keyed and ordered by ID.
Definition: DetectorCollection.h:62
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::cameraGeom::DetectorCollection
An immutable collection of Detectors that can be accessed by name or ID.
Definition: DetectorCollection.h:151
lsst::afw::cameraGeom::DetectorCollectionBase::DetectorCollectionBase
DetectorCollectionBase() noexcept=default
lsst::geom
Definition: AffineTransform.h:36
lsst::afw::image.slicing.Factory
Factory
Definition: slicing.py:252
list
daf::base::PropertyList * list
Definition: fits.cc:913
std
STL namespace.
lsst::afw::cameraGeom::DetectorCollectionBase::add
void add(std::shared_ptr< T > detector)
Add a detector to the collection.
Definition: DetectorCollection.cc:89
detector
table::Key< int > detector
Definition: DetectorCollection.cc:172
std::map::empty
T empty(T... args)
lsst::afw::cameraGeom::DetectorCollection::~DetectorCollection
virtual ~DetectorCollection() noexcept
std::size_t
lsst::geom::Box2D
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
std::unordered_map< std::string, std::shared_ptr< Detector::InCameraBuilder > >
Detector.h
lsst::afw::cameraGeom::Detector
A representation of a detector in a mosaic camera.
Definition: Detector.h:185
lsst::afw::cameraGeom::DetectorCollectionBase
An abstract base class for collections of Detectors and specific subclasses thereof.
Definition: DetectorCollection.h:49