47 #ifndef _MIRA_BUFFER_H_ 48 #define _MIRA_BUFFER_H_ 57 #include <boost/type_traits.hpp> 83 template <
typename T,
typename Alloc = std::allocator<T> >
89 static_assert(boost::has_trivial_destructor<T>::value,
90 "Can be used with types that have trivial destructor only");
94 static_assert(boost::has_trivial_default_constructor<T>::value,
95 "Can be used with types that have a trivial default constructor only");
96 static_assert(boost::has_trivial_copy_constructor<T>::value,
97 "Can be used with types that have a trivial copy constructor only");
336 setBuffer(newBuffer, newSize);
400 if (elements >=
mSize)
421 if (elements >=
mSize)
527 throw std::out_of_range(
"Buffer::range_check");
564 template<
typename Reflector,
typename T,
typename Allocator>
568 uint32 count = c.
size();
575 serialization::PlainArray<T> array(c.
data(), c.
size());
580 template<
typename Reflector,
typename T,
typename Allocator>
593 serialization::PlainArray<T> array(c.
data(), c.
size());
598 template<
typename Reflector,
typename T,
typename Allocator>
604 template<
typename T,
typename Allocator>
607 template<
typename T,
typename Allocator>
Type trait that indicates whether pointer tracking can be enabled for this type.
Definition: IsObjectTrackable.h:68
void reflectWrite(Reflector &r, Buffer< T, Allocator > &c)
Specialization of the non-intrusive reflect for Buffer.
Definition: Buffer.h:581
Alloc::const_pointer const_pointer
Definition: Buffer.h:119
reference back()
Returns a reference to the last element in the vector container.
Definition: Buffer.h:498
Typedefs for OS independent basic data types.
bool operator!=(const Buffer &other) const
Checks for inequality with other buffer.
Definition: Buffer.h:254
bool operator==(const Buffer &other) const
Checks for equality with other buffer.
Definition: Buffer.h:246
Macros for use with reflectors.
void pop_back()
Removes the last element in the vector, effectively reducing the vector size by one.
Definition: Buffer.h:390
std::size_t size_type
Definition: Buffer.h:124
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Buffer(Buffer &&other) noexcept
Move constructor.
Definition: Buffer.h:223
bool mBufferCreated
Was the buffer created (is it owned) by us.
Definition: Buffer.h:554
Buffer & operator=(const Buffer &other)
Assignment.
Definition: Buffer.h:208
Buffer(T *carray, size_type size)
Use already allocated memory in carray with size size.
Definition: Buffer.h:157
Alloc mAllocator
The allocator used to allocate new memory.
Definition: Buffer.h:556
const T * const_iterator
Definition: Buffer.h:123
size_type mReserved
The real size of the buffer.
Definition: Buffer.h:553
ptrdiff_t difference_type
Definition: Buffer.h:125
T value_type
Definition: Buffer.h:90
Alloc::reference reference
Definition: Buffer.h:120
Provides type trait that indicates whether a type should be serialized "transparently".
allocator_type get_allocator() const
Returns the allocator.
Definition: Buffer.h:314
const_reference front() const
Returns a reference to the first element in the vector container.
Definition: Buffer.h:490
void reserve(size_type reserve)
Allocates new memory if reserved size < new reserved size.
Definition: Buffer.h:323
T * mBuffer
Pointer to the data buffer.
Definition: Buffer.h:551
size_type mSize
The used elements of the buffer.
Definition: Buffer.h:552
size_type sizeInBytes() const
Returns the used size in bytes.
Definition: Buffer.h:298
Buffer(const Buffer &other)
Copy constructor.
Definition: Buffer.h:202
void push_back(const T &x)
Adds a new element at the end of the vector, after its current last element.
Definition: Buffer.h:362
Buffer & operator=(Buffer &&other) noexcept
Move assignment.
Definition: Buffer.h:229
Wrapper class for reflecting arrays.
void pop_front(size_type elements)
Removes the first elements in the vector by copying all remaining data to the front invalidating all ...
Definition: Buffer.h:420
Alloc::pointer pointer
Definition: Buffer.h:118
void swap(Buffer &other)
Swaps the content of this buffer with the other buffer.
Definition: Buffer.h:235
Contains the base interface of all Reflectors, Serializers, etc.
const_pointer data() const
Returns a const pointer to the underlying data.
Definition: Buffer.h:519
T * iterator
Definition: Buffer.h:122
#define MIRA_REFLECT_CALL(ReflectorType, reflector, context, COMMAND)
Whenever a reflection function calls another function that is independently maintained, the call should be marked to the reflector.
Definition: ReflectorMacros.h:109
reference front()
Returns a reference to the first element in the vector container.
Definition: Buffer.h:482
size_type size() const
Returns the used size of the buffer set by resize()
Definition: Buffer.h:293
const_reference at(size_type n) const
The difference between this member function and member operator function operator[] is that vector::a...
Definition: Buffer.h:474
void push_back(const Buffer< T > &data)
Adds new elements to the end of the vector, after its current last element.
Definition: Buffer.h:379
bool empty() const
Checks if the buffer is empty (used size == 0).
Definition: Buffer.h:303
pointer data()
Returns a pointer to the underlying data.
Definition: Buffer.h:514
Buffer()
Default constructor constructing an empty buffer.
Definition: Buffer.h:140
reference at(size_type n)
The difference between this member function and member operator function operator[] is that vector::a...
Definition: Buffer.h:464
const_reference back() const
Returns a reference to the last element in the vector container.
Definition: Buffer.h:506
void reflect(Reflector &r, LogRecord &record)
Non-intrusive reflector for LogRecord.
Definition: LoggingCore.h:137
size_type max_size() const
Returns the maximum size of the buffer.
Definition: Buffer.h:288
Buffer(size_type size)
Definition: Buffer.h:147
Generic buffer class that can be used as a replacement for std::vector whenever copying and reallocat...
Definition: Buffer.h:84
~Buffer()
Destructor.
Definition: Buffer.h:195
std::vector< T > * mTakenVector
Used to take over the data from a vector without copying.
Definition: Buffer.h:558
void push_back(T *data, size_type size)
Adds new elements to the end of the vector, after its current last element.
Definition: Buffer.h:371
Can be specialized for a concrete derived RecursiveMemberReflector to reflect the size of collections...
Definition: ReflectCollection.h:69
void pop_back(size_type elements)
Removes the last elements in the vector, effectively reducing the vector size by elements.
Definition: Buffer.h:399
iterator begin()
Returns an iterator referring to the first element in the vector container.
Definition: Buffer.h:264
void reflectRead(Reflector &r, Buffer< T, Allocator > &c)
Specialization of the non-intrusive reflect for Buffer.
Definition: Buffer.h:565
void resize(size_type size)
Resizes the buffer.
Definition: Buffer.h:350
void clear()
All the elements of the vector are dropped.
Definition: Buffer.h:437
void pop_front()
Removes the first element in the vector by copying all remaining data to the front invalidating all i...
Definition: Buffer.h:412
iterator end()
Returns an iterator referring to the past-the-end element in the vector container.
Definition: Buffer.h:276
void copy(const Buffer &other)
Copies a buffer into this.
Definition: Buffer.h:214
Type trait that indicates whether a type is a collection.
Definition: IsCollection.h:63
const_iterator end() const
Returns an iterator referring to the past-the-end element in the vector container.
Definition: Buffer.h:282
Alloc::const_reference const_reference
Definition: Buffer.h:121
Alloc allocator_type
Definition: Buffer.h:126
Buffer(std::vector< T > &&other)
Constructs a buffer that TAKES OVER all data from the specified vector.
Definition: Buffer.h:183
const_iterator begin() const
Returns an iterator referring to the first element in the vector container.
Definition: Buffer.h:270
size_type capacity() const
Returns the reserved size/capacity of the buffer (Its real size) set by reserve() ...
Definition: Buffer.h:309
reference operator[](size_type n)
Returns a reference to the element at position n in the vector container.
Definition: Buffer.h:446