ATLAS Offline Software
Public Member Functions | Private Types | Private Attributes | Friends | List of all members
CaloRecGPU::Helpers::SimpleHolder< T, Context, true > Class Template Reference

#include <Helpers.h>

Collaboration diagram for CaloRecGPU::Helpers::SimpleHolder< T, Context, true >:

Public Member Functions

CUDA_HOS_DEV const T & operator* () const
 
CUDA_HOS_DEV T & operator* ()
 
CUDA_HOS_DEV const T * operator-> () const
 
CUDA_HOS_DEV T * operator-> ()
 
CUDA_HOS_DEV bool valid () const
 
void clear ()
 
void allocate ()
 
 SimpleHolder ()
 
 SimpleHolder (const bool really_allocate)
 
template<class X , class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
 SimpleHolder (X *other_p)
 
template<class X , class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
 SimpleHolder (const X &other_v)
 
 SimpleHolder (const SimpleHolder &other)
 
template<class X , class other_context , bool other_hold, class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
 SimpleHolder (const SimpleHolder< X, other_context, other_hold > &other)
 
 SimpleHolder (SimpleHolder &&other)
 
template<class X , class other_context , class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
 SimpleHolder (SimpleHolder< X, other_context, true > &&other)
 
SimpleHolderoperator= (const SimpleHolder &other)
 
template<class X , class other_context , bool other_hold, class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
SimpleHolderoperator= (const SimpleHolder< X, other_context, other_hold > &other)
 
SimpleHolderoperator= (SimpleHolder &&other)
 
template<class X , class other_context , class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
SimpleHolderoperator= (SimpleHolder< X, other_context, true > &&other)
 
 ~SimpleHolder ()
 
template<class X , class disabler = typename std::enable_if < std::is_base_of<X, T>::value || std::is_same<T, X>::value >::type>
CUDA_HOS_DEV operator const X * () const
 
template<class X , class disabler = typename std::enable_if < std::is_base_of<X, T>::value || std::is_same<T, X>::value >::type>
CUDA_HOS_DEV operator X* ()
 
template<class stream , class str = std::basic_string<typename stream::char_type>>
void textual_output (stream &s, const str &separator=" ") const
 
template<class stream >
void textual_input (stream &s)
 
template<class stream >
void binary_output (stream &s) const
 
template<class stream >
void binary_input (stream &s)
 

Private Types

using indexer = unsigned int
 
using Manager = MemoryManagement< T, indexer >
 

Private Attributes

T * m_object
 

Friends

template<class a , class b , bool c>
class SimpleHolder
 

Detailed Description

template<class T, class Context>
class CaloRecGPU::Helpers::SimpleHolder< T, Context, true >

Definition at line 1072 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

Member Typedef Documentation

◆ indexer

template<class T , class Context >
using CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::indexer = unsigned int
private

◆ Manager

template<class T , class Context >
using CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::Manager = MemoryManagement<T, indexer>
private

Constructor & Destructor Documentation

◆ SimpleHolder() [1/8]

template<class T , class Context >
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder ( )
inline

Definition at line 1124 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1124  : m_object(nullptr)
1125  {
1126  }

◆ SimpleHolder() [2/8]

template<class T , class Context >
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder ( const bool  really_allocate)
inline

Definition at line 1128 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1129  {
1130  if (really_allocate)
1131  {
1132  m_object = Manager::template allocate<Context>(1);
1133  }
1134  else
1135  {
1136  m_object = nullptr;
1137  }
1138  }

◆ SimpleHolder() [3/8]

template<class T , class Context >
template<class X , class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder ( X *  other_p)
inlineexplicit
Warning
We assume the pointer is in a valid memory location!

Definition at line 1144 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1145  {
1146  m_object = Manager::template allocate<Context>(1);
1147  Manager::template copy<Context, Context>(m_object, other_p, 1);
1148  }

◆ SimpleHolder() [4/8]

template<class T , class Context >
template<class X , class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder ( const X &  other_v)
inline
Warning
We assume the object is in a valid memory location!

Definition at line 1154 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1154  : SimpleHolder(&other_v)
1155  {
1156 
1157 
1158  }

◆ SimpleHolder() [5/8]

template<class T , class Context >
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder ( const SimpleHolder< T, Context, true > &  other)
inline

Definition at line 1160 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1161  {
1162  if (other.valid())
1163  {
1164  m_object = Manager::template allocate<Context>(1);
1165  Manager::template copy<Context, Context>(m_object, other.m_object, other.valid());
1166  }
1167  else
1168  {
1169  m_object = nullptr;
1170  }
1171  }

◆ SimpleHolder() [6/8]

template<class T , class Context >
template<class X , class other_context , bool other_hold, class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder ( const SimpleHolder< X, other_context, other_hold > &  other)
inline

Definition at line 1175 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1176  {
1177  if (other.valid())
1178  {
1179  m_object = Manager::template allocate<Context>(1);
1180  Manager::template copy<Context, other_context>(m_object, other.m_object, other.valid());
1181  }
1182  else
1183  {
1184  m_object = nullptr;
1185  }
1186  }

◆ SimpleHolder() [7/8]

template<class T , class Context >
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder ( SimpleHolder< T, Context, true > &&  other)
inline

Definition at line 1188 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1189  {
1190  m_object = nullptr;
1191  Manager::template move<Context, Context>(m_object, other.m_object, other.valid());
1192  }

◆ SimpleHolder() [8/8]

template<class T , class Context >
template<class X , class other_context , class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder ( SimpleHolder< X, other_context, true > &&  other)
inline

Definition at line 1196 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1197  {
1198  m_object = nullptr;
1199  Manager::template move<Context, other_context>(m_object, other.m_object, other.valid());
1200  }

◆ ~SimpleHolder()

template<class T , class Context >
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::~SimpleHolder ( )
inline

Definition at line 1254 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1255  {
1256  Manager::template deallocate<Context>(m_object);
1257  }

Member Function Documentation

◆ allocate()

template<class T , class Context >
void CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::allocate ( )
inline

Definition at line 1116 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1117  {
1118  if (m_object == nullptr)
1119  {
1120  m_object = Manager::template allocate<Context>(1);
1121  }
1122  }

◆ binary_input()

template<class T , class Context >
template<class stream >
void CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::binary_input ( stream &  s)
inline

Definition at line 1342 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1343  {
1345  {
1346  allocate();
1347  s.read((char *) m_object, sizeof(T));
1348  }
1349  else
1350  {
1351  SimpleHolder<T, MemoryContext::CPU, true> other;
1352  other.binary_input(s);
1353  (*this) = other;
1354  }
1355  }

◆ binary_output()

template<class T , class Context >
template<class stream >
void CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::binary_output ( stream &  s) const
inline

Definition at line 1324 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1325  {
1326  if (m_object == nullptr)
1327  {
1328  return;
1329  }
1331  {
1332  s.write((char *) m_object, sizeof(T));
1333  }
1334  else
1335  {
1336  SimpleHolder<T, MemoryContext::CPU, true> other(*this);
1337  other.binary_output(s);
1338  }
1339  }

◆ clear()

template<class T , class Context >
void CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::clear ( )
inline

Definition at line 1111 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1112  {
1113  Manager::template deallocate<Context>(m_object);
1114  }

◆ operator const X *()

template<class T , class Context >
template<class X , class disabler = typename std::enable_if < std::is_base_of<X, T>::value || std::is_same<T, X>::value >::type>
CUDA_HOS_DEV CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator const X * ( ) const
inline

Definition at line 1260 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1261  {
1262  return m_object;
1263  }

◆ operator X*()

template<class T , class Context >
template<class X , class disabler = typename std::enable_if < std::is_base_of<X, T>::value || std::is_same<T, X>::value >::type>
CUDA_HOS_DEV CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator X* ( )
inline

Definition at line 1266 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1267  {
1268  return m_object;
1269  }

◆ operator*() [1/2]

template<class T , class Context >
CUDA_HOS_DEV T& CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator* ( )
inline

Definition at line 1091 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1092  {
1093  return *m_object;
1094  }

◆ operator*() [2/2]

template<class T , class Context >
CUDA_HOS_DEV const T& CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator* ( ) const
inline

Definition at line 1086 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1087  {
1088  return *m_object;
1089  }

◆ operator->() [1/2]

template<class T , class Context >
CUDA_HOS_DEV T* CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator-> ( )
inline

Definition at line 1101 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1102  {
1103  return m_object;
1104  }

◆ operator->() [2/2]

template<class T , class Context >
CUDA_HOS_DEV const T* CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator-> ( ) const
inline

Definition at line 1096 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1097  {
1098  return m_object;
1099  }

◆ operator=() [1/4]

template<class T , class Context >
SimpleHolder& CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator= ( const SimpleHolder< T, Context, true > &  other)
inline

Definition at line 1204 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1205  {
1206  if (!valid() && other.valid())
1207  {
1208  allocate();
1209  }
1210  if (&other != this)
1211  {
1212  Manager::template copy<Context, Context>(m_object, other.m_object, other.valid());
1213  }
1214  return (*this);
1215  }

◆ operator=() [2/4]

template<class T , class Context >
template<class X , class other_context , bool other_hold, class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
SimpleHolder& CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator= ( const SimpleHolder< X, other_context, other_hold > &  other)
inline

Definition at line 1221 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1222  {
1223  if (!valid() && other.valid())
1224  {
1225  allocate();
1226  }
1227  Manager::template copy<Context, other_context>(m_object, other.m_object, other.valid());
1228  return (*this);
1229  }

◆ operator=() [3/4]

template<class T , class Context >
SimpleHolder& CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator= ( SimpleHolder< T, Context, true > &&  other)
inline

Definition at line 1233 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1234  {
1235  if (&other != this)
1236  {
1237  clear();
1238  Manager::template move<Context, Context>(m_object, other.m_object, other.valid());
1239  }
1240  return (*this);
1241  }

◆ operator=() [4/4]

template<class T , class Context >
template<class X , class other_context , class disabler = typename std::enable_if < std::is_base_of<T, X>::value || std::is_same<T, X>::value >::type>
SimpleHolder& CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::operator= ( SimpleHolder< X, other_context, true > &&  other)
inline

Definition at line 1247 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1248  {
1249  clear();
1250  Manager::template move<Context, other_context>(m_object, other.m_object, other.valid());
1251  return (*this);
1252  }

◆ textual_input()

template<class T , class Context >
template<class stream >
void CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::textual_input ( stream &  s)
inline

Definition at line 1293 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1294  {
1296  {
1297  bool is_valid;
1298  s >> is_valid >> std::ws;
1299  if (s.fail())
1300  {
1301  //Throw errors, perhaps? Don't know if we can/should use exceptions...
1302  std::cerr << "FAILED READING " << this << "!" << std::endl;
1303  is_valid = false;
1304  }
1305  if (is_valid)
1306  {
1307  allocate();
1308  s >> (*m_object);
1309  }
1310  else
1311  {
1312  clear();
1313  }
1314  }
1315  else
1316  {
1317  SimpleHolder<T, MemoryContext::CPU, true> other;
1318  other.textual_input(s);
1319  (*this) = other;
1320  }
1321  }

◆ textual_output()

template<class T , class Context >
template<class stream , class str = std::basic_string<typename stream::char_type>>
void CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::textual_output ( stream &  s,
const str separator = " " 
) const
inline

Definition at line 1272 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1273  {
1275  {
1276  if (m_object == nullptr)
1277  {
1278  s << 0;
1279  }
1280  else
1281  {
1282  s << 1 << separator << (*m_object);
1283  }
1284  }
1285  else
1286  {
1287  SimpleHolder<T, MemoryContext::CPU, true> other(*this);
1288  other.textual_output(s, separator);
1289  }
1290  }

◆ valid()

template<class T , class Context >
CUDA_HOS_DEV bool CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::valid ( ) const
inline

Definition at line 1106 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

1107  {
1108  return m_object != nullptr;
1109  }

Friends And Related Function Documentation

◆ SimpleHolder

template<class T , class Context >
template<class a , class b , bool c>
friend class SimpleHolder
friend

Member Data Documentation

◆ m_object

template<class T , class Context >
T* CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::m_object
private

The documentation for this class was generated from the following file:
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::valid
CUDA_HOS_DEV bool valid() const
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:1106
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::clear
void clear()
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:1111
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::allocate
void allocate()
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:1116
taskman.template
dictionary template
Definition: taskman.py:317
athena.value
value
Definition: athena.py:122
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::SimpleHolder
friend class SimpleHolder
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:1082
CaloRecGPU::Helpers::SimpleHolder< T, Context, true >::m_object
T * m_object
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:1078
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16