Remote Call Framework 3.2
AsioBuffers.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2020, Delta V Software. All rights reserved.
6 // http://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
12 // under GPL terms.
13 //
14 // Version: 3.2
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_ASIOBUFFERS_HPP
20 #define INCLUDE_RCF_ASIOBUFFERS_HPP
21 
22 #include <RCF/Asio.hpp>
23 
24 namespace RCF {
25 
26  // This adapter around a std::vector prevents asio from making a deep copy
27  // of the buffer list, when sending multiple buffers. The deep copy would
28  // involve making memory allocations.
29  class AsioBuffers
30  {
31  public:
32 
33  typedef std::vector<AsioConstBuffer> BufferVec;
34  typedef std::shared_ptr<BufferVec> BufferVecPtr;
35 
36  typedef AsioConstBuffer value_type;
37  typedef BufferVec::const_iterator const_iterator;
38 
39  AsioBuffers()
40  {
41  mVecPtr.reset( new std::vector<AsioConstBuffer>() );
42  }
43 
44  const_iterator begin() const
45  {
46  return mVecPtr->begin();
47  }
48 
49  const_iterator end() const
50  {
51  return mVecPtr->end();
52  }
53 
54  BufferVecPtr mVecPtr;
55  };
56 
57 } // namespace RCF
58 
59 #endif // ! INCLUDE_RCF_ASIOBUFFERS_HPP
Definition: AmiIoHandler.hpp:24