Fawkes API  Fawkes Development Version
fawkes::SharedMemoryHeader Class Referenceabstract

Interface for shared memory header. More...

#include <>>

Inheritance diagram for fawkes::SharedMemoryHeader:

Public Member Functions

virtual ~SharedMemoryHeader ()
 Virtual destructor. More...
 
virtual bool matches (void *memptr)=0
 Method to check if the given memptr matches this header. More...
 
virtual size_t size ()=0
 Size of the header. More...
 
virtual void initialize (void *memptr)=0
 Initialize the header. More...
 
virtual void set (void *memptr)=0
 Set information from memptr. More...
 
virtual void reset ()=0
 Reset information previously set with set(). More...
 
virtual size_t data_size ()=0
 Return the size of the data. More...
 
virtual SharedMemoryHeaderclone () const =0
 Clone this shared memory header. More...
 
virtual bool operator== (const SharedMemoryHeader &s) const =0
 Check for equality of headers. More...
 

Detailed Description

Interface for shared memory header.

This class has to be implemented to be able to use shared memory segments. It defines a set of properties for the shared memory segment that can be searched for and printed out by an appropriate lister.

See also
SharedMemory
SharedMemoryLister
Author
Tim Niemueller

Definition at line 33 of file shm.h.

Constructor & Destructor Documentation

◆ ~SharedMemoryHeader()

fawkes::SharedMemoryHeader::~SharedMemoryHeader ( )
inlinevirtual

Virtual destructor.

Definition at line 35 of file shm.h.

References clone(), data_size(), initialize(), matches(), operator==(), reset(), and size().

Member Function Documentation

◆ clone()

SharedMemoryHeader * fawkes::SharedMemoryHeader::clone ( ) const
pure virtual

Clone this shared memory header.

This method shall return a copied instance of this SharedMemoryHeader derivate. It should act the same way as the current instance.

Returns
Clone instance. Remember to delete the instance.

Implemented in firevision::SharedMemoryImageBufferHeader, firevision::SharedMemoryLookupTableHeader, and fawkes::BlackBoardSharedMemoryHeader.

Referenced by fawkes::SharedMemory::SharedMemoryIterator::operator=(), fawkes::SharedMemory::SharedMemory(), fawkes::SharedMemory::SharedMemoryIterator::SharedMemoryIterator(), and ~SharedMemoryHeader().

◆ data_size()

size_t fawkes::SharedMemoryHeader::data_size ( )
pure virtual

Return the size of the data.

The size of the data that will be stored in the shared memory segment. This method has to return the same value everytime and may only depend on the other data set in the header and written to the shared memory segment.

Returns
the size of the data segment

Implemented in firevision::SharedMemoryImageBufferHeader, firevision::SharedMemoryLookupTableHeader, and fawkes::BlackBoardSharedMemoryHeader.

Referenced by fawkes::SharedMemory::attach(), and ~SharedMemoryHeader().

◆ initialize()

void fawkes::SharedMemoryHeader::initialize ( void *  memptr)
pure virtual

Initialize the header.

This should initialize the header data in the given memptr from the data of this SharedMemoryHeader derivate instance. It has to write out all state information that is needed to identify the shared memory segment later on.

Parameters
memptrthe memptr where the header data shall be written to.

Implemented in firevision::SharedMemoryImageBufferHeader, firevision::SharedMemoryLookupTableHeader, and fawkes::BlackBoardSharedMemoryHeader.

Referenced by fawkes::SharedMemory::attach(), and ~SharedMemoryHeader().

◆ matches()

bool fawkes::SharedMemoryHeader::matches ( void *  memptr)
pure virtual

Method to check if the given memptr matches this header.

This method is called when searching for a shared memory segment to open, list or erase it. Implement this to distuinguish several shared memory segments that share the same magic token.

Parameters
memptrThe memory chunk in the shared memory segment where to start checking.
Returns
true, if the given data in the memory chunk matches this header, false otherwise.

Implemented in firevision::SharedMemoryImageBufferHeader, firevision::SharedMemoryLookupTableHeader, and fawkes::BlackBoardSharedMemoryHeader.

Referenced by fawkes::SharedMemory::attach(), and ~SharedMemoryHeader().

◆ operator==()

bool fawkes::SharedMemoryHeader::operator== ( const SharedMemoryHeader s) const
pure virtual

Check for equality of headers.

This shall be implemented that it compares the current and the given instances for equality. You probably want to use dynamic_cast to cast the given instance to a compatible type.

Parameters
sshared memory header to compare to
Returns
true if the two instances identify the very same shared memory segments, false otherwise

Implemented in firevision::SharedMemoryImageBufferHeader, firevision::SharedMemoryLookupTableHeader, and fawkes::BlackBoardSharedMemoryHeader.

Referenced by ~SharedMemoryHeader().

◆ reset()

void fawkes::SharedMemoryHeader::reset ( void  )
pure virtual

Reset information previously set with set().

This shall restore the state the header had before set() was called. This is used for instance in the SharedMemoryLister after info about one segment has been printed.

Implemented in firevision::SharedMemoryImageBufferHeader, firevision::SharedMemoryLookupTableHeader, and fawkes::BlackBoardSharedMemoryHeader.

Referenced by ~SharedMemoryHeader().

◆ set()

void fawkes::SharedMemoryHeader::set ( void *  memptr)
pure virtual

Set information from memptr.

Set the information stored in this SharedMemoryHeader derivate instance from the data stored in the given memptr.

Parameters
memptrThe memptr where to copy data from.

Implemented in firevision::SharedMemoryImageBufferHeader, firevision::SharedMemoryLookupTableHeader, and fawkes::BlackBoardSharedMemoryHeader.

Referenced by fawkes::SharedMemory::attach().

◆ size()

unsigned int fawkes::SharedMemoryHeader::size ( )
pure virtual

Size of the header.

The size that is needed in the shared memory memptr to accomodate the header data. This size has to fit all the data that will be stored in the header. It must return the same size every time.

Returns
size of header

Implemented in firevision::SharedMemoryImageBufferHeader, firevision::SharedMemoryLookupTableHeader, and fawkes::BlackBoardSharedMemoryHeader.

Referenced by fawkes::SharedMemory::attach(), and ~SharedMemoryHeader().


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