Fawkes API  Fawkes Development Version
shm_lut.h
1 
2 /***************************************************************************
3  * shm_lut.h - shared memory lookup table
4  *
5  * Generated: Thu Feb 09 16:57:40 2006
6  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _FIREVISION_FVUTILS_IPC_SHM_LUT_H_
25 #define _FIREVISION_FVUTILS_IPC_SHM_LUT_H_
26 
27 #include <fvutils/ipc/defs.h>
28 #include <utils/ipc/shm.h>
29 #include <utils/ipc/shm_lister.h>
30 
31 #include <stdint.h>
32 
33 // Magic token to identify FireVision shared memory LUTs
34 #define FIREVISION_SHM_LUT_MAGIC_TOKEN "FireVision LUT"
35 
36 namespace firevision {
37 
38 /** Shared memory lookup table header struct. */
39 typedef struct
40 {
41  char lut_id[LUT_ID_MAX_LENGTH]; /**< LUT ID */
42  uint32_t width; /**< LUT width */
43  uint32_t height; /**< LUT height */
44  uint32_t depth; /**< LUT depth */
45  uint32_t bytes_per_cell; /**< Bytes per cell */
47 
49 {
50 public:
53  unsigned int width,
54  unsigned int height,
55  unsigned int bytes_per_cell);
57  unsigned int width,
58  unsigned int height,
59  unsigned int depth,
60  unsigned int bytes_per_cell);
63 
64  virtual fawkes::SharedMemoryHeader *clone() const;
65  virtual bool matches(void *memptr);
66  virtual size_t size();
67  virtual bool create();
68  virtual void initialize(void *memptr);
69  virtual void set(void *memptr);
70  virtual void reset();
71  virtual size_t data_size();
72  virtual bool operator==(const fawkes::SharedMemoryHeader &s) const;
73 
74  virtual void print_info();
75 
76  const char * lut_id() const;
77  void set_lut_id(const char *lut_id);
78  unsigned int width() const;
79  unsigned int height() const;
80  unsigned int depth() const;
81  unsigned int bytes_per_cell() const;
82 
84 
85 private:
87 
88  char * lut_id_;
89  unsigned int width_;
90  unsigned int height_;
91  unsigned int depth_;
92  unsigned int bytes_per_cell_;
93 };
94 
96 {
97 public:
100 
101  virtual void print_header();
102  virtual void print_footer();
103  virtual void print_no_segments();
104  virtual void print_no_orphaned_segments();
105  virtual void print_info(const fawkes::SharedMemoryHeader *header,
106  int shm_id,
107  int semaphore,
108  unsigned int mem_size,
109  const void * memptr);
110 };
111 
113 {
114 public:
115  SharedMemoryLookupTable(const char * lut_id,
116  unsigned int width,
117  unsigned int height,
118  unsigned int depth = 1,
119  unsigned int bytes_per_cell = 1);
120  SharedMemoryLookupTable(const char *lut_id, bool is_read_only = true);
122 
123  const char * lut_id() const;
124  bool set_lut_id(const char *lut_id);
125  unsigned char *buffer() const;
126  unsigned int width() const;
127  unsigned int height() const;
128  unsigned int depth() const;
129  unsigned int bytes_per_cell() const;
130 
131  static void list();
132  static void cleanup(bool use_lister = true);
133  static bool exists(const char *lut_id);
134  static void wipe(const char *lut_id);
135 
136 private:
137  void constructor(const char * lut_id,
138  unsigned int width,
139  unsigned int height,
140  unsigned int depth,
141  unsigned int bytes_per_cell,
142  bool is_read_only);
143 
144  SharedMemoryLookupTableHeader * priv_header_;
146 
147  char * lut_id_;
148  unsigned int width_;
149  unsigned int height_;
150  unsigned int depth_;
151  unsigned int bytes_per_cell_;
152 };
153 
154 } // end namespace firevision
155 
156 #endif
firevision::SharedMemoryLookupTableHeader
Definition: shm_lut.h:47
firevision::SharedMemoryLookupTableHeader::clone
virtual fawkes::SharedMemoryHeader * clone() const
Definition: shm_lut.cpp:323
firevision::SharedMemoryLookupTable::buffer
unsigned char * buffer() const
Get LUT buffer.
Definition: shm_lut.cpp:140
firevision::SharedMemoryLookupTableHeader::lut_id
const char * lut_id() const
Get LUT ID.
Definition: shm_lut.cpp:485
firevision::SharedMemoryLookupTableLister
Definition: shm_lut.h:94
firevision::SharedMemoryLookupTableHeader::set
virtual void set(void *memptr)
Definition: shm_lut.cpp:404
fawkes::SharedMemory
Definition: shm.h:56
fawkes::SharedMemoryLister
Format list output for shared memory segments.
Definition: shm_lister.h:41
firevision::SharedMemoryLookupTable::set_lut_id
bool set_lut_id(const char *lut_id)
Set LUT ID.
Definition: shm_lut.cpp:126
fawkes::SharedMemory::is_read_only
bool is_read_only() const
Check for read-only mode.
Definition: shm.cpp:710
firevision::SharedMemoryLookupTableHeader::data_size
virtual size_t data_size()
Definition: shm_lut.cpp:335
firevision::SharedMemoryLookupTableHeader::reset
virtual void reset()
Definition: shm_lut.cpp:410
firevision::SharedMemoryLookupTableLister::print_no_orphaned_segments
virtual void print_no_orphaned_segments()
Print this if no matching orphaned segment was found.
Definition: shm_lut.cpp:559
firevision::SharedMemoryLookupTableHeader::height
unsigned int height() const
Get LUT height.
Definition: shm_lut.cpp:452
firevision::SharedMemoryLookupTable::wipe
static void wipe(const char *lut_id)
Erase a specific shared memory segment that contains a LUT.
Definition: shm_lut.cpp:231
fawkes::SharedMemoryHeader
Definition: shm.h:37
firevision::SharedMemoryLookupTable_header_t
Shared memory lookup table header struct.
Definition: shm_lut.h:38
firevision::SharedMemoryLookupTableHeader::create
virtual bool create()
Check if buffer should be created.
Definition: shm_lut.cpp:385
firevision::SharedMemoryLookupTable::list
static void list()
List shared memory LUT segments.
Definition: shm_lut.cpp:183
firevision::SharedMemoryLookupTableHeader::SharedMemoryLookupTableHeader
SharedMemoryLookupTableHeader()
Constructor.
Definition: shm_lut.cpp:243
firevision::SharedMemoryLookupTableHeader::matches
virtual bool matches(void *memptr)
Definition: shm_lut.cpp:345
firevision::SharedMemoryLookupTableLister::print_info
virtual void print_info(const fawkes::SharedMemoryHeader *header, int shm_id, int semaphore, unsigned int mem_size, const void *memptr)
Print info about segment.
Definition: shm_lut.cpp:565
firevision::SharedMemoryLookupTableLister::SharedMemoryLookupTableLister
SharedMemoryLookupTableLister()
Constructor.
Definition: shm_lut.cpp:517
firevision::SharedMemoryLookupTableHeader::operator==
virtual bool operator==(const fawkes::SharedMemoryHeader &s) const
Check for equality of headers.
Definition: shm_lut.cpp:425
firevision::SharedMemoryLookupTableLister::~SharedMemoryLookupTableLister
virtual ~SharedMemoryLookupTableLister()
Destructor.
Definition: shm_lut.cpp:522
firevision::SharedMemoryLookupTableHeader::print_info
virtual void print_info()
Print Info.
Definition: shm_lut.cpp:367
firevision::SharedMemoryLookupTable::exists
static bool exists(const char *lut_id)
Check LUT availability.
Definition: shm_lut.cpp:219
firevision::SharedMemoryLookupTableHeader::raw_header
SharedMemoryLookupTable_header_t * raw_header()
Get raw header.
Definition: shm_lut.cpp:507
firevision::SharedMemoryLookupTableHeader::set_lut_id
void set_lut_id(const char *lut_id)
Set LUT ID.
Definition: shm_lut.cpp:496
firevision::SharedMemoryLookupTable::lut_id
const char * lut_id() const
Get LUT ID.
Definition: shm_lut.cpp:116
firevision::SharedMemoryLookupTable::SharedMemoryLookupTable
SharedMemoryLookupTable(const char *lut_id, unsigned int width, unsigned int height, unsigned int depth=1, unsigned int bytes_per_cell=1)
Write Constructor.
Definition: shm_lut.cpp:54
firevision::SharedMemoryLookupTableLister::print_no_segments
virtual void print_no_segments()
Print this if no matching segment was found.
Definition: shm_lut.cpp:553
firevision::SharedMemoryLookupTable::width
unsigned int width() const
Get LUT width.
Definition: shm_lut.cpp:149
firevision::SharedMemoryLookupTable::bytes_per_cell
unsigned int bytes_per_cell() const
Get bytes per cell.
Definition: shm_lut.cpp:176
firevision::SharedMemoryLookupTable
Definition: shm_lut.h:111
firevision::SharedMemoryLookupTable::depth
unsigned int depth() const
Get LUT depth.
Definition: shm_lut.cpp:167
firevision::SharedMemoryLookupTableLister::print_footer
virtual void print_footer()
Print footer of the table.
Definition: shm_lut.cpp:548
firevision::SharedMemoryLookupTableHeader::bytes_per_cell
unsigned int bytes_per_cell() const
Get bytes per cell.
Definition: shm_lut.cpp:474
firevision::SharedMemoryLookupTableHeader::size
virtual size_t size()
Definition: shm_lut.cpp:329
firevision::SharedMemoryLookupTableHeader::initialize
virtual void initialize(void *memptr)
Definition: shm_lut.cpp:391
firevision::SharedMemoryLookupTable::height
unsigned int height() const
Get LUT height.
Definition: shm_lut.cpp:158
firevision::SharedMemoryLookupTableHeader::width
unsigned int width() const
Get LUT width.
Definition: shm_lut.cpp:441
firevision::SharedMemoryLookupTable::~SharedMemoryLookupTable
~SharedMemoryLookupTable()
Destructor.
Definition: shm_lut.cpp:106
firevision::SharedMemoryLookupTableLister::print_header
virtual void print_header()
Print header of the table.
Definition: shm_lut.cpp:527
firevision::SharedMemoryLookupTable::cleanup
static void cleanup(bool use_lister=true)
Erase all shared memory segments that contain FireVision LUTs.
Definition: shm_lut.cpp:199
firevision::SharedMemoryLookupTableHeader::~SharedMemoryLookupTableHeader
virtual ~SharedMemoryLookupTableHeader()
Destructor.
Definition: shm_lut.cpp:313
firevision::SharedMemoryLookupTableHeader::depth
unsigned int depth() const
Get LUT depth.
Definition: shm_lut.cpp:463