Remote Call Framework 3.3
AsioBuffers.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2022, Delta V Software. All rights reserved.
6 // https://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF under GPL terms.
12 //
13 // Version: 3.3
14 // Contact: support <at> deltavsoft.com
15 //
16 //******************************************************************************
17 
18 #ifndef INCLUDE_RCF_ASIOBUFFERS_HPP
19 #define INCLUDE_RCF_ASIOBUFFERS_HPP
20 
21 #include <RCF/Asio.hpp>
22 
23 namespace RCF {
24 
25  // This adapter around a std::vector prevents asio from making a deep copy
26  // of the buffer list, when sending multiple buffers. The deep copy would
27  // involve making memory allocations.
28  class AsioBuffers
29  {
30  public:
31 
32  typedef std::vector<AsioConstBuffer> BufferVec;
33  typedef std::shared_ptr<BufferVec> BufferVecPtr;
34 
35  typedef AsioConstBuffer value_type;
36  typedef BufferVec::const_iterator const_iterator;
37 
38  AsioBuffers()
39  {
40  mVecPtr.reset( new std::vector<AsioConstBuffer>() );
41  }
42 
43  const_iterator begin() const
44  {
45  return mVecPtr->begin();
46  }
47 
48  const_iterator end() const
49  {
50  return mVecPtr->end();
51  }
52 
53  BufferVecPtr mVecPtr;
54  };
55 
56 } // namespace RCF
57 
58 #endif // ! INCLUDE_RCF_ASIOBUFFERS_HPP
Definition: AmiIoHandler.hpp:23