rgbd
client_shm.h
Go to the documentation of this file.
1 #ifndef RGBD_CLIENT_SHM_H_
2 #define RGBD_CLIENT_SHM_H_
3 
4 #include <boost/interprocess/shared_memory_object.hpp>
5 #include <boost/interprocess/mapped_region.hpp>
6 
7 #include "rgbd/image_header.h"
8 #include "rgbd/types.h"
9 
10 namespace rgbd
11 {
12 
16 class ClientSHM
17 {
18 
19 public:
20 
26  ClientSHM();
27 
33  ~ClientSHM();
34 
41  bool initialize(const std::string& server_name, float timeout = 5.0);
42 
47  bool deinitialize();
48 
53  bool initialized() { return (buffer_header_ != nullptr); }
54 
61  bool nextImage(Image& image);
62 
69 
70 private:
71 
72  boost::interprocess::shared_memory_object shm_;
73 
74  boost::interprocess::mapped_region mem_buffer_header_;
75  boost::interprocess::mapped_region mem_image_;
76 
78  unsigned char* image_data_;
79 
80  uint64_t rgb_data_size_;
81  uint64_t depth_data_size_;
82 
86  uint64_t sequence_nr_;
87 
88 };
89 
90 } // end namespace rgbd
91 
92 #endif // RGBD_CLIENT_SHM_H_
rgbd::ClientSHM::initialized
bool initialized()
Check if the client is initialized. nextImage shouldn't be called if client is not initialized.
Definition: client_shm.h:53
rgbd::ClientSHM::buffer_header_
BufferHeader * buffer_header_
Definition: client_shm.h:77
std::string
std::shared_ptr
types.h
rgbd::ClientSHM::rgb_data_size_
uint64_t rgb_data_size_
Definition: client_shm.h:80
rgbd::ClientSHM::depth_data_size_
uint64_t depth_data_size_
Definition: client_shm.h:81
rgbd::ClientSHM::mem_buffer_header_
boost::interprocess::mapped_region mem_buffer_header_
Definition: client_shm.h:74
rgbd::ClientSHM::mem_image_
boost::interprocess::mapped_region mem_image_
Definition: client_shm.h:75
rgbd::BufferHeader
Definition: image_header.h:12
rgbd::Image
Definition: image.h:43
rgbd::ClientSHM::initialize
bool initialize(const std::string &server_name, float timeout=5.0)
Initialize shared memory client.
Definition: client_shm.cpp:33
rgbd::ClientSHM::sequence_nr_
uint64_t sequence_nr_
sequence_nr Contains the sequence nummer of the last NextImage call
Definition: client_shm.h:86
image_header.h
rgbd::ClientSHM::deinitialize
bool deinitialize()
Clears all the shared memory classes to nullptrs or empty classes. initialized will now return false.
Definition: client_shm.cpp:77
rgbd
Definition: client.h:24
rgbd::ClientSHM::ClientSHM
ClientSHM()
Constructor.
Definition: client_shm.cpp:21
rgbd::ClientSHM::nextImage
ImagePtr nextImage()
Get a new Image. If no new image has been received, the sequence nummer is still the same as the prev...
Definition: client_shm.cpp:145
rgbd::ClientSHM::~ClientSHM
~ClientSHM()
Destructor.
Definition: client_shm.cpp:27
rgbd::ClientSHM::image_data_
unsigned char * image_data_
Definition: client_shm.h:78
rgbd::ClientSHM::shm_
boost::interprocess::shared_memory_object shm_
Definition: client_shm.h:72
rgbd::ClientSHM
Client which uses shared memory, requires a server on the same machine.
Definition: client_shm.h:16