LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.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 
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