24 #include <fvutils/ipc/shm_exceptions.h>
25 #include <fvutils/ipc/shm_lut.h>
26 #include <utils/system/console_colors.h>
36 namespace firevision {
55 SharedMemoryLookupTable::SharedMemoryLookupTable(
const char * lut_id,
59 unsigned int bytes_per_cell)
60 :
SharedMemory(FIREVISION_SHM_LUT_MAGIC_TOKEN, false, true, true)
75 :
SharedMemory(FIREVISION_SHM_LUT_MAGIC_TOKEN, is_read_only, false, false)
81 SharedMemoryLookupTable::constructor(
const char * lut_id,
85 unsigned int bytes_per_cell,
102 throw Exception(
"Could not create shared memory segment");
143 return (
unsigned char *)
_memptr;
152 return raw_header_->
width;
161 return raw_header_->
height;
170 return raw_header_->
depth;
189 SharedMemory::list(FIREVISION_SHM_LUT_MAGIC_TOKEN, h, lister);
209 SharedMemory::erase_orphaned(FIREVISION_SHM_LUT_MAGIC_TOKEN, h, lister);
223 bool ex = SharedMemory::exists(FIREVISION_SHM_LUT_MAGIC_TOKEN, h);
235 SharedMemory::erase(FIREVISION_SHM_LUT_MAGIC_TOKEN, h, NULL);
263 unsigned int bytes_per_cell)
284 unsigned int bytes_per_cell)
300 if (h->lut_id_ != NULL) {
301 lut_id_ = strdup(h->lut_id_);
306 height_ = h->height_;
308 bytes_per_cell_ = h->bytes_per_cell_;
317 if (lut_id_ != NULL) {
338 if (header_ == NULL) {
339 return (
size_t)width_ * height_ * depth_ * bytes_per_cell_;
350 if (lut_id_ == NULL) {
353 }
else if (strncmp(h->
lut_id, lut_id_, LUT_ID_MAX_LENGTH) == 0) {
354 if ((width_ == 0) || (height_ == 0) || (depth_ == 0) || (bytes_per_cell_ == 0)
370 if (header_ == NULL) {
371 cout <<
"No image set" << endl;
374 cout <<
"SharedMemory Lookup Table Info: " << endl
375 <<
" LUT ID: " << header_->
lut_id << endl
376 <<
" dimensions: " << header_->
width <<
"x" << header_->
height <<
"x"
377 << header_->
depth << endl
388 return ((width_ > 0) && (height_ > 0) && (depth_ > 0) && (bytes_per_cell_ > 0));
397 strncpy(header_->
lut_id, lut_id_, LUT_ID_MAX_LENGTH - 1);
398 header_->
width = width_;
399 header_->
height = height_;
400 header_->
depth = depth_;
432 return ((strncmp(lut_id_, h->lut_id_, LUT_ID_MAX_LENGTH) == 0) && (width_ == h->width_)
433 && (height_ == h->height_) && (depth_ == h->depth_)
434 && (bytes_per_cell_ == h->bytes_per_cell_));
446 return header_->
width;
468 return header_->
depth;
531 << cgreen <<
"FireVision Shared Memory Segments - Lookup Tables" << cnormal << endl
532 <<
"========================================================================================"
535 printf(
"%-23s %-10s %-10s %-10s %-9s %-9s %-9s\n",
544 <<
"----------------------------------------------------------------------------------------"
556 cout <<
"No FireVision shared memory segments containing lookup tables found" << endl;
562 cout <<
"No orphaned FireVision shared memory segments containing lookup tables found" << endl;
569 unsigned int mem_size,
574 printf(
"%-23s %-10d %-10d %-10u %-9u %-9u %s%s\n",
581 (SharedMemory::is_swapable(shm_id) ?
"S" :
""),
582 (SharedMemory::is_destroyed(shm_id) ?
"D" :
""));