#include <sharelib.h>
Collaboration diagram for Share::ShareManager:
Public Types | |
typedef Relocator::relative_pointer | relative_pointer |
Relative pointer type. | |
typedef Relocator::relative_const_pointer | relative_const_pointer |
Relative const pointer type. | |
Public Member Functions | |
void | createSegment (const char *name, size_t size) throw (ShareException) |
Create and attach segment | |
void | attachSegment (const char *name) throw (ShareException) |
Attach an already existing shared segment. | |
void | detachSegment () throw () |
Detach from shared segment. | |
void | unlinkSegment () throw () |
Mark shared segment to be destroyed. | |
const char * | name () |
Name of attached shared segment. | |
relative_pointer | absToRel (void *abs) |
relative_const_pointer | absToRel (const void *abs) |
template<class T> | |
relative_pointer | absToRel (T *abs) |
void * | relToAbs (relative_pointer rel) |
void * | alloc (size_t size) throw (ShareException) |
void * | alloc (size_t size, size_t count) throw (ShareException) |
void | free (void *addr) throw () |
void | free (void *addr, size_t) throw () |
size_t | available () |
Static Public Member Functions | |
static ShareManager * | instance () |
static void | destroySelf () |
Protected Member Functions | |
void | initDebugMode (SharedSegment *segment) |
Initialize ShareManager for debuging. | |
void | destroySegment () |
Destroy current shared segment immediately. | |
Friends | |
class | SharedSegmentWrapper |
Bridge from sharectl to sharelib. |
High-level interface to shared segment manipulation. Design pattern signleton
Definition at line 184 of file sharelib.h.
static ShareManager* Share::ShareManager::instance | ( | ) | [static] |
Method to access to singleton object.
Referenced by Share::SharedObject::alloc(), Share::Allocator< T >::allocate(), Share::Allocator< T >::deallocate(), Share::SharedObject::free(), Share::Allocator< T >::max_size(), Share::RelocPtr< T >::operator->(), and Share::RelocPtr< T >::operator=().
Here is the caller graph for this function:
static void Share::ShareManager::destroySelf | ( | ) | [static] |
Destroy singleton object. This method should be called automatically on application exit using std::atexit() function.
void Share::ShareManager::createSegment | ( | const char * | name, | |
size_t | size | |||
) | throw (ShareException) |
Create and attach segment
Create and attach new segment.
name | Name of new segment. Method throws ShareException if name is already used. | |
size | How much memory will be allocated for data. Note that real size can be larger. |
ShareException | Generic exception thrown if creation process fails. |
void Share::ShareManager::attachSegment | ( | const char * | name | ) | throw (ShareException) |
Attach an already existing shared segment.
Method throws ShareException if segment does not exist.
name | Name of shared segment to attach to. |
ShareException | Generic exception thrown if attaching fails. |
void Share::ShareManager::detachSegment | ( | ) | throw () |
Detach from shared segment.
All relative and absolute pointers to segment will be invalid after detach.
void Share::ShareManager::unlinkSegment | ( | ) | throw () |
Mark shared segment to be destroyed.
Segment will be realy destroyed after references count fades to zero. This means that calling prcess has to detach shared segment after this call to destroy it.
const char* Share::ShareManager::name | ( | ) |
Name of attached shared segment.
relative_pointer Share::ShareManager::absToRel | ( | void * | abs | ) | [inline] |
Convert absolute address to relative.
abs | Absolute address to convert. |
Definition at line 245 of file sharelib.h.
References Share::Relocator::absToRel().
Referenced by absToRel().
relative_const_pointer Share::ShareManager::absToRel | ( | const void * | abs | ) | [inline] |
Convert absolute address to relative.
abs | Absolute address to convert. |
Definition at line 252 of file sharelib.h.
References Share::Relocator::absToRel().
relative_pointer Share::ShareManager::absToRel | ( | T * | abs | ) | [inline] |
Convert absolute address to relative.
abs | Absolute address to convert. |
Definition at line 259 of file sharelib.h.
References absToRel().
void* Share::ShareManager::relToAbs | ( | relative_pointer | rel | ) | [inline] |
Convert relative address to absolute.
rel | Relative address to convert. |
Definition at line 269 of file sharelib.h.
References Share::Relocator::relToAbs().
void* Share::ShareManager::alloc | ( | size_t | size | ) | throw (ShareException) |
Allocate piece of memory from shared segment or local heap.
size | Requested size to allocate. |
ShareException | Library-specific exception derived from std::bad_alloc |
Referenced by alloc().
void* Share::ShareManager::alloc | ( | size_t | size, | |
size_t | count | |||
) | throw (ShareException) [inline] |
Allocate piece of memory from shared segment or local heap.
size | Requested size to allocate. |
ShareException | Library-specific exception derived from std::bad_alloc |
count | Objects count to allocate. |
Definition at line 286 of file sharelib.h.
References alloc().
void Share::ShareManager::free | ( | void * | addr | ) | throw () |
void Share::ShareManager::free | ( | void * | addr, | |
size_t | ||||
) | throw () [inline] |
Free memory allocated by method alloc().
addr | Address returned by alloc(). If this is different addres, all attached application will crash terribly. |
Definition at line 301 of file sharelib.h.
References free().
size_t Share::ShareManager::available | ( | ) |
friend class SharedSegmentWrapper [friend] |