UCommon
ucommon::mapped_array< T > Class Template Reference

Template class to map typed vector into shared memory. More...

#include <mapped.h>

Inheritance diagram for ucommon::mapped_array< T >:
Collaboration diagram for ucommon::mapped_array< T >:

Public Member Functions

void * addLock (void)
 Add mapped space while holding lock for one object.
 
void initialize (void)
 Initialize typed data in mapped array.
 
 mapped_array (const char *name, unsigned number)
 Construct mapped vector array of typed objects.
 
unsigned max (void) const
 Get member size of typed objects that can be held in mapped vector.
 
T * operator() (unsigned member)
 Get typed pointer to member object of vector in mapped segment.
 
T * operator() (void)
 Allocate mapped space for one object.
 
T & operator[] (unsigned member)
 Reference typed object of vector in mapped segment.
 
- Public Member Functions inherited from ucommon::MappedMemory
caddr_t addr (void)
 Get starting address of mapped segment.
 
bool copy (size_t offset, void *buffer, size_t size) const
 Copy memory from specific offset within the mapped memory segment.
 
size_t len (void) const
 Get size of mapped segment.
 
 MappedMemory (const char *name)
 Provide read-only mapped access to an existing named shared memory segment.
 
 MappedMemory (const char *name, size_t size)
 Construct a read/write access mapped shared segment of memory of a known size.
 
void * offset (size_t offset) const
 Get memory from a specific offset within the mapped memory segment.
 
 operator bool () const
 Test if map active.
 
bool operator! () const
 Test if map is inactive.
 
void release (void)
 Unmap memory segment.
 
void * sbrk (size_t size)
 Extend size of managed heap on shared memory segment.
 
virtual ~MappedMemory ()
 Unmap memory segment.
 

Protected Member Functions

void create (const char *fn, unsigned members)
 
- Protected Member Functions inherited from ucommon::MappedMemory
void create (const char *name, size_t size=(size_t) 0)
 Supporting function to construct a new or access an existing shared memory segment.
 

Additional Inherited Members

- Static Public Member Functions inherited from ucommon::MappedMemory
static void disable (void)
 An API that allows "disabling" of publishing shared memory maps.
 
static void remove (const char *name)
 Destroy a previously existing memory segment under the specified name.
 
- Protected Attributes inherited from ucommon::MappedMemory
bool erase
 
char idname [65]
 
size_t size
 
size_t used
 

Detailed Description

template<class T>
class ucommon::mapped_array< T >

Template class to map typed vector into shared memory.

This is used to construct a typed read/write vector of objects that are held in a named shared memory segment.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 271 of file mapped.h.

Constructor & Destructor Documentation

◆ mapped_array() [1/2]

template<class T >
ucommon::mapped_array< T >::mapped_array ( )
inlineprotected

Definition at line 277 of file mapped.h.

◆ mapped_array() [2/2]

template<class T >
ucommon::mapped_array< T >::mapped_array ( const char * name,
unsigned number )
inline

Construct mapped vector array of typed objects.

This is constructed for read/write access. mapped_view is used in all cases for read-only access to mapped data. Member objects are linearly allocated from the shared memory segment, or may simply be directly accessed by offset.

Parameters
nameof mapped segment to construct.
numberof objects in the mapped vector.

Definition at line 291 of file mapped.h.

Member Function Documentation

◆ addLock()

template<class T >
void * ucommon::mapped_array< T >::addLock ( void )
inline

Add mapped space while holding lock for one object.

Returns
address of object.

Definition at line 305 of file mapped.h.

Here is the call graph for this function:

◆ create()

template<class T >
void ucommon::mapped_array< T >::create ( const char * fn,
unsigned members )
inlineprotected

Definition at line 279 of file mapped.h.

◆ initialize()

template<class T >
void ucommon::mapped_array< T >::initialize ( void )
inline

Initialize typed data in mapped array.

Assumes default constructor for type.

Definition at line 298 of file mapped.h.

Here is the call graph for this function:

◆ max()

template<class T >
unsigned ucommon::mapped_array< T >::max ( void ) const
inline

Get member size of typed objects that can be held in mapped vector.

Returns
members mapped in segment.

Definition at line 335 of file mapped.h.

◆ operator()() [1/2]

template<class T >
T * ucommon::mapped_array< T >::operator() ( unsigned member)
inline

Get typed pointer to member object of vector in mapped segment.

Parameters
memberto access.
Returns
typed pointer or NULL if past end of array.

Definition at line 313 of file mapped.h.

Here is the call graph for this function:

◆ operator()() [2/2]

template<class T >
T * ucommon::mapped_array< T >::operator() ( void )
inline

Allocate mapped space for one object.

Returns
address of object.

Definition at line 320 of file mapped.h.

Here is the call graph for this function:

◆ operator[]()

template<class T >
T & ucommon::mapped_array< T >::operator[] ( unsigned member)
inline

Reference typed object of vector in mapped segment.

Parameters
memberto access.
Returns
typed reference.

Definition at line 328 of file mapped.h.

Here is the call graph for this function:

The documentation for this class was generated from the following file: