Fawkes API  Fawkes Development Version
firevision::SharedMemoryLookupTable Class Reference

Shared memory lookup table. More...

#include <>>

Inheritance diagram for firevision::SharedMemoryLookupTable:

Public Member Functions

 SharedMemoryLookupTable (const char *lut_id, unsigned int width, unsigned int height, unsigned int depth=1, unsigned int bytes_per_cell=1)
 Write Constructor. More...
 
 SharedMemoryLookupTable (const char *lut_id, bool is_read_only=true)
 Read constructor. More...
 
 ~SharedMemoryLookupTable ()
 Destructor. More...
 
const char * lut_id () const
 Get LUT ID. More...
 
bool set_lut_id (const char *lut_id)
 Set LUT ID. More...
 
unsigned char * buffer () const
 Get LUT buffer. More...
 
unsigned int width () const
 Get LUT width. More...
 
unsigned int height () const
 Get LUT height. More...
 
unsigned int depth () const
 Get LUT depth. More...
 
unsigned int bytes_per_cell () const
 Get bytes per cell. More...
 
- Public Member Functions inherited from fawkes::SharedMemory
 SharedMemory (const char *magic_token, SharedMemoryHeader *header, bool is_read_only, bool create, bool destroy_on_delete, const char *registry_name=0)
 Create a new shared memory segment. More...
 
 SharedMemory (const SharedMemory &s)
 Copy constructor. More...
 
virtual ~SharedMemory ()
 Destructor. More...
 
bool is_read_only () const
 Check for read-only mode. More...
 
bool is_destroyed () const
 Check if segment has been destroyed This can be used if the segment has been destroyed. More...
 
bool is_swapable () const
 Check if memory can be swapped out. More...
 
bool is_valid () const
 Check validity of shared memory segment. More...
 
bool is_creator () const
 Determine if the shared memory segment has been created by this instance. More...
 
bool is_protected () const
 Check if memory segment is protected. More...
 
void * memptr () const
 Get a pointer to the shared memory This method returns a pointer to the data-segment of the shared memory segment. More...
 
size_t data_size () const
 Get the size of the data-segment. More...
 
int shmem_id () const
 Get shared memory ID. More...
 
unsigned int num_attached () const
 Get number of attached processes. More...
 
void set (void *memptr)
 Copies data from the memptr to shared memory. More...
 
void set_destroy_on_delete (bool destroy)
 Set deletion behaviour. More...
 
void add_semaphore ()
 Add semaphore to shared memory segment. More...
 
void set_swapable (bool swapable)
 Set shared memory swapable. More...
 
void lock_for_read ()
 Lock shared memory segment for reading. More...
 
bool try_lock_for_read ()
 Try to aquire lock on shared memory segment for reading. More...
 
void lock_for_write ()
 Lock shared memory segment for writing. More...
 
bool try_lock_for_write ()
 Try to aquire lock on shared memory segment for writing. More...
 
void unlock ()
 Unlock memory. More...
 
void * ptr (void *addr) const
 Get the real pointer to the data based on an address. More...
 
void * addr (void *ptr) const
 Get an address from a real pointer. More...
 

Static Public Member Functions

static void list ()
 List shared memory LUT segments. More...
 
static void cleanup (bool use_lister=true)
 Erase all shared memory segments that contain FireVision LUTs. More...
 
static bool exists (const char *lut_id)
 Check LUT availability. More...
 
static void wipe (const char *lut_id)
 Erase a specific shared memory segment that contains a LUT. More...
 
- Static Public Member Functions inherited from fawkes::SharedMemory
static void list (const char *magic_token, SharedMemoryHeader *header, SharedMemoryLister *lister, const char *registry_name=0)
 List shared memory segments of a given type. More...
 
static void erase (const char *magic_token, SharedMemoryHeader *header, SharedMemoryLister *lister=0, const char *registry_name=0)
 Erase shared memory segments of a given type. More...
 
static void erase_orphaned (const char *magic_token, SharedMemoryHeader *header, SharedMemoryLister *lister=0, const char *registry_name=0)
 Erase orphaned (attach count = 0) shared memory segments of a given type. More...
 
static bool exists (const char *magic_token, SharedMemoryHeader *header, const char *registry_name=0)
 Check if a specific shared memory segment exists. More...
 
static bool is_destroyed (int shm_id)
 Check if a segment has been destroyed. More...
 
static bool is_swapable (int shm_id)
 Check if memory can be swapped out. More...
 
static unsigned int num_attached (int shm_id)
 Get number of attached processes. More...
 
static SharedMemoryIterator find (const char *magic_token, SharedMemoryHeader *header, const char *registry_name=0)
 Find SharedMemory segments. More...
 
static SharedMemoryIterator end ()
 Get invalid iterator. More...
 

Additional Inherited Members

- Static Public Attributes inherited from fawkes::SharedMemory
static const unsigned int MagicTokenSize = MAGIC_TOKEN_SIZE
 The magic token size. More...
 
static const short MaxNumConcurrentReaders = 8
 Maximum number of concurrent readers. More...
 
- Protected Member Functions inherited from fawkes::SharedMemory
 SharedMemory (const char *magic_token, bool is_read_only, bool create, bool destroy_on_delete, const char *registry_name=0)
 Constructor for derivates. More...
 
void attach ()
 Attach to the shared memory segment. More...
 
void free ()
 Detach from and maybe destroy the shared memory segment. More...
 
- Protected Attributes inherited from fawkes::SharedMemory
void * _memptr
 Pointer to the data segment. More...
 
size_t _mem_size
 Total size of the segment, including headers. More...
 
size_t _data_size
 Size of the data segment only. More...
 
SharedMemoryHeader_header
 Data-specific header. More...
 
bool _is_read_only
 Read-only. More...
 
bool _destroy_on_delete
 destroy on delete. More...
 
bool _should_create
 Create shared memory segment. More...
 
char * _magic_token
 Magic token. More...
 
char * _shm_magic_token
 Magic token as stored in the shared memory segment. More...
 
SharedMemory_header_t_shm_header
 general header as stored in the shared memory segment More...
 
void * _shm_upper_bound
 Upper bound of memory. More...
 
long unsigned int _shm_offset
 Offset to the master's base addr. More...
 

Detailed Description

Shared memory lookup table.

Definition at line 113 of file shm_lut.h.

Constructor & Destructor Documentation

◆ SharedMemoryLookupTable() [1/2]

firevision::SharedMemoryLookupTable::SharedMemoryLookupTable ( const char *  lut_id,
unsigned int  width,
unsigned int  height,
unsigned int  depth = 1,
unsigned int  bytes_per_cell = 1 
)

Write Constructor.

Create a new shared memory segment. Will open a shared memory segment that exactly fits the given information. Will throw an error if image with num image_num exists it will throw an exception an exception. I will create a new segment if no matching segment was found. The segment is accessed in read-write mode.

Parameters
lut_idLUT ID
widthLUT width
heightLUT height
depthLUT depth
bytes_per_cellLUT bytes per cell

Definition at line 58 of file shm_lut.cpp.

◆ SharedMemoryLookupTable() [2/2]

firevision::SharedMemoryLookupTable::SharedMemoryLookupTable ( const char *  lut_id,
bool  is_read_only = true 
)

Read constructor.

This constructor is used to search for an existing shared memory segment. It will throw an error if it cannot find a segment with the specified data. The segment is opened read-only by default, but this can be overridden with the is_read_only argument if needed.

Parameters
lut_idLUT ID
is_read_onlytrue to open read-only

Definition at line 77 of file shm_lut.cpp.

References fawkes::SharedMemory::_header, fawkes::SharedMemory::_is_read_only, fawkes::SharedMemory::_memptr, fawkes::SharedMemory::attach(), bytes_per_cell(), depth(), height(), fawkes::SharedMemory::is_read_only(), lut_id(), firevision::SharedMemoryLookupTableHeader::raw_header(), and width().

◆ ~SharedMemoryLookupTable()

firevision::SharedMemoryLookupTable::~SharedMemoryLookupTable ( )

Destructor.

Definition at line 111 of file shm_lut.cpp.

References fawkes::SharedMemory::free().

Member Function Documentation

◆ buffer()

unsigned char * firevision::SharedMemoryLookupTable::buffer ( ) const

Get LUT buffer.

Returns
LUT buffer

Definition at line 148 of file shm_lut.cpp.

References fawkes::SharedMemory::_memptr.

Referenced by firevision::FuseLutContent::FuseLutContent().

◆ bytes_per_cell()

unsigned int firevision::SharedMemoryLookupTable::bytes_per_cell ( ) const

◆ cleanup()

void firevision::SharedMemoryLookupTable::cleanup ( bool  use_lister = true)
static

Erase all shared memory segments that contain FireVision LUTs.

Parameters
use_listerif true a lister is used to print the shared memory segments to stdout while cleaning up.

Definition at line 213 of file shm_lut.cpp.

◆ depth()

unsigned int firevision::SharedMemoryLookupTable::depth ( ) const

◆ exists()

bool firevision::SharedMemoryLookupTable::exists ( const char *  lut_id)
static

Check LUT availability.

Parameters
lut_idimage number to check
Returns
true if shared memory segment with requested LUT exists

Definition at line 234 of file shm_lut.cpp.

◆ height()

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

◆ list()

void firevision::SharedMemoryLookupTable::list ( )
static

List shared memory LUT segments.

Definition at line 196 of file shm_lut.cpp.

◆ lut_id()

const char * firevision::SharedMemoryLookupTable::lut_id ( ) const

Get LUT ID.

Returns
LUT ID

Definition at line 122 of file shm_lut.cpp.

Referenced by firevision::FuseLutContent::FuseLutContent(), and SharedMemoryLookupTable().

◆ set_lut_id()

bool firevision::SharedMemoryLookupTable::set_lut_id ( const char *  lut_id)

Set LUT ID.

Parameters
lut_idLUT ID
Returns
true on success

Definition at line 133 of file shm_lut.cpp.

References fawkes::SharedMemory::_memptr, fawkes::SharedMemory::attach(), fawkes::SharedMemory::free(), and firevision::SharedMemoryLookupTableHeader::set_lut_id().

◆ width()

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

◆ wipe()

void firevision::SharedMemoryLookupTable::wipe ( const char *  lut_id)
static

Erase a specific shared memory segment that contains a LUT.

Parameters
lut_idLUT ID

Definition at line 247 of file shm_lut.cpp.


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