LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
details::PointerToData_t< T > Class Template Reference

Public Types

using value_type = T
 
using const_value_type = std::add_const_t< value_type >
 
using reference = std::add_lvalue_reference_t< value_type >
 
using const_reference = std::add_lvalue_reference_t< const_value_type >
 
using pointer = std::add_pointer_t< value_type >
 
using const_pointer = std::add_pointer_t< const_value_type >
 

Public Member Functions

 ~PointerToData_t ()
 Destructor: gets rid of the owned data. More...
 
 operator bool () const
 Returns whether we point to something. More...
 
bool operator! () const
 Returns whether we point to nothing. More...
 
bool hasData () const
 Returns whether we have data. More...
 
bool owned () const
 Returns whether we have data and we own it. More...
 
void SetData (pointer data, bool owned)
 Sets the data and the ownership. More...
 
void AcquireData (pointer data)
 Acquire ownership of the specified data. More...
 
void PointToData (pointer data)
 Point to the specified data, not acquiring ownership. More...
 
void PointToData (reference data)
 Point to the specified data, not acquiring ownership. More...
 
void StealData (std::remove_const_t< T > &&data)
 Move data from the specified object, and own it. More...
 
void NewData (T const &data)
 Create a owned copy of the specified object. More...
 
void Clear ()
 Stop pointing to the data; if owned, delete it. More...
 
Dereferencing
const_reference operator* () const
 
reference operator* ()
 
const_pointer operator-> () const
 
pointer operator-> ()
 

Protected Attributes

bool bOwned = false
 whether we own our data More...
 
pointer pData = nullptr
 pointer to data More...
 

Detailed Description

template<typename T>
class details::PointerToData_t< T >

Todo:
Document this code and make it into a library

Definition at line 108 of file RawDataDrawer.cxx.

Member Typedef Documentation

template<typename T >
using details::PointerToData_t< T >::const_pointer = std::add_pointer_t<const_value_type>

Definition at line 115 of file RawDataDrawer.cxx.

template<typename T >
using details::PointerToData_t< T >::const_reference = std::add_lvalue_reference_t<const_value_type>

Definition at line 113 of file RawDataDrawer.cxx.

template<typename T >
using details::PointerToData_t< T >::const_value_type = std::add_const_t<value_type>

Definition at line 111 of file RawDataDrawer.cxx.

template<typename T >
using details::PointerToData_t< T >::pointer = std::add_pointer_t<value_type>

Definition at line 114 of file RawDataDrawer.cxx.

template<typename T >
using details::PointerToData_t< T >::reference = std::add_lvalue_reference_t<value_type>

Definition at line 112 of file RawDataDrawer.cxx.

template<typename T >
using details::PointerToData_t< T >::value_type = T

Definition at line 110 of file RawDataDrawer.cxx.

Constructor & Destructor Documentation

template<typename T >
details::PointerToData_t< T >::~PointerToData_t ( )
inline

Destructor: gets rid of the owned data.

Definition at line 118 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::Clear().

118 { Clear(); }
void Clear()
Stop pointing to the data; if owned, delete it.

Member Function Documentation

template<typename T >
void details::PointerToData_t< T >::AcquireData ( pointer  data)
inline

Acquire ownership of the specified data.

Definition at line 149 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::SetData().

Referenced by details::PointerToData_t< T >::NewData(), and details::PointerToData_t< T >::StealData().

149 { SetData(data, true); }
void SetData(pointer data, bool owned)
Sets the data and the ownership.
template<typename T >
void details::PointerToData_t< T >::Clear ( )
inline

Stop pointing to the data; if owned, delete it.

Definition at line 159 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::bOwned, and details::PointerToData_t< T >::pData.

Referenced by evd::details::RawDigitCacheDataClass::empty(), evd::details::RawDigitInfo_t::MaxCharge(), details::PointerToData_t< T >::SetData(), and details::PointerToData_t< T >::~PointerToData_t().

160  {
161  if (bOwned) delete pData;
162  pData = nullptr;
163  bOwned = false;
164  } // Clear()
bool bOwned
whether we own our data
pointer pData
pointer to data
template<typename T >
bool details::PointerToData_t< T >::hasData ( ) const
inline

Returns whether we have data.

Definition at line 136 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::pData.

Referenced by details::PointerToData_t< T >::operator bool(), details::PointerToData_t< T >::operator!(), and details::PointerToData_t< T >::owned().

136 { return bool(pData); }
pointer pData
pointer to data
template<typename T >
void details::PointerToData_t< T >::NewData ( T const &  data)
inline

Create a owned copy of the specified object.

Definition at line 157 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::AcquireData().

157 { AcquireData(new T(data)); }
void AcquireData(pointer data)
Acquire ownership of the specified data.
template<typename T >
details::PointerToData_t< T >::operator bool ( ) const
inline

Returns whether we point to something.

Definition at line 130 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::hasData().

130 { return hasData(); }
bool hasData() const
Returns whether we have data.
template<typename T >
bool details::PointerToData_t< T >::operator! ( ) const
inline

Returns whether we point to nothing.

Definition at line 133 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::hasData().

133 { return !hasData(); }
bool hasData() const
Returns whether we have data.
template<typename T >
const_reference details::PointerToData_t< T >::operator* ( ) const
inline

Definition at line 122 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::pData.

122 { return *pData; }
pointer pData
pointer to data
template<typename T >
reference details::PointerToData_t< T >::operator* ( )
inline

Definition at line 123 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::pData.

123 { return *pData; }
pointer pData
pointer to data
template<typename T >
const_pointer details::PointerToData_t< T >::operator-> ( ) const
inline

Definition at line 125 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::pData.

125 { return pData; }
pointer pData
pointer to data
template<typename T >
pointer details::PointerToData_t< T >::operator-> ( )
inline

Definition at line 126 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::pData.

126 { return pData; }
pointer pData
pointer to data
template<typename T >
bool details::PointerToData_t< T >::owned ( ) const
inline

Returns whether we have data and we own it.

Definition at line 139 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::bOwned, and details::PointerToData_t< T >::hasData().

Referenced by details::PointerToData_t< T >::SetData().

139 { return bOwned && hasData(); }
bool bOwned
whether we own our data
bool hasData() const
Returns whether we have data.
template<typename T >
void details::PointerToData_t< T >::PointToData ( pointer  data)
inline

Point to the specified data, not acquiring ownership.

Definition at line 151 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::SetData().

151 { SetData(data, false); }
void SetData(pointer data, bool owned)
Sets the data and the ownership.
template<typename T >
void details::PointerToData_t< T >::PointToData ( reference  data)
inline

Point to the specified data, not acquiring ownership.

Definition at line 153 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::SetData().

153 { SetData(&data, false); }
void SetData(pointer data, bool owned)
Sets the data and the ownership.
template<typename T >
void details::PointerToData_t< T >::SetData ( pointer  data,
bool  owned 
)
inline

Sets the data and the ownership.

Definition at line 142 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::bOwned, details::PointerToData_t< T >::Clear(), details::PointerToData_t< T >::owned(), and details::PointerToData_t< T >::pData.

Referenced by details::PointerToData_t< T >::AcquireData(), and details::PointerToData_t< T >::PointToData().

143  {
144  Clear();
145  bOwned = owned;
146  pData = data;
147  }
bool bOwned
whether we own our data
pointer pData
pointer to data
void Clear()
Stop pointing to the data; if owned, delete it.
bool owned() const
Returns whether we have data and we own it.
template<typename T >
void details::PointerToData_t< T >::StealData ( std::remove_const_t< T > &&  data)
inline

Move data from the specified object, and own it.

Definition at line 155 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::AcquireData().

155 { AcquireData(new T(std::move(data))); }
void AcquireData(pointer data)
Acquire ownership of the specified data.

Member Data Documentation

template<typename T >
bool details::PointerToData_t< T >::bOwned = false
protected

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