shm_lut.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __FIREVISION_FVUTILS_IPC_SHM_LUT_H_
00025 #define __FIREVISION_FVUTILS_IPC_SHM_LUT_H_
00026
00027 #include <utils/ipc/shm.h>
00028 #include <utils/ipc/shm_lister.h>
00029 #include <fvutils/ipc/defs.h>
00030 #include <stdint.h>
00031
00032
00033 #define FIREVISION_SHM_LUT_MAGIC_TOKEN "FireVision LUT"
00034
00035
00036 typedef struct {
00037 char lut_id[LUT_ID_MAX_LENGTH];
00038 uint32_t width;
00039 uint32_t height;
00040 uint32_t depth;
00041 uint32_t bytes_per_cell;
00042 } SharedMemoryLookupTable_header_t;
00043
00044
00045 class SharedMemoryLookupTableHeader : public fawkes::SharedMemoryHeader
00046 {
00047 public:
00048 SharedMemoryLookupTableHeader();
00049 SharedMemoryLookupTableHeader(const char *lut_id,
00050 unsigned int width,
00051 unsigned int height,
00052 unsigned int bytes_per_cell);
00053 SharedMemoryLookupTableHeader(const char *lut_id,
00054 unsigned int width,
00055 unsigned int height,
00056 unsigned int depth,
00057 unsigned int bytes_per_cell);
00058 SharedMemoryLookupTableHeader(const SharedMemoryLookupTableHeader *h);
00059 virtual ~SharedMemoryLookupTableHeader();
00060
00061 virtual fawkes::SharedMemoryHeader * clone() const;
00062 virtual bool matches(void *memptr);
00063 virtual size_t size();
00064 virtual bool create();
00065 virtual void initialize(void *memptr);
00066 virtual void set(void *memptr);
00067 virtual void reset();
00068 virtual size_t data_size();
00069 virtual bool operator==(const fawkes::SharedMemoryHeader & s) const;
00070
00071 virtual void print_info();
00072
00073 const char * lut_id() const;
00074 void set_lut_id(const char *lut_id);
00075 unsigned int width() const;
00076 unsigned int height() const;
00077 unsigned int depth() const;
00078 unsigned int bytes_per_cell() const;
00079
00080 SharedMemoryLookupTable_header_t * raw_header();
00081
00082 private:
00083 SharedMemoryLookupTable_header_t *__header;
00084
00085 char *__lut_id;
00086 unsigned int __width;
00087 unsigned int __height;
00088 unsigned int __depth;
00089 unsigned int __bytes_per_cell;
00090 };
00091
00092 class SharedMemoryLookupTableLister : public fawkes::SharedMemoryLister
00093 {
00094 public:
00095 SharedMemoryLookupTableLister();
00096 virtual ~SharedMemoryLookupTableLister();
00097
00098 virtual void print_header();
00099 virtual void print_footer();
00100 virtual void print_no_segments();
00101 virtual void print_no_orphaned_segments();
00102 virtual void print_info(const fawkes::SharedMemoryHeader *header,
00103 int shm_id, int semaphore, unsigned int mem_size,
00104 const void *memptr);
00105 };
00106
00107
00108 class SharedMemoryLookupTable : public fawkes::SharedMemory
00109 {
00110
00111 public:
00112
00113 SharedMemoryLookupTable( const char *lut_id,
00114 unsigned int width, unsigned int height,
00115 unsigned int depth = 1,
00116 unsigned int bytes_per_cell = 1
00117 );
00118 SharedMemoryLookupTable(const char *lut_id , bool is_read_only = true);
00119 ~SharedMemoryLookupTable();
00120
00121 const char * lut_id() const;
00122 bool set_lut_id(const char *lut_id);
00123 unsigned char * buffer() const;
00124 unsigned int width() const;
00125 unsigned int height() const;
00126 unsigned int depth() const;
00127 unsigned int bytes_per_cell() const;
00128
00129 static void list();
00130 static void cleanup(bool use_lister = true);
00131 static bool exists(const char *lut_id);
00132 static void wipe(const char *lut_id);
00133
00134 private:
00135 void constructor(const char *lut_id,
00136 unsigned int width, unsigned int height, unsigned int depth,
00137 unsigned int bytes_per_cell,
00138 bool is_read_only);
00139
00140 SharedMemoryLookupTableHeader *__priv_header;
00141 SharedMemoryLookupTable_header_t *__raw_header;
00142
00143 char *__lut_id;
00144 unsigned int __width;
00145 unsigned int __height;
00146 unsigned int __depth;
00147 unsigned int __bytes_per_cell;
00148
00149 };
00150
00151
00152 #endif