Pothos  0.2.1-g9f04573d
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
ManagedBuffer.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
14 #include <memory> //shared_ptr
15 
16 namespace Pothos {
17 
19 class BufferManager;
20 
28 {
29 public:
30 
35  ManagedBuffer(void);
36 
41  pothos_explicit operator bool(void) const;
42 
47  void reset(void);
48 
55  void reset(std::shared_ptr<BufferManager> manager, const SharedBuffer &buff, const size_t slabIndex = 0);
56 
62  const SharedBuffer &getBuffer(void) const;
63 
70  size_t getSlabIndex(void) const;
71 
73  ~ManagedBuffer(void);
74 
76  ManagedBuffer(const ManagedBuffer &obj);
77 
80 
82  ManagedBuffer &operator=(const ManagedBuffer &obj);
83 
85  ManagedBuffer &operator=(ManagedBuffer &&obj);
86 
88  std::shared_ptr<BufferManager> getBufferManager(void) const;
89 
91  bool operator<(const ManagedBuffer &) const;
92 
97  bool unique(void) const;
98 
102  size_t useCount(void) const;
103 
104 private:
105  struct Impl; Impl *_impl;
106  POTHOS_API friend bool operator==(const ManagedBuffer &lhs, const ManagedBuffer &rhs);
107 };
108 
113 inline bool operator==(const ManagedBuffer &lhs, const ManagedBuffer &rhs);
114 
115 } //namespace Pothos
116 
117 inline Pothos::ManagedBuffer::operator bool(void) const
118 {
119  return _impl != nullptr;
120 }
121 
122 inline bool Pothos::ManagedBuffer::operator<(const ManagedBuffer &rhs) const
123 {
124  return _impl < rhs._impl;
125 }
126 
127 inline bool Pothos::ManagedBuffer::unique(void) const
128 {
129  return this->useCount() == 1;
130 }
131 
132 inline bool Pothos::operator==(const ManagedBuffer &lhs, const ManagedBuffer &rhs)
133 {
134  return lhs._impl == rhs._impl;
135 }
#define pothos_explicit
Definition: Config.hpp:85
#define POTHOS_API
Definition: Config.hpp:41
POTHOS_API bool operator==(const Callable &lhs, const Callable &rhs)
bool unique(void) const
Definition: ManagedBuffer.hpp:127
Definition: ManagedBuffer.hpp:27
Definition: SharedBuffer.hpp:21
bool operator<(const ManagedBuffer &) const
sortable operator for ManagedBuffer
Definition: ManagedBuffer.hpp:122