Fawkes API  Fawkes Development Version
firevision::SharedMemoryImageBufferHeader Class Reference

Shared memory image buffer header. More...

#include <>>

Inheritance diagram for firevision::SharedMemoryImageBufferHeader:

Public Member Functions

 SharedMemoryImageBufferHeader ()
 Constructor. More...
 
 SharedMemoryImageBufferHeader (const char *image_id, colorspace_t colorspace, unsigned int width, unsigned int height)
 Constructor. More...
 
 SharedMemoryImageBufferHeader (const SharedMemoryImageBufferHeader *h)
 Copy constructor. More...
 
virtual ~SharedMemoryImageBufferHeader ()
 Destructor. More...
 
virtual fawkes::SharedMemoryHeaderclone () const
 Clone this shared memory header. More...
 
virtual bool matches (void *memptr)
 Method to check if the given memptr matches this header. More...
 
virtual size_t size ()
 Size of the header. More...
 
virtual void print_info ()
 Print some info. More...
 
virtual bool create ()
 Create if colorspace, width and height have been supplied. More...
 
virtual void initialize (void *memptr)
 Initialize the header. More...
 
virtual void set (void *memptr)
 Set information from memptr. More...
 
virtual void reset ()
 Reset information previously set with set(). More...
 
virtual size_t data_size ()
 Return the size of the data. More...
 
virtual bool operator== (const fawkes::SharedMemoryHeader &s) const
 Check for equality of headers. More...
 
void set_image_id (const char *image_id)
 Set image id. More...
 
void set_frame_id (const char *frame_id)
 Set frame ID. More...
 
colorspace_t colorspace () const
 Get colorspace. More...
 
unsigned int width () const
 Get width. More...
 
unsigned int height () const
 Get height. More...
 
const char * image_id () const
 Get image number. More...
 
const char * frame_id () const
 Get frame ID. More...
 
SharedMemoryImageBuffer_header_traw_header ()
 Get raw header. More...
 
- Public Member Functions inherited from fawkes::SharedMemoryHeader
virtual ~SharedMemoryHeader ()
 Virtual destructor. More...
 

Detailed Description

Shared memory image buffer header.

Definition at line 69 of file shm_image.h.

Constructor & Destructor Documentation

◆ SharedMemoryImageBufferHeader() [1/3]

firevision::SharedMemoryImageBufferHeader::SharedMemoryImageBufferHeader ( )

Constructor.

Definition at line 582 of file shm_image.cpp.

References fawkes::SharedMemory::_header.

◆ SharedMemoryImageBufferHeader() [2/3]

firevision::SharedMemoryImageBufferHeader::SharedMemoryImageBufferHeader ( const char *  image_id,
colorspace_t  colorspace,
unsigned int  width,
unsigned int  height 
)

Constructor.

Parameters
image_idimage id
colorspacecolorspace
widthwidth
heightheight

Definition at line 601 of file shm_image.cpp.

References fawkes::SharedMemory::_header, firevision::SharedMemoryImageBuffer::colorspace(), firevision::SharedMemoryImageBuffer::height(), and firevision::SharedMemoryImageBuffer::width().

◆ SharedMemoryImageBufferHeader() [3/3]

firevision::SharedMemoryImageBufferHeader::SharedMemoryImageBufferHeader ( const SharedMemoryImageBufferHeader h)

Copy constructor.

Parameters
hshared memory image header to copy

Definition at line 624 of file shm_image.cpp.

References fawkes::SharedMemory::_header.

◆ ~SharedMemoryImageBufferHeader()

firevision::SharedMemoryImageBufferHeader::~SharedMemoryImageBufferHeader ( )
virtual

Destructor.

Definition at line 650 of file shm_image.cpp.

References fawkes::SharedMemory::free().

Member Function Documentation

◆ clone()

SharedMemoryHeader * firevision::SharedMemoryImageBufferHeader::clone ( ) const
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.

Implements fawkes::SharedMemoryHeader.

Definition at line 667 of file shm_image.cpp.

◆ colorspace()

colorspace_t firevision::SharedMemoryImageBufferHeader::colorspace ( ) const

◆ create()

bool firevision::SharedMemoryImageBufferHeader::create ( )
virtual

Create if colorspace, width and height have been supplied.

Returns
true if colorspace has been set, width and height are greater than zero.

Definition at line 763 of file shm_image.cpp.

◆ data_size()

size_t firevision::SharedMemoryImageBufferHeader::data_size ( )
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

Implements fawkes::SharedMemoryHeader.

Definition at line 674 of file shm_image.cpp.

References fawkes::SharedMemory::_header.

◆ frame_id()

const char * firevision::SharedMemoryImageBufferHeader::frame_id ( ) const

◆ height()

unsigned int firevision::SharedMemoryImageBufferHeader::height ( ) const

◆ image_id()

◆ initialize()

void firevision::SharedMemoryImageBufferHeader::initialize ( void *  memptr)
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.

Implements fawkes::SharedMemoryHeader.

Definition at line 772 of file shm_image.cpp.

References fawkes::SharedMemory::_header, firevision::SharedMemoryImageBuffer_header_t::colorspace, firevision::SharedMemoryImageBuffer_header_t::frame_id, firevision::SharedMemoryImageBuffer_header_t::height, firevision::SharedMemoryImageBuffer_header_t::image_id, and firevision::SharedMemoryImageBuffer_header_t::width.

◆ matches()

bool firevision::SharedMemoryImageBufferHeader::matches ( void *  memptr)
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.

Implements fawkes::SharedMemoryHeader.

Definition at line 685 of file shm_image.cpp.

References firevision::SharedMemoryImageBuffer_header_t::colorspace, firevision::SharedMemoryImageBuffer_header_t::frame_id, firevision::SharedMemoryImageBuffer_header_t::height, firevision::SharedMemoryImageBuffer_header_t::image_id, and firevision::SharedMemoryImageBuffer_header_t::width.

◆ operator==()

bool firevision::SharedMemoryImageBufferHeader::operator== ( const fawkes::SharedMemoryHeader s) const
virtual

Check for equality of headers.

First checks if passed SharedMemoryHeader is an instance of SharedMemoryImageBufferHeader. If not returns false, otherwise it compares image ID, colorspace, width, and height. If all match returns true, false if any of them differs.

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

Implements fawkes::SharedMemoryHeader.

Definition at line 720 of file shm_image.cpp.

◆ print_info()

void firevision::SharedMemoryImageBufferHeader::print_info ( )
virtual

Print some info.

Definition at line 736 of file shm_image.cpp.

References fawkes::SharedMemory::_header.

◆ raw_header()

SharedMemoryImageBuffer_header_t * firevision::SharedMemoryImageBufferHeader::raw_header ( )

◆ reset()

void firevision::SharedMemoryImageBufferHeader::reset ( void  )
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.

Implements fawkes::SharedMemoryHeader.

Definition at line 821 of file shm_image.cpp.

References fawkes::SharedMemory::_header, and fawkes::SharedMemory::free().

◆ set()

void firevision::SharedMemoryImageBufferHeader::set ( void *  memptr)
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.

Implements fawkes::SharedMemoryHeader.

Definition at line 790 of file shm_image.cpp.

References fawkes::SharedMemory::_header, firevision::SharedMemoryImageBuffer_header_t::colorspace, firevision::SharedMemoryImageBuffer_header_t::frame_id, fawkes::SharedMemory::free(), firevision::SharedMemoryImageBuffer_header_t::height, firevision::SharedMemoryImageBuffer_header_t::image_id, and firevision::SharedMemoryImageBuffer_header_t::width.

◆ set_frame_id()

void firevision::SharedMemoryImageBufferHeader::set_frame_id ( const char *  frame_id)

Set frame ID.

Parameters
frame_idframe ID

Definition at line 912 of file shm_image.cpp.

References fawkes::SharedMemory::free().

Referenced by firevision::SharedMemoryImageBuffer::set_frame_id().

◆ set_image_id()

void firevision::SharedMemoryImageBufferHeader::set_image_id ( const char *  image_id)

Set image id.

Parameters
image_idimage ID

Definition at line 901 of file shm_image.cpp.

References fawkes::SharedMemory::free().

Referenced by firevision::SharedMemoryImageBuffer::set_image_id().

◆ size()

size_t firevision::SharedMemoryImageBufferHeader::size ( )
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

Implements fawkes::SharedMemoryHeader.

Definition at line 660 of file shm_image.cpp.

◆ width()

unsigned int firevision::SharedMemoryImageBufferHeader::width ( ) const

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