Template Class DetectorCollectionBase

Class Documentation

template<typename T>
class DetectorCollectionBase

An abstract base class for collections of Detectors and specific subclasses thereof.

This class provides the common interface and implementation for

DetectorCollection (which holds true Detector instances) and Camera::Builder (which holds Detector::InCameraBuilder instances). It is not intended to define an interface independent of those classes.
Template Parameters
  • T: Element type; either Detector or a subclass thereof.

Public Types

template<>
using NameMap = std::unordered_map<std::string, std::shared_ptr<T>>
template<>
using IdMap = std::map<int, std::shared_ptr<T>>
template<>
using List = 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

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.

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 to nullptr.

std::shared_ptr<T> get(int id, std::shared_ptr<T> def = nullptr) const

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 to nullptr.

Protected Functions

DetectorCollectionBase(List const &detectorList)
DetectorCollectionBase()
DetectorCollectionBase(DetectorCollectionBase const&)
DetectorCollectionBase(DetectorCollectionBase&&)
DetectorCollectionBase &operator=(DetectorCollectionBase const&)
DetectorCollectionBase &operator=(DetectorCollectionBase&&)
void add(std::shared_ptr<T> detector)

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)