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 namespace firevision {
00036 #if 0
00037 }
00038 #endif
00039
00040
00041 typedef struct {
00042 char lut_id[LUT_ID_MAX_LENGTH];
00043 uint32_t width;
00044 uint32_t height;
00045 uint32_t depth;
00046 uint32_t bytes_per_cell;
00047 } SharedMemoryLookupTable_header_t;
00048
00049
00050 class SharedMemoryLookupTableHeader : public fawkes::SharedMemoryHeader
00051 {
00052 public:
00053 SharedMemoryLookupTableHeader();
00054 SharedMemoryLookupTableHeader(const char *lut_id,
00055 unsigned int width,
00056 unsigned int height,
00057 unsigned int bytes_per_cell);
00058 SharedMemoryLookupTableHeader(const char *lut_id,
00059 unsigned int width,
00060 unsigned int height,
00061 unsigned int depth,
00062 unsigned int bytes_per_cell);
00063 SharedMemoryLookupTableHeader(const SharedMemoryLookupTableHeader *h);
00064 virtual ~SharedMemoryLookupTableHeader();
00065
00066 virtual fawkes::SharedMemoryHeader * clone() const;
00067 virtual bool matches(void *memptr);
00068 virtual size_t size();
00069 virtual bool create();
00070 virtual void initialize(void *memptr);
00071 virtual void set(void *memptr);
00072 virtual void reset();
00073 virtual size_t data_size();
00074 virtual bool operator==(const fawkes::SharedMemoryHeader & s) const;
00075
00076 virtual void print_info();
00077
00078 const char * lut_id() const;
00079 void set_lut_id(const char *lut_id);
00080 unsigned int width() const;
00081 unsigned int height() const;
00082 unsigned int depth() const;
00083 unsigned int bytes_per_cell() const;
00084
00085 SharedMemoryLookupTable_header_t * raw_header();
00086
00087 private:
00088 SharedMemoryLookupTable_header_t *__header;
00089
00090 char *__lut_id;
00091 unsigned int __width;
00092 unsigned int __height;
00093 unsigned int __depth;
00094 unsigned int __bytes_per_cell;
00095 };
00096
00097 class SharedMemoryLookupTableLister : public fawkes::SharedMemoryLister
00098 {
00099 public:
00100 SharedMemoryLookupTableLister();
00101 virtual ~SharedMemoryLookupTableLister();
00102
00103 virtual void print_header();
00104 virtual void print_footer();
00105 virtual void print_no_segments();
00106 virtual void print_no_orphaned_segments();
00107 virtual void print_info(const fawkes::SharedMemoryHeader *header,
00108 int shm_id, int semaphore, unsigned int mem_size,
00109 const void *memptr);
00110 };
00111
00112
00113 class SharedMemoryLookupTable : public fawkes::SharedMemory
00114 {
00115
00116 public:
00117
00118 SharedMemoryLookupTable( const char *lut_id,
00119 unsigned int width, unsigned int height,
00120 unsigned int depth = 1,
00121 unsigned int bytes_per_cell = 1
00122 );
00123 SharedMemoryLookupTable(const char *lut_id , bool is_read_only = true);
00124 ~SharedMemoryLookupTable();
00125
00126 const char * lut_id() const;
00127 bool set_lut_id(const char *lut_id);
00128 unsigned char * buffer() const;
00129 unsigned int width() const;
00130 unsigned int height() const;
00131 unsigned int depth() const;
00132 unsigned int bytes_per_cell() const;
00133
00134 static void list();
00135 static void cleanup(bool use_lister = true);
00136 static bool exists(const char *lut_id);
00137 static void wipe(const char *lut_id);
00138
00139 private:
00140 void constructor(const char *lut_id,
00141 unsigned int width, unsigned int height, unsigned int depth,
00142 unsigned int bytes_per_cell,
00143 bool is_read_only);
00144
00145 SharedMemoryLookupTableHeader *__priv_header;
00146 SharedMemoryLookupTable_header_t *__raw_header;
00147
00148 char *__lut_id;
00149 unsigned int __width;
00150 unsigned int __height;
00151 unsigned int __depth;
00152 unsigned int __bytes_per_cell;
00153
00154 };
00155
00156 }
00157
00158 #endif