List of all members | Public Member Functions | Private Attributes
utl::Validated< T > Class Template Reference

Wrapper class for initially unset data. More...

#include "utl/Validated.h"

Inheritance diagram for utl::Validated< T >:
Inheritance graph
[legend]

Public Member Functions

T & Get ()
 
const T & Get () const
 
bool IsValid () const
 
Validatedoperator= (const T &value)
 
void Set (const T &value)
 
void SetValid (const bool valid=true)
 
 Validated ()
 
 Validated (const T &value)
 

Private Attributes

bool fIsValid = false
 
fValue
 

Detailed Description

template<typename T>
class utl::Validated< T >

Wrapper class for initially unset data.

This class is intended as a replacement of lazy evaluation through pointers, i.e. when zero value of a pointer to some field indicates that this field has not been initialized yet. Previously, it was usualy done in the following way:

class Foo {
public:
Foo() : fField(0) { }
int GetField() const
{ if (!fField) FetchField(); return *fField; }
private:
void FetchField() const
{ fField = new int(GetFromSomewhere()); }
mutable int* fField;
};

This can now be replaced with more elegant construct which does not trash the heap allocator with small memory chunks:

class Foo {
public:
//Foo() // ctor not needed, default is invalid value
int GetField() const
{ if (!fField.IsValid()) FetchField(); return fField.Get(); }
private:
void FetchField() const { fField = GetFromSomewhere(); }
mutable utl::Validated<int> fField;
};
Author
Darko Veberic
Date
03 Nov 2008

Definition at line 17 of file ResponseMap.h.

Constructor & Destructor Documentation

template<typename T>
utl::Validated< T >::Validated ( )
inline

Definition at line 58 of file Validated.h.

template<typename T>
utl::Validated< T >::Validated ( const T &  value)
inline

Definition at line 60 of file Validated.h.

Member Function Documentation

template<typename T>
T& utl::Validated< T >::Get ( )
inline

Definition at line 68 of file Validated.h.

Referenced by rdet::AntennaType::BufferAntennaPattern(), rdet::AntennaType::GetAntennaData(), sdet::Station::GetAxes(), rdet::Channel::GetChannelData(), cdet::Station::GetCommissionTimeRange(), rdet::Station::GetCommissionTimeRange(), sdet::Station::GetCommissionTimeRange(), mdet::PMT::GetCrossTalkNormalizationFactor(), cdet::Station::GetDeadTime(), sdet::Station::GetFADCBinSize(), sdet::Station::GetFADCTraceLength(), sdet::Station::GetGroupId(), sdet::Station::GetHeight(), sdet::Station::GetLatchBin(), sdet::Station::GetLinerSigmaAlpha(), cdet::Station::GetListPadIds(), cdet::Station::GetName(), rdet::Station::GetName(), sdet::Station::GetName(), cdet::Station::GetNumberPadsX(), cdet::Station::GetNumberPadsY(), cdet::Station::GetNumberRPCChambers(), io::CorsikaShowerFileParticleIterator::GetOneParticle(), cdet::Station::GetPadArea(), cdet::Station::GetPadSizeX(), cdet::Station::GetPadSizeY(), rdet::Channel::GetPosition(), cdet::Station::GetPosition(), rdet::Station::GetPosition(), sdet::Station::GetPosition(), sdet::Station::GetRadius(), rdet::Channel::GetResponseMap(), cdet::Station::GetRPCHousingInnerDimensions(), cdet::Station::GetRPCHousingThickness(), cdet::Station::GetRPCSizeX(), cdet::Station::GetRPCSizeY(), sdet::Station::GetSaturationValue(), cdet::Station::GetTankSupportCentralFootBaseDimensions(), cdet::Station::GetTankSupportCentralFootDimensions(), cdet::Station::GetTankSupportOuterFootBaseDimensions(), cdet::Station::GetTankSupportOuterFootDimensions(), cdet::Station::GetTankSupportOuterFootDistanceToCenter(), cdet::Station::GetTankSupportTopSlabDimensions(), sdet::Station::GetThickness(), sdet::Station::GetTimingUncertainty(), sdet::Station::GetUUBCommissionTime(), sdet::Station::IsInAcquisition(), rdet::Station::IsInGrid(), cdet::Station::IsInGrid(), sdet::Station::IsInGrid(), io::RadioSimulation_ROOT::operator>>(), io::RadioSimulation_ROOT::RadioSimulation_ROOT(), sdet::Station::SetPartnerIds(), and cdet::Station::Update().

template<typename T>
const T& utl::Validated< T >::Get ( ) const
inline

Definition at line 70 of file Validated.h.

template<typename T>
bool utl::Validated< T >::IsValid ( ) const
inlinevirtual

Implements utl::VValidated.

Definition at line 64 of file Validated.h.

Referenced by rdet::AntennaType::GetAntennaData(), sdet::Station::GetAxes(), rdet::Channel::GetChannelData(), cdet::Station::GetCommissionTimeRange(), rdet::Station::GetCommissionTimeRange(), sdet::Station::GetCommissionTimeRange(), mdet::PMT::GetCrossTalkNormalizationFactor(), cdet::Station::GetDeadTime(), sdet::Station::GetFADCBinSize(), sdet::Station::GetFADCTraceLength(), sdet::Station::GetGroupId(), sdet::Station::GetHeight(), sdet::Station::GetLatchBin(), sdet::Station::GetLinerSigmaAlpha(), cdet::Station::GetListPadIds(), cdet::Station::GetName(), rdet::Station::GetName(), sdet::Station::GetName(), cdet::Station::GetNumberPadsX(), cdet::Station::GetNumberPadsY(), cdet::Station::GetNumberRPCChambers(), io::CorsikaShowerFileParticleIterator::GetOneParticle(), cdet::Station::GetPadArea(), cdet::Station::GetPadSizeX(), cdet::Station::GetPadSizeY(), rdet::Channel::GetPosition(), cdet::Station::GetPosition(), rdet::Station::GetPosition(), sdet::Station::GetPosition(), sdet::Station::GetRadius(), rdet::Channel::GetResponseMap(), cdet::Station::GetRPCHousingInnerDimensions(), cdet::Station::GetRPCHousingThickness(), cdet::Station::GetRPCSizeX(), cdet::Station::GetRPCSizeY(), sdet::Station::GetSaturationValue(), cdet::Station::GetTankSupportCentralFootBaseDimensions(), cdet::Station::GetTankSupportCentralFootDimensions(), cdet::Station::GetTankSupportOuterFootBaseDimensions(), cdet::Station::GetTankSupportOuterFootDimensions(), cdet::Station::GetTankSupportOuterFootDistanceToCenter(), cdet::Station::GetTankSupportTopSlabDimensions(), sdet::Station::GetThickness(), sdet::Station::GetTimingUncertainty(), sdet::Station::GetUUBCommissionTime(), evt::RadioSimulation::HasCorePosition(), sdet::Station::IsInAcquisition(), rdet::Station::IsInGrid(), cdet::Station::IsInGrid(), sdet::Station::IsInGrid(), io::RadioSimulation_ROOT::RadioSimulation_ROOT(), and sdet::Station::SetPartnerIds().

template<typename T>
Validated& utl::Validated< T >::operator= ( const T &  value)
inline

Definition at line 62 of file Validated.h.

template<typename T>
void utl::Validated< T >::Set ( const T &  value)
inline
template<typename T>
void utl::Validated< T >::SetValid ( const bool  valid = true)
inlinevirtual

Implements utl::VValidated.

Definition at line 66 of file Validated.h.

Referenced by io::CorsikaShowerFileParticleIterator::CorsikaShowerFileParticleIterator(), rdet::AntennaType::GetAntennaData(), sdet::Station::GetAxes(), rdet::Channel::GetChannelData(), cdet::Station::GetDeadTime(), sdet::Station::GetFADCTraceLength(), sdet::Station::GetGroupId(), sdet::Station::GetHeight(), sdet::Station::GetLatchBin(), cdet::Station::GetListPadIds(), cdet::Station::GetName(), rdet::Station::GetName(), sdet::Station::GetName(), cdet::Station::GetNumberPadsX(), cdet::Station::GetNumberPadsY(), cdet::Station::GetNumberRPCChambers(), io::CorsikaShowerFileParticleIterator::GetOneParticle(), cdet::Station::GetPadArea(), cdet::Station::GetPadSizeX(), cdet::Station::GetPadSizeY(), sdet::Station::GetRadius(), cdet::Station::GetRPCHousingInnerDimensions(), cdet::Station::GetRPCHousingThickness(), cdet::Station::GetRPCSizeX(), cdet::Station::GetRPCSizeY(), cdet::Station::GetTankSupportCentralFootBaseDimensions(), cdet::Station::GetTankSupportCentralFootDimensions(), cdet::Station::GetTankSupportOuterFootBaseDimensions(), cdet::Station::GetTankSupportOuterFootDimensions(), cdet::Station::GetTankSupportOuterFootDistanceToCenter(), cdet::Station::GetTankSupportTopSlabDimensions(), sdet::Station::GetThickness(), sdet::Station::GetTimingUncertainty(), rdet::Station::IsInGrid(), cdet::Station::IsInGrid(), sdet::Station::IsInGrid(), io::RadioSimulation_ROOT::operator>>(), sdet::Station::SetPartnerIds(), rdet::Channel::Update(), sdet::Scintillator::Update(), rdet::Station::Update(), and cdet::Station::Update().

Member Data Documentation

template<typename T>
bool utl::Validated< T >::fIsValid = false
private
template<typename T>
T utl::Validated< T >::fValue
private

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

, generated on Tue Sep 26 2023.