Public Types | Private Types | Static Private Member Functions | List of all members
phot::OpDetVisibilityData< Cont, Mapping > Class Template Reference

A container for photon visibility mapping data. More...

#include <OpDetVisibilityData.h>

Inheritance diagram for phot::OpDetVisibilityData< Cont, Mapping >:
util::MappedContainer< Cont, Mapping > util::MappedContainerBase

Public Types

using DataContainer_t = Cont
 Type of the original container. More...
 
using Mapping_t = Mapping
 Type of the mapping object. More...
 
using size_type = std::size_t
 
using value_type = Value_t
 
- Public Types inherited from util::MappedContainer< Cont, Mapping >
using DataContainer_t = Cont
 Type of the original container. More...
 
using Mapping_t = Mapping
 Type of the mapping object. More...
 
using MappedContainer_t = MappedContainer< DataContainer_t, Mapping_t >
 Type of this class. More...
 
using DataIndex_t = util::collection_value_t< Mapping_t >
 Type of the index passed to the original container. More...
 
using MappingIndex_t = std::size_t
 Type of the index passed to the mapping. More...
 
using value_type = Value_t
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using reference = util::with_const_as_t< typename Storage_t::reference, util::collection_value_access_t< DataContainer_t > >
 
using const_reference = typename Storage_t::const_reference
 
using iterator = IteratorBase< MappedContainer_t, reference >
 
using const_iterator = IteratorBase< MappedContainer_t const, const_reference >
 

Public Member Functions

Validity information
 OpDetVisibilityData ()=default
 
 OpDetVisibilityData (DataContainer_t const &cont, Mapping_t const &mapping, size_type size, value_type defValue)
 Constructor: acquires data, mapping and a default value. More...
 
 OpDetVisibilityData (DataContainer_t const &cont, Mapping_t const &mapping, size_type size)
 Constructor: acquires data and mapping. More...
 
 OpDetVisibilityData (DataContainer_t const &cont, Mapping_t const &mapping)
 Constructor: acquires data and mapping. More...
 
bool isValid () const
 Returns whether the contained data is valid or not. More...
 
 operator bool () const
 Returns whether the container has valid data. More...
 
bool operator! () const
 Returns whether the container has no valid data. More...
 
- Public Member Functions inherited from util::MappedContainer< Cont, Mapping >
void setDefaultValue (value_type defValue)
 
 MappedContainer ()=default
 Default constructor: container will be unusable until assigned to. More...
 
 MappedContainer (DataContainer_t const &cont, Mapping_t const &mapping, size_type size, value_type defValue)
 Constructor: acquires data, mapping and a default value. More...
 
 MappedContainer (DataContainer_t const &cont, Mapping_t const &mapping, size_type size)
 Constructor: acquires data and mapping. More...
 
 MappedContainer (DataContainer_t const &cont, Mapping_t const &mapping)
 Constructor: acquires data and mapping. More...
 
size_type size () const
 Returns the nominal size of the container (after mapping). More...
 
size_type minimal_size () const
 Returns the minimum size to include all mapped values. More...
 
size_type max_size () const
 Returns the size of the largest possible container of this type. More...
 
bool empty () const
 Returns whether the container has no elements. More...
 
reference defaultValue ()
 Returns the default value for elements with no original content. More...
 
const_reference defaultValue () const
 
decltype(auto) operator[] (MappingIndex_t index) const
 Returns the content corresponding to the specified index. More...
 
decltype(auto) operator[] (MappingIndex_t index)
 
decltype(auto) at (MappingIndex_t index) const
 Returns the content corresponding to the specified index. More...
 
decltype(auto) at (MappingIndex_t index)
 
decltype(auto) front () const
 Returns the first element in the container. More...
 
decltype(auto) front ()
 
decltype(auto) back () const
 Returns the last element in the container. More...
 
decltype(auto) back ()
 
decltype(auto) map_index (MappingIndex_t index) const
 Returns the index in the original data which is mapped to index. More...
 
decltype(auto) map_index (MappingIndex_t index)
 
const_iterator cbegin () const
 Returns a constant iterator to the first mapped element. More...
 
const_iterator begin () const
 Returns a constant iterator to the first mapped element. More...
 
iterator begin ()
 Returns an iterator to the first mapped element. More...
 
const_iterator cend () const
 Returns a constant iterator past the last mapped element. More...
 
const_iterator end () const
 Returns a constant iterator past the last mapped element. More...
 
iterator end ()
 Returns an iterator past the last mapped element. More...
 

Private Types

using ContainerBase_t = util::MappedContainer< Cont, Mapping >
 

Static Private Member Functions

static size_type effectiveSize (DataContainer_t const &cont, size_type allegedSize)
 Determines whether the current content should be considered valid. More...
 
static size_type effectiveSize (DataContainer_t const &cont, Mapping_t const &mapping)
 Determines whether the current content should be considered valid. More...
 

Additional Inherited Members

- Static Public Attributes inherited from util::MappedContainer< Cont, Mapping >
static constexpr DataIndex_t InvalidIndex = invalidIndex<DataIndex_t>()
 
- Static Protected Member Functions inherited from util::MappedContainer< Cont, Mapping >
static size_type minimal_size (DataContainer_t const &cont, Mapping_t const &mapping)
 Returns the minimum size to include all mapped values. More...
 

Detailed Description

template<typename Cont, typename Mapping>
class phot::OpDetVisibilityData< Cont, Mapping >

A container for photon visibility mapping data.

This container is designed to replace the use of plain pointers to library data, adding an intermediate mapping layer.

A proper mapping allows to use symmetries of the detector to reduce the redundant size of the library, at the cost of some run time.

This container is used as a util::MappedContainer object, with the addition of being aware of whether the contained data is valid or not. The validity is estimated by considering the original data that is being mapped, that is the data from the library. If the data is invalid or empty, as it may be for a null pointer or an empty vector, the container data is also considered to be invalid.

Implementation notes

In the current implementation, the concept of data being invalid is implemented by forcing the nominal size of the container to be zero.

Known limitations

Currently the mapping of the optical detectors is forced to be a static collection of detector IDs. If more flexibility is needed, the design of the container internals need to be updated to allow run time polymorphism.

Given the type of validity detection described above, it takes extra steps to provide a default mapping for areas not covered by the library. While with plain util::MappedContainer that can be achieved by a empty data container and a mapping returning InvalidIndex for all optical detectors, here this would just yield to an invalid container. Instead, together with that mapping, some fake data needs to be supplied to phot::OpDetVisibilityData, which will be basically ignored and may be of any size larger than zero (or more precisely, phot::isValidLibraryData() must return false).

Definition at line 120 of file OpDetVisibilityData.h.

Member Typedef Documentation

template<typename Cont, typename Mapping>
using phot::OpDetVisibilityData< Cont, Mapping >::ContainerBase_t = util::MappedContainer<Cont, Mapping>
private

Definition at line 123 of file OpDetVisibilityData.h.

template<typename Cont, typename Mapping>
using util::MappedContainer< Cont, Mapping >::DataContainer_t = Cont

Type of the original container.

Definition at line 153 of file MappedContainer.h.

template<typename Cont, typename Mapping>
using util::MappedContainer< Cont, Mapping >::Mapping_t = Mapping

Type of the mapping object.

Definition at line 154 of file MappedContainer.h.

template<typename Cont, typename Mapping>
using util::MappedContainer< Cont, Mapping >::size_type = std::size_t

Definition at line 172 of file MappedContainer.h.

template<typename Cont, typename Mapping>
using util::MappedContainer< Cont, Mapping >::value_type = Value_t

Definition at line 170 of file MappedContainer.h.

Constructor & Destructor Documentation

template<typename Cont, typename Mapping>
phot::OpDetVisibilityData< Cont, Mapping >::OpDetVisibilityData ( )
default
template<typename Cont, typename Mapping>
phot::OpDetVisibilityData< Cont, Mapping >::OpDetVisibilityData ( DataContainer_t const &  cont,
Mapping_t const &  mapping,
size_type  size,
value_type  defValue 
)
inline

Constructor: acquires data, mapping and a default value.

Parameters
contcontainer with the data to be mapped
mappingthe mapping to be used
sizethe size of the container after mapping
defValuevalue to be used as default
See also
MappedContainer(DataContainer_t const&, Mapping_t const&, size_type, value_type)

This works as the equivalent util::MappedContainer constructor, except that if the data in cont is deemed invalid the size is overridden to zero.

Definition at line 165 of file OpDetVisibilityData.h.

171  : ContainerBase_t(cont, mapping, effectiveSize(cont, size), defValue)
172  {}
size_type size() const
Returns the nominal size of the container (after mapping).
util::MappedContainer< Cont, Mapping > ContainerBase_t
static size_type effectiveSize(DataContainer_t const &cont, size_type allegedSize)
Determines whether the current content should be considered valid.
template<typename Cont, typename Mapping>
phot::OpDetVisibilityData< Cont, Mapping >::OpDetVisibilityData ( DataContainer_t const &  cont,
Mapping_t const &  mapping,
size_type  size 
)
inline

Constructor: acquires data and mapping.

Parameters
contcontainer with the data to be mapped
mappingthe mapping to be used
sizethe size of the container after mapping
See also
MappedContainer(DataContainer_t const&, Mapping_t const&, size_type)

This works as the equivalent util::MappedContainer constructor, except that if the data in cont is deemed invalid the size is overridden to zero.

Definition at line 186 of file OpDetVisibilityData.h.

187  : ContainerBase_t(cont, mapping, effectiveSize(cont, size))
188  {}
size_type size() const
Returns the nominal size of the container (after mapping).
util::MappedContainer< Cont, Mapping > ContainerBase_t
static size_type effectiveSize(DataContainer_t const &cont, size_type allegedSize)
Determines whether the current content should be considered valid.
template<typename Cont, typename Mapping>
phot::OpDetVisibilityData< Cont, Mapping >::OpDetVisibilityData ( DataContainer_t const &  cont,
Mapping_t const &  mapping 
)
inline

Constructor: acquires data and mapping.

Parameters
contcontainer with the data to be mapped
mappingthe mapping to be used
See also
util::MappedContainer(DataContainer_t const&, Mapping_t const&, size_type)

The size of the container is declared to be the minimal one (see minimal_size()), unless data of the library cont is invalid, in which case the full container is invalid.

The default value is assigned as in util::MappedContainer(DataContainer_t const&, Mapping_t const&, size_type).

Definition at line 203 of file OpDetVisibilityData.h.

204  : ContainerBase_t(cont, mapping, effectiveSize(cont, mapping))
205  {}
util::MappedContainer< Cont, Mapping > ContainerBase_t
static size_type effectiveSize(DataContainer_t const &cont, size_type allegedSize)
Determines whether the current content should be considered valid.

Member Function Documentation

template<typename Cont , typename Mapping >
auto phot::OpDetVisibilityData< Cont, Mapping >::effectiveSize ( DataContainer_t const &  cont,
size_type  allegedSize 
)
staticprivate

Determines whether the current content should be considered valid.

Definition at line 398 of file OpDetVisibilityData.h.

399  { return isValidLibraryData(cont)? allegedSize: 0U; }
bool isValidLibraryData(Cont &&cont)
Returns the validity of content of library data in the container.
template<typename Cont , typename Mapping >
auto phot::OpDetVisibilityData< Cont, Mapping >::effectiveSize ( DataContainer_t const &  cont,
Mapping_t const &  mapping 
)
staticprivate

Determines whether the current content should be considered valid.

Definition at line 404 of file OpDetVisibilityData.h.

405  {
406  return isValidLibraryData(cont)
407  ? ContainerBase_t::minimal_size(cont, mapping)
408  : 0U
409  ;
410  } // OpDetVisibilityData::effectiveSize(DataContainer_t, Mapping_t)
size_type minimal_size() const
Returns the minimum size to include all mapped values.
bool isValidLibraryData(Cont &&cont)
Returns the validity of content of library data in the container.
template<typename Cont, typename Mapping>
bool phot::OpDetVisibilityData< Cont, Mapping >::isValid ( ) const
inline

Returns whether the contained data is valid or not.

Definition at line 216 of file OpDetVisibilityData.h.

216 { return !ContainerBase_t::empty(); }
bool empty() const
Returns whether the container has no elements.
template<typename Cont, typename Mapping>
phot::OpDetVisibilityData< Cont, Mapping >::operator bool ( ) const
inline

Returns whether the container has valid data.

Definition at line 219 of file OpDetVisibilityData.h.

219 { return isValid(); }
bool isValid() const
Returns whether the contained data is valid or not.
template<typename Cont, typename Mapping>
bool phot::OpDetVisibilityData< Cont, Mapping >::operator! ( ) const
inline

Returns whether the container has no valid data.

Definition at line 222 of file OpDetVisibilityData.h.

222 { return !isValid(); }
bool isValid() const
Returns whether the contained data is valid or not.

The documentation for this class was generated from the following file: