PacketBuffer.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 
24 // -- END LICENSE BLOCK ------------------------------------------------
25 
26 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
34 
36 
37 namespace sick {
38 namespace datastructure {
39 
40 
42 
43 PacketBuffer::PacketBuffer(const std::vector<uint8_t>& buffer)
44 {
45  setBuffer(buffer);
46 }
47 
48 PacketBuffer::PacketBuffer(const PacketBuffer::ArrayBuffer& buffer, const size_t& length)
49 {
50  setBuffer(buffer, length);
51 }
52 
53 std::shared_ptr<std::vector<uint8_t> const> PacketBuffer::getBuffer() const
54 {
55  // Okay to share since it's a shared_ptr<vector const>
56  return m_buffer;
57 }
58 
59 void PacketBuffer::setBuffer(const std::vector<uint8_t>& buffer)
60 {
61  m_buffer = std::make_shared<std::vector<uint8_t> const>(buffer);
62 }
63 
64 void PacketBuffer::setBuffer(const PacketBuffer::ArrayBuffer& buffer, const size_t& length)
65 {
66  m_buffer = std::make_shared<std::vector<uint8_t> const>(buffer.data(), buffer.data() + length);
67 }
68 
70 {
71  return m_buffer->size();
72 }
73 
74 } // namespace datastructure
75 } // namespace sick
boost::array< uint8_t, MAXSIZE > ArrayBuffer
Typedef for an arraybuffer which can be read from the sensor.
Definition: PacketBuffer.h:67
std::shared_ptr< std::vector< uint8_t > const > getBuffer() const
Getter to return a copy of the data saved in the PacketBuffer.
size_t getLength() const
Returns length of the current PacketBuffer.
std::shared_ptr< std::vector< uint8_t > const > m_buffer
Definition: PacketBuffer.h:123
void setBuffer(const std::vector< uint8_t > &buffer)
Setter for the PacketBuffer.
PacketBuffer()
Constructor of PacketBuffer.


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Apr 2 2021 02:45:41