soma-io
5.1.2
|
Allocation context. More...
#include <soma-io/allocator/allocator.h>
Public Types | |
typedef AllocatorStrategy::DataAccess | DataAccess |
typedef AllocatorStrategy::MappingMode | MappingMode |
Public Member Functions | |
AllocatorContext (DataAccess mode=AllocatorStrategy::InternalModif, carto::rc_ptr< DataSource > datasource=DataSource::none(), bool isDiskformatOK=false, float usefactor=1) | |
Constructor from a DataSource. More... | |
AllocatorContext (DataAccess mode, carto::rc_ptr< DataSourceInfo > datasourceinfo, float usefactor=1) | |
Constructor from a DataSourceInfo. More... | |
AllocatorContext (DataAccess mode, const std::string &filename, offset_t offset=0, bool isDiskformatOK=false, float usefactor=1) | |
Constructor from a filename. More... | |
AllocatorContext (DataAccess mode, float usefactor) | |
Constructor without pre-existing DataSource. More... | |
AllocatorContext (const LowLevelAllocator *alloc) | |
Constructor from a LLA. More... | |
AllocatorContext (const AllocatorContext &) | |
Constructor by copy. More... | |
~AllocatorContext () | |
AllocatorContext & | operator= (const AllocatorContext &) |
template<typename T > | |
T * | allocate (T *&ptr, size_t n) const |
return value is the same as modifiable input param ptr More... | |
template<typename T > | |
void | deallocate (T *ptr, size_t n) const |
bool | canDuplicate () const |
MappingMode | allocatorType () const |
DataAccess | accessMode () const |
void | setAccessMode (DataAccess mode) |
void | setDataSource (carto::rc_ptr< DataSource > datasource) |
AllocatorContext becomes owner of datasource . More... | |
const carto::rc_ptr< DataSource > | dataSource () const |
carto::rc_ptr< DataSource > | dataSource () |
void | setDataSourceInfo (carto::rc_ptr< DataSourceInfo > dsi) |
AllocatorContext becomes owner od datasourceinfo . More... | |
const carto::rc_ptr< DataSourceInfo > | dataSourceInfo () const |
carto::rc_ptr< DataSourceInfo > | dataSourceInfo () |
bool | isAllocated () const |
float | useFactor () const |
void | setUseFactor (float x) |
bool | allowsMemoryMapping () const |
void | setAllowsMemoryMapping (bool x) |
Static Public Member Functions | |
static const AllocatorContext & | fast () |
Allocation context.
The allocators system is globally described on a separate Allocators system page.
More specifically, AllocatorContext is the entry point to this
allocation system: only this class has generally to be used by programmers. It handles a switch to the appropriate low-level allocator (LowLevelAllocator) according to the amount of memory available, the size of the data block to be allocated, and to what is intended to be done with it.
The switch mechanism is itself in large part deported to another class: AllocatorStrategy which also provides some constant enums used by AllocatorContext. This is perhaps a bad idea and both classes might be merged in the future.
In order to accelerate allocation, or to be sure that allocation is done in the intended mode (which may be important in some cases), this switching mechanism can be bypassed by directly providing a LowLevelAllocator. Such low-level allocators are singletons and should never be created by hand: use their singleton() static methods.
Definition at line 260 of file allocator.h.
Definition at line 263 of file allocator.h.
Definition at line 264 of file allocator.h.
soma::AllocatorContext::AllocatorContext | ( | DataAccess | mode = AllocatorStrategy::InternalModif , |
carto::rc_ptr< DataSource > | datasource = DataSource::none() , |
||
bool | isDiskformatOK = false , |
||
float | usefactor = 1 |
||
) |
Constructor from a DataSource.
soma::AllocatorContext::AllocatorContext | ( | DataAccess | mode, |
carto::rc_ptr< DataSourceInfo > | datasourceinfo, | ||
float | usefactor = 1 |
||
) |
Constructor from a DataSourceInfo.
soma::AllocatorContext::AllocatorContext | ( | DataAccess | mode, |
const std::string & | filename, | ||
offset_t | offset = 0 , |
||
bool | isDiskformatOK = false , |
||
float | usefactor = 1 |
||
) |
Constructor from a filename.
soma::AllocatorContext::AllocatorContext | ( | DataAccess | mode, |
float | usefactor | ||
) |
Constructor without pre-existing DataSource.
soma::AllocatorContext::AllocatorContext | ( | const LowLevelAllocator * | alloc | ) |
Constructor from a LLA.
soma::AllocatorContext::AllocatorContext | ( | const AllocatorContext & | ) |
Constructor by copy.
soma::AllocatorContext::~AllocatorContext | ( | ) |
|
inline |
Definition at line 296 of file allocator.h.
Referenced by soma::FormatReader< T >::setupAndRead().
|
inline |
return value is the same as modifiable input param ptr
Definition at line 333 of file allocator.h.
References soma::LowLevelAllocator::allocate(), soma::AllocatorStrategy::lowLevelAllocator(), soma::AllocatorStrategy::mappingMode(), and soma::MemoryAllocator::singleton().
Referenced by soma::AllocatedVector< T >::allocate().
MappingMode soma::AllocatorContext::allocatorType | ( | ) | const |
Referenced by soma::AllocatedVector< T >::AllocatedVector().
|
inline |
Definition at line 383 of file allocator.h.
bool soma::AllocatorContext::canDuplicate | ( | ) | const |
|
inline |
Definition at line 302 of file allocator.h.
|
inline |
Definition at line 301 of file allocator.h.
|
inline |
Definition at line 306 of file allocator.h.
|
inline |
Definition at line 305 of file allocator.h.
|
inline |
Definition at line 363 of file allocator.h.
References soma::LowLevelAllocator::deallocate(), and soma::MemoryAllocator::singleton().
|
static |
|
inline |
Definition at line 308 of file allocator.h.
Referenced by soma::AllocatedVector< T >::AllocatedVector(), and soma::AllocatedVector< T >::copy().
AllocatorContext& soma::AllocatorContext::operator= | ( | const AllocatorContext & | ) |
void soma::AllocatorContext::setAccessMode | ( | DataAccess | mode | ) |
|
inline |
Definition at line 389 of file allocator.h.
void soma::AllocatorContext::setDataSource | ( | carto::rc_ptr< DataSource > | datasource | ) |
AllocatorContext becomes owner of datasource
.
void soma::AllocatorContext::setDataSourceInfo | ( | carto::rc_ptr< DataSourceInfo > | dsi | ) |
AllocatorContext becomes owner od datasourceinfo
.
void soma::AllocatorContext::setUseFactor | ( | float | x | ) |
float soma::AllocatorContext::useFactor | ( | ) | const |
Referenced by soma::FormatReader< T >::setupAndRead().