Template Class DetectorCollectionBase¶
Defined in File DetectorCollection.h
Class Documentation¶
-
template<typename
T
>
classDetectorCollectionBase
¶ An abstract base class for collections of Detectors and specific subclasses thereof.
This class provides the common interface and implementation for
DetectorCollection
(which holds trueDetector
instances) andCamera::Builder
(which holdsDetector::InCameraBuilder
instances). It is not intended to define an interface independent of those classes.- Template Parameters
T
: Element type; eitherDetector
or a subclass thereof.
Public Types
-
template<>
usingNameMap
= std::unordered_map<std::string, std::shared_ptr<T>>¶
-
template<>
usingIdMap
= std::map<int, std::shared_ptr<T>>¶
-
template<>
usingList
= std::vector<std::shared_ptr<T>>¶
Public Functions
-
virtual
~DetectorCollectionBase
() = 0¶
-
NameMap const &
getNameMap
() const¶ Get an unordered map keyed by name.
-
IdMap const &
getIdMap
() const¶ Get an unordered map keyed by ID.
-
std::size_t
size
() const¶ Get the number of detectors. Renamed to
__len__
in Python.
-
bool
empty
() const¶ Determine if the collection contains any detectors.
-
std::shared_ptr<T>
operator[]
(std::string const &name) const¶ Implement the [name] operator
- Return
pointer to detector entry
- Parameters
[in] name
: detector name
-
std::shared_ptr<T>
operator[]
(int id) const¶ Implement the [id] operator
- Return
pointer to detector entry
- Parameters
[in] id
: detector name
Retrieve a detector by name, or fall back to a default.
- Return
pointer to detector entry if the entry exists, else return the default value
- Parameters
[in] name
: detector name[in] def
: default detector to return. This defaults tonullptr
.
Retrieve a detector by ID, or fall back to a default.
- Return
pointer to detector entry if the entry exists, else return the default value
- Parameters
[in] id
: detector id[in] def
: default detector to return. This defaults tonullptr
.
Protected Functions
-
DetectorCollectionBase
(List const &detectorList)¶
-
DetectorCollectionBase
()¶
-
DetectorCollectionBase
(DetectorCollectionBase const&)¶
-
DetectorCollectionBase
(DetectorCollectionBase&&)¶
-
DetectorCollectionBase &
operator=
(DetectorCollectionBase const&)¶
-
DetectorCollectionBase &
operator=
(DetectorCollectionBase&&)¶
Add a detector to the collection.
Strong for pex::exceptions::RuntimeError, weak (collection is made empty) otherwise.
- Parameters
[in] detector
: New detector to add to the collection.
- Exceptions
pex::exceptions::RuntimeError
: Thrown if the ID and/or name conflict with those of detectors already in the collection.
-
void
remove
(std::string const &name)¶
-
void
remove
(int id)¶