MDSTk Libraries
1.1.0
Medical Data Segmentation Toolkit
|
Simple memory channel that keeps all data in a memory buffer. More...
#include <mdsMemoryChannel.h>
Public Types | |
enum | { CLASS_OBJECT } |
Templates that require members of the CObject class can use this enum to check the existence. More... | |
enum | { HEAP_OBJECT = 0x70616568 } |
Signature used to recognize objects on the heap. More... | |
typedef mds::base::CLibraryLockableObject < CChannel >::CLock | tLock |
Lock that have to be used to provide mutual access to write(), read() and etc. | |
Public Member Functions | |
bool | checkMedium (int Medium) const |
Checks if channel medium is equal to a given value. | |
bool | checkType (int Type) const |
Checks if channel type corresponds to a given value. | |
CMemoryChannel (const EChannelType type, const int length, char *data=NULL) | |
Constructor. | |
virtual bool | connect (unsigned timeout=CH_CONNECTION_TIMEOUT) |
Connects to the opposite channel side. | |
virtual void | disconnect () |
Disconnects from the opossite channel side. | |
virtual bool | flush () |
In case of the output channel, the function writes all remaining data (partially filled or empty block) to the channel. | |
char * | getDataPtr () |
Returns pointer to the memory. | |
int | getLength () |
Returns length of memory buffer. | |
int | getMedium () const |
Returns the channel medium. | |
int | getNumOfReadBytes () |
Returns number of bytes currently read from memory buffer. | |
int | getNumOfWrittenBytes () |
Returns number of bytes currently written to memory buffer. | |
int | getReferencesCount () const |
Returns the number of references. | |
int | getType () const |
Method returns the channel type. | |
virtual bool | isConnected () |
Method for testing channel errors such as: | |
bool | isOnHeap () const |
Returns true if the object is allocated on the heap. | |
virtual bool | listen (unsigned uTimeout=CH_CONNECTION_TIMEOUT) |
Listens for and accepts an incoming connection. | |
void | lock () |
Locks the object. | |
MDS_SHAREDPTR (CMemoryChannel) | |
Smart pointer type. | |
MDS_SHAREDPTR (CChannel) | |
Smart pointer type. | |
virtual int | read (char *data, int length) |
Reads data from the input channel. | |
void | setDataPtr (const int length, char *data=NULL) |
Sets target data of memory channel and resets read and write index. | |
virtual bool | skip (int length) |
Skips a given number of bytes. | |
void | unlock () |
Locks the object. | |
virtual bool | wait (unsigned timeout=CH_WAIT_TIMEOUT) |
Waits for data. | |
virtual bool | write (const char *data, int length) |
Writes compressed data to the output channel. | |
virtual | ~CMemoryChannel () |
Virtual destructor. | |
Static Public Member Functions | |
static CChannel * | create (EChannelType eType, const std::string &sDesc) |
Creation of a channel which is described by a textual string. | |
static void * | operator new (std::size_t Size) |
Allocates a new object on the heap. | |
static void | separate (const std::string &sDescs, std::vector< std::string > &Descs) |
Parses a given string and separates descriptions of several channels. | |
Protected Member Functions | |
void | addReference () const |
Increase the reference counter. | |
bool | delReference () const |
Decrease the reference counter. | |
Protected Attributes | |
bool | m_bBufferOwner |
Memory buffer owner flag. | |
int | m_iHeapObject |
Flag initialized if the object is on the heap. | |
int | m_iLength |
Length of memory buffer. | |
int | m_iNumOfReadBytes |
Index of reading from buffer. | |
int | m_iNumOfWrittenBytes |
Index of write to buffer. | |
int | m_iReferences |
The number of references to the object. | |
int | m_Medium |
Channel medium. | |
char * | m_pcData |
Pointer to memory buffer. | |
int | m_Type |
Channel type. |
Simple memory channel that keeps all data in a memory buffer.
typedef mds::base::CLibraryLockableObject<CChannel>::CLock mds::mod::CChannel::tLock [inherited] |
anonymous enum [inherited] |
Templates that require members of the CObject class can use this enum to check the existence.
mds::mod::CMemoryChannel::CMemoryChannel | ( | const EChannelType | type, |
const int | length, | ||
char * | data = NULL |
||
) |
Constructor.
data
of size size
.data
is NULL
allocates memory internally and manages it itself.mds::mod::CMemoryChannel::~CMemoryChannel | ( | ) | [virtual] |
Virtual destructor.
void mds::base::CObject::addReference | ( | ) | const [protected, inherited] |
Increase the reference counter.
bool mds::mod::CChannel::checkMedium | ( | int | Medium | ) | const [inherited] |
Checks if channel medium is equal to a given value.
bool mds::mod::CChannel::checkType | ( | int | Type | ) | const [inherited] |
Checks if channel type corresponds to a given value.
bool mds::mod::CMemoryChannel::connect | ( | unsigned | timeout = CH_CONNECTION_TIMEOUT | ) | [virtual] |
Connects to the opposite channel side.
Implements mds::mod::CChannel.
CChannel * mds::mod::CChannel::create | ( | EChannelType | eType, |
const std::string & | sDesc | ||
) | [static, inherited] |
Creation of a channel which is described by a textual string.
bool mds::base::CObject::delReference | ( | ) | const [protected, inherited] |
Decrease the reference counter.
void mds::mod::CMemoryChannel::disconnect | ( | ) | [virtual] |
Disconnects from the opossite channel side.
Implements mds::mod::CChannel.
bool mds::mod::CMemoryChannel::flush | ( | ) | [virtual] |
In case of the output channel, the function writes all remaining data (partially filled or empty block) to the channel.
Otherwise, it skips the remaining data in the channel until en empty data block or partially filled block is found.
Implements mds::mod::CChannel.
char * mds::mod::CMemoryChannel::getDataPtr | ( | ) |
Returns pointer to the memory.
Returns length of memory buffer.
int mds::mod::CChannel::getMedium | ( | ) | const [inherited] |
Returns the channel medium.
Returns number of bytes currently read from memory buffer.
Returns number of bytes currently written to memory buffer.
int mds::base::CObject::getReferencesCount | ( | ) | const [inherited] |
Returns the number of references.
int mds::mod::CChannel::getType | ( | ) | const [inherited] |
Method returns the channel type.
bool mds::mod::CMemoryChannel::isConnected | ( | ) | [virtual] |
Method for testing channel errors such as:
Implements mds::mod::CChannel.
bool mds::base::CObject::isOnHeap | ( | ) | const [inherited] |
Returns true if the object is allocated on the heap.
bool mds::mod::CMemoryChannel::listen | ( | unsigned | uTimeout = CH_CONNECTION_TIMEOUT | ) | [virtual] |
Listens for and accepts an incoming connection.
Implements mds::mod::CChannel.
void mds::base::CLockableObject< CChannel >::lock | ( | ) | [inherited] |
Locks the object.
Smart pointer type.
mds::mod::CChannel::MDS_SHAREDPTR | ( | CChannel | ) | [inherited] |
Smart pointer type.
static void* mds::base::CObject::operator new | ( | std::size_t | Size | ) | [static, inherited] |
Allocates a new object on the heap.
int mds::mod::CMemoryChannel::read | ( | char * | data, |
int | length | ||
) | [virtual] |
Reads data from the input channel.
Implements mds::mod::CChannel.
void mds::mod::CChannel::separate | ( | const std::string & | sDescs, |
std::vector< std::string > & | Descs | ||
) | [static, inherited] |
Parses a given string and separates descriptions of several channels.
void mds::mod::CMemoryChannel::setDataPtr | ( | const int | length, |
char * | data = NULL |
||
) |
Sets target data of memory channel and resets read and write index.
bool mds::mod::CMemoryChannel::skip | ( | int | length | ) | [virtual] |
Skips a given number of bytes.
Reimplemented from mds::mod::CChannel.
void mds::base::CLockableObject< CChannel >::unlock | ( | ) | [inherited] |
Locks the object.
bool mds::mod::CMemoryChannel::wait | ( | unsigned | timeout = CH_WAIT_TIMEOUT | ) | [virtual] |
Waits for data.
Implements mds::mod::CChannel.
bool mds::mod::CMemoryChannel::write | ( | const char * | data, |
int | length | ||
) | [virtual] |
Writes compressed data to the output channel.
Implements mds::mod::CChannel.
bool mds::mod::CMemoryChannel::m_bBufferOwner [protected] |
Memory buffer owner flag.
int mds::base::CObject::m_iHeapObject [mutable, protected, inherited] |
Flag initialized if the object is on the heap.
int mds::mod::CMemoryChannel::m_iLength [protected] |
Length of memory buffer.
int mds::mod::CMemoryChannel::m_iNumOfReadBytes [protected] |
Index of reading from buffer.
int mds::mod::CMemoryChannel::m_iNumOfWrittenBytes [protected] |
Index of write to buffer.
int mds::base::CObject::m_iReferences [mutable, protected, inherited] |
The number of references to the object.
int mds::mod::CChannel::m_Medium [protected, inherited] |
Channel medium.
char* mds::mod::CMemoryChannel::m_pcData [protected] |
Pointer to memory buffer.
int mds::mod::CChannel::m_Type [protected, inherited] |
Channel type.