rohdeschwarz  0.2.0
TCPIP socket library for Rohde & Schwarz instrument control
bus.cpp
Go to the documentation of this file.
1 
7 // rohdeschwarz
9 using namespace rohdeschwarz::busses;
10 
11 
12 // std lib
13 #include <utility>
14 
15 
16 // constants
17 const std::size_t _50_KB_ = 50 * 1024;
18 
19 
20 // types
21 using char_p = char*;
22 using uchar_p = unsigned char*;
23 
24 
25 // implementation
26 
27 
29  _buffer(_50_KB_)
30 {
31  // pass
32 }
33 
34 
36 {
37  // pass
38 }
39 
40 
41 std::size_t Bus::bufferSize_B() const
42 {
43  return _buffer.size();
44 }
45 
46 
47 void Bus::setBufferSize(std::size_t bytes)
48 {
49  _buffer.resize(bytes);
50 }
51 
52 
53 std::vector<unsigned char>* Bus::buffer()
54 {
55  return &_buffer;
56 }
57 
58 
59 const std::vector<unsigned char>* Bus::buffer() const
60 {
61  return &_buffer;
62 }
63 
64 
65 std::vector<unsigned char> Bus::takeData()
66 {
67  auto buffer = std::move(_buffer);
68  setBufferSize(buffer.size());
69  return buffer;
70 }
71 
72 
73 bool Bus::readData(std::size_t* readSize)
74 {
75  return readData(_buffer.data(), _buffer.size(), readSize);
76 }
const std::size_t _50_KB_
Definition: bus.cpp:17
char * char_p
Definition: bus.cpp:21
unsigned char * uchar_p
Definition: bus.cpp:22
rohdeschwarz::busses::Bus class definition
std::size_t bufferSize_B() const
Definition: bus.cpp:41
void setBufferSize(std::size_t bytes)
Definition: bus.cpp:47
virtual ~Bus()
Destructor.
Definition: bus.cpp:35
Bus()
Constructor.
Definition: bus.cpp:28
std::vector< unsigned char > * buffer()
Definition: bus.cpp:53
std::vector< unsigned char > takeData()
Definition: bus.cpp:65
virtual bool readData(unsigned char *buffer, std::size_t bufferSize, std::size_t *readSize=nullptr)=0