Share::ShareManager Class Reference
[Core library classes]

Gateway to shared segment More...

#include <sharelib.h>

Collaboration diagram for Share::ShareManager:

Collaboration graph
[legend]
List of all members.

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 ShareManagerinstance ()
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.

Detailed Description

Gateway to shared segment

High-level interface to shared segment manipulation. Design pattern signleton

Definition at line 184 of file sharelib.h.


Member Typedef Documentation

typedef Relocator::relative_pointer Share::ShareManager::relative_pointer

Relative pointer type.

Definition at line 186 of file sharelib.h.

typedef Relocator::relative_const_pointer Share::ShareManager::relative_const_pointer

Relative const pointer type.

Definition at line 187 of file sharelib.h.


Member Function Documentation

static ShareManager* Share::ShareManager::instance (  )  [static]

Method to access to singleton object.

Returns:
Return pointer 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.

Parameters:
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.
Exceptions:
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.

Parameters:
name Name of shared segment to attach to.
Exceptions:
ShareException Generic exception thrown if attaching fails.
Note:
Do not call this method after createSegment method call.

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.

Attention:
On Win32 platform is segment destoroyed automatically by OS, when there are no more references to segment.

const char* Share::ShareManager::name (  ) 

Name of attached shared segment.

Returns:
Return name of shared segment.

relative_pointer Share::ShareManager::absToRel ( void *  abs  )  [inline]

Convert absolute address to relative.

Parameters:
abs Absolute address to convert.
Returns:
Return relative address.

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.

Parameters:
abs Absolute address to convert.
Returns:
Return relative address.

Definition at line 252 of file sharelib.h.

References Share::Relocator::absToRel().

template<class T>
relative_pointer Share::ShareManager::absToRel ( T *  abs  )  [inline]

Convert absolute address to relative.

Parameters:
abs Absolute address to convert.
Returns:
Return relative address.

Definition at line 259 of file sharelib.h.

References absToRel().

void* Share::ShareManager::relToAbs ( relative_pointer  rel  )  [inline]

Convert relative address to absolute.

Parameters:
rel Relative address to convert.
Returns:
Return absolute address.

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.

Parameters:
size Requested size to allocate.
Returns:
Return local pointer to allocated memory.
Exceptions:
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.

Parameters:
size Requested size to allocate.
Returns:
Return local pointer to allocated memory.
Exceptions:
ShareException Library-specific exception derived from std::bad_alloc
Parameters:
count Objects count to allocate.
Note:
Used for STL allocator.

Definition at line 286 of file sharelib.h.

References alloc().

void Share::ShareManager::free ( void *  addr  )  throw ()

Free memory allocated by method alloc().

Parameters:
addr Address returned by alloc(). If this is different addres, all attached application will crash terribly.

Referenced by free().

void Share::ShareManager::free ( void *  addr,
size_t   
) throw () [inline]

Free memory allocated by method alloc().

Parameters:
addr Address returned by alloc(). If this is different addres, all attached application will crash terribly.
Note:
Used for STL allocator.

Definition at line 301 of file sharelib.h.

References free().

size_t Share::ShareManager::available (  ) 

Returns:
Return size of avalilable memory in shared segment


Friends And Related Function Documentation

friend class SharedSegmentWrapper [friend]

Bridge from sharectl to sharelib.

Definition at line 327 of file sharelib.h.


The documentation for this class was generated from the following file:
Generated on Sun Aug 26 17:43:03 2007 for ShareLibrary by  doxygen 1.5.2