fw4spl
|
Define Base class for FW4SPL buffers. More...
#include <BufferObject.hpp>
Classes | |
class | LockBase |
base class for BufferObject Lock More... | |
Public Types | |
typedef std::shared_ptr< void > | CounterType |
typedef std::weak_ptr< void > | WeakCounterType |
typedef size_t | SizeType |
Locks | |
Locks types | |
typedef LockBase< BufferObject > | Lock |
typedef LockBase< const BufferObject > | ConstLock |
Public Member Functions | |
virtual bool | isA (const std::string &type) const override |
std::string | className () const |
return the sub class classname : an alias of this->getClassname | |
virtual ::fwMemory::BufferManager::BufferType | getBuffer () const |
FWMEMORY_API | BufferObject () |
BufferObject constructor. More... | |
virtual FWMEMORY_API | ~BufferObject () |
BufferObject destructor. More... | |
virtual FWMEMORY_API void | allocate (SizeType size, const ::fwMemory::BufferAllocationPolicy::sptr &policy=::fwMemory::BufferMallocPolicy::New()) |
Buffer allocation. More... | |
virtual FWMEMORY_API void | reallocate (SizeType size) |
Buffer reallocation. More... | |
virtual FWMEMORY_API void | destroy () |
Buffer deallocation. More... | |
virtual FWMEMORY_API void | setBuffer (::fwMemory::BufferManager::BufferType buffer, SizeType size, const ::fwMemory::BufferAllocationPolicy::sptr &policy=::fwMemory::BufferMallocPolicy::New()) |
Buffer setter. More... | |
virtual FWMEMORY_API Lock | lock () |
Return a lock on the BufferObject. More... | |
virtual FWMEMORY_API ConstLock | lock () const |
Return a const lock on the BufferObject. More... | |
SizeType | getSize () const |
Returns the buffer's size. | |
bool | isEmpty () const |
Returns true if the buffer is empty. | |
long | lockCount () const |
Returns the number of locks on the BufferObject. | |
long | isLocked () const |
Returns true if the buffer has any lock. | |
const ::fwMemory::BufferManager::ConstBufferPtrType | getBufferPointer () const |
Returns pointer on BufferObject's buffer. | |
::fwCore::mt::ReadWriteMutex & | getMutex () |
FWMEMORY_API void | swap (const BufferObject::sptr &_source) |
Exchanges the content of the BufferObject with the content of _source. | |
FWMEMORY_API BufferManager::StreamInfo | getStreamInfo () const |
FWMEMORY_API void | setIStreamFactory (const std::shared_ptr< ::fwMemory::stream::in::IFactory > &factory, SizeType size, const ::boost::filesystem::path &sourceFile="",::fwMemory::FileFormatType format=::fwMemory::OTHER, const ::fwMemory::BufferAllocationPolicy::sptr &policy=::fwMemory::BufferMallocPolicy::New()) |
Set a stream factory for the buffer manager The factory will be used to load data on demand by the buffer manager. More... | |
Public Member Functions inherited from fwCore::BaseObject |
Static Public Member Functions | |
static bool | isTypeOf (const std::string &type) |
Static Public Member Functions inherited from fwCore::BaseObject | |
static bool | isTypeOf (const std::string &type) |
static const std::string & | leafClassname () |
return object's classname without its namespace, i.e. BaseObject | |
static const std::string & | classname () |
return object's classname without its namespace, i.e. BaseObject | |
Protected Attributes | |
::fwMemory::BufferManager::BufferType | m_buffer |
SizeType | m_size |
WeakCounterType | m_count |
mutable::fwCore::mt::Mutex | m_lockDumpMutex |
::fwCore::mt::ReadWriteMutex | m_mutex |
::fwMemory::BufferManager::sptr | m_bufferManager |
::fwMemory::BufferAllocationPolicy::sptr | m_allocPolicy |
Friends | |
template<class , class , class > | |
class | ::fwTools::ClassFactory |
class | ::fwTools::Factory |
Demangling methods | |
virtual const std::string & | getLeafClassname () const override |
return object's classname without its namespace, i.e. BaseObject | |
virtual const std::string & | getClassname () const override |
return full object's classname with its namespace, i.e. fwCore::BaseObject | |
static const std::string & | leafClassname () |
return object's classname without its namespace, i.e. BaseObject | |
static const std::string & | classname () |
return object's classname without its namespace, i.e. BaseObject | |
Define Base class for FW4SPL buffers.
Keep a pointer to a buffer and it's allocation policy (new malloc) without any cleverness about allocating/destroying the buffer. Users of this class needs to take care about allocation and destruction by themselves.
BufferObject class has a BufferManager and Locks mechanism, Allowing to trigger special treatments on various events on BufferObjects (allocation, reallocation, destruction, swapping, locking, unlocking) and allowing to give some guarantees.
Users of buffer have to keep a lock on a BufferObject when dealing with the buffers content. Keeping a lock on a BufferObject guarantees that the buffer will not be changed or modified by the BufferManager mechanism. A lock DO NOT GARANTEE that an other user of this buffer object are not changing/modifying the buffer.
Definition at line 51 of file BufferObject.hpp.
fwMemory::BufferObject::BufferObject | ( | ) |
BufferObject constructor.
Register the buffer to an existing buffer manager.
Definition at line 21 of file BufferObject.cpp.
|
virtual |
BufferObject destructor.
unregister the buffer from the buffer manager.
Definition at line 32 of file BufferObject.cpp.
|
virtual |
Buffer allocation.
Allocate a buffer using given policy. The allocation may have been hooked by the buffer manager.
size | number of bytes to allocate |
policy | Buffer allocation policy, default is Malloc policy |
Definition at line 41 of file BufferObject.cpp.
|
virtual |
Buffer deallocation.
Destroy the buffer using the associated policy. The destruction may have been hooked by the buffer manager.
Definition at line 58 of file BufferObject.cpp.
|
virtual |
Return a lock on the BufferObject.
Definition at line 77 of file BufferObject.cpp.
|
virtual |
Return a const lock on the BufferObject.
Definition at line 84 of file BufferObject.cpp.
|
virtual |
Buffer reallocation.
Reallocate the buffer using the associated policy. A policy may not handle reallocation. The reallocation may have been hooked by the buffer manager.
size | New buffer size |
Definition at line 50 of file BufferObject.cpp.
|
virtual |
Buffer setter.
Set the buffer from an existing one.
buffer | External Buffer |
size | Buffer's size |
policy | External buffer allocation policy, default is Malloc policy |
Definition at line 67 of file BufferObject.cpp.
void fwMemory::BufferObject::setIStreamFactory | ( | const std::shared_ptr< ::fwMemory::stream::in::IFactory > & | factory, |
SizeType | size, | ||
const ::boost::filesystem::path & | sourceFile = "" , |
||
::fwMemory::FileFormatType | format = ::fwMemory::OTHER , |
||
const ::fwMemory::BufferAllocationPolicy::sptr & | policy = ::fwMemory::BufferMallocPolicy::New() |
||
) |
Set a stream factory for the buffer manager The factory will be used to load data on demand by the buffer manager.
factory | fwMemory::stream::in::IFactory stream factory |
size | size of data provided by the stream |
sourceFile | Filesystem path of the source file, if applicable |
format | file format (RAW,RAWZ,OTHER), if sourceFile is provided |
policy | Buffer allocation policy |
Definition at line 109 of file BufferObject.cpp.