Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Static Public Member Functions | Static Private Member Functions | List of all members
Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type > Class Template Reference

#include <ArrayPolicies.hpp>

Static Public Member Functions

static void Initialize (ObjectType *data, unsigned int itemsToCreate)
 Initalize each element in the array with ObjectType's default constructor.
static void Initialize (ObjectType *data, unsigned int itemsToCreate, const ObjectType &initValue)
 Initalize each element in the array with ObjectType's copy constructor.
static void Initialize (ObjectType *data, unsigned int itemsToCreate, const ObjectType *initValue)

Static Private Member Functions

template<typename CreateType >
static void DoInitialization (ObjectType *data, unsigned int itemsToCreate, const CreateType &f)
static void DefaultConstructionWithPlacementNew (ObjectType *element)
static void CopyConstructionWithPlacementNew (ObjectType *element, const ObjectType &initValue)
static void CopyConstructionFromArray (ObjectType *element, const ObjectType *&rhs)

Detailed Description

template<typename ObjectType>
class Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type >

Definition at line 84 of file ArrayPolicies.hpp.

Member Function Documentation

template<typename ObjectType >
static void Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type >::CopyConstructionFromArray ( ObjectType *  element,
const ObjectType *&  rhs 
)
inlinestaticprivate

Definition at line 148 of file ArrayPolicies.hpp.

{
new (element) ObjectType(*rhs);
rhs += 1;
}
template<typename ObjectType >
static void Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type >::CopyConstructionWithPlacementNew ( ObjectType *  element,
const ObjectType &  initValue 
)
inlinestaticprivate

Definition at line 143 of file ArrayPolicies.hpp.

{
new (element) ObjectType(initValue);
}
template<typename ObjectType >
static void Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type >::DefaultConstructionWithPlacementNew ( ObjectType *  element)
inlinestaticprivate

Definition at line 138 of file ArrayPolicies.hpp.

{
new (element) ObjectType;
}
template<typename ObjectType >
template<typename CreateType >
static void Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type >::DoInitialization ( ObjectType *  data,
unsigned int  itemsToCreate,
const CreateType &  f 
)
inlinestaticprivate

Definition at line 115 of file ArrayPolicies.hpp.

{
unsigned int nextObjectToCreate = 0;
try
{
for(unsigned int i = 0; i < itemsToCreate; ++i)
{
ObjectType* memLocation = &data[i];
f(memLocation);
++nextObjectToCreate;
}
}
catch(...)
{
for(unsigned int i = 0; i < nextObjectToCreate; ++i)
{
ObjectType* memLocation = &data[nextObjectToCreate - i - 1];
memLocation->~ObjectType();
}
throw;
}
}
template<typename ObjectType >
static void Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type >::Initialize ( ObjectType *  data,
unsigned int  itemsToCreate 
)
inlinestatic

Initalize each element in the array with ObjectType's default constructor.

Parameters
dataThe array of values to populate.
itemsToCreateThe size of data.

Definition at line 91 of file ArrayPolicies.hpp.

{
DoInitialization(data, itemsToCreate,
boost::bind(&ArrayInitializationPolicy<ObjectType>::DefaultConstructionWithPlacementNew, _1));
}
template<typename ObjectType >
static void Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type >::Initialize ( ObjectType *  data,
unsigned int  itemsToCreate,
const ObjectType &  initValue 
)
inlinestatic

Initalize each element in the array with ObjectType's copy constructor.

Parameters
dataThe array of values to populate.
itemsToCreateThe size of data.
initValueThe inital value each element in data will have.

Definition at line 101 of file ArrayPolicies.hpp.

{
DoInitialization(data, itemsToCreate,
boost::bind(&ArrayInitializationPolicy<ObjectType>::CopyConstructionWithPlacementNew, _1, boost::ref(initValue)));
}
template<typename ObjectType >
static void Nektar::ArrayInitializationPolicy< ObjectType, typename boost::disable_if< boost::is_fundamental< ObjectType > >::type >::Initialize ( ObjectType *  data,
unsigned int  itemsToCreate,
const ObjectType *  initValue 
)
inlinestatic

Definition at line 107 of file ArrayPolicies.hpp.

{
DoInitialization(data, itemsToCreate,
boost::bind(&ArrayInitializationPolicy<ObjectType>::CopyConstructionFromArray, _1, boost::ref(initValue)));
}