Iris Whole Slide Imaging
Loading...
Searching...
No Matches
IrisBuffer.hpp
Go to the documentation of this file.
1
13#ifndef IrisBuffer_hpp
14#define IrisBuffer_hpp
15
16//TODO: THIS IS CURRENTLY NOT THREAD SAFE! THERE CAN BE DATA RACES WITH THE CURRENT FORM. MUST UPDATE TO USE ATOMIC AND MUTEXES FOR THREAD SAFETY!
17
18namespace Iris {
36 size_t _capacity = 0;
37 size_t _size = 0;
38 void* const _data = nullptr;
39
40public:
42 explicit __INTERNAL__Buffer (BufferReferenceStrength, size_t capacity) noexcept;
43 explicit __INTERNAL__Buffer (BufferReferenceStrength, const void* const data, size_t bytes) noexcept;
44 __INTERNAL__Buffer (const __INTERNAL__Buffer&) = delete;
45 __INTERNAL__Buffer& operator = (const __INTERNAL__Buffer&) = delete;
52 operator void* const () const;
59 operator bool () const;
89 void* data () const;
100 void* end () const;
118 Result prepare (size_t amount_of_bytes_to_prepare);
136 void* append (size_t append_by_bytes);
152 Result append (void* data, size_t size);
161 size_t size () const;
177 Result set_size (size_t buffer_valid_size_bytes);
185 size_t capacity () const;
193 size_t available_bytes () const;
209 Result resize (size_t expected_size_bytes);
220};
221} // END IRIS NAMESPACE
222
223#endif /* IrisBuffer_hpp */
Result
Result flags returned by Iris as part of API calls.
Definition IrisTypes.hpp:25
BufferReferenceStrength
Iris Buffer ownership strength to underlying data. A weak reference only wraps data blocks by referen...
Definition IrisTypes.hpp:43
@ REFERENCE_STRONG
Full ownership. Will free data on buffer destruction. Can resize underlying pointer.
Definition IrisTypes.hpp:47
Private implementation of the reference counted data object used to wrap datablocks.
Definition IrisBuffer.hpp:34
void * end() const
Returns a pointer to the next unwritten location in the buffer.
void * data() const
Returns pointer to the beginning of the underlying data block.
void * append(size_t append_by_bytes)
Expands the size of the buffer without writing data into the expanded space.
Result shrink_to_fit()
Shrinks the underlying data block to fit the used space.
Result set_size(size_t buffer_valid_size_bytes)
Set the size object.
Result prepare(size_t amount_of_bytes_to_prepare)
Extends the capacity of the buffer without affecting the size.
Result append(void *data, size_t size)
Appends the end of the buffer by copying data into the buffer.
size_t available_bytes() const
Returns the remaining bytes within the buffer that are unused.
Result resize(size_t expected_size_bytes)
Resize the underlying datablock.
Result change_strength(BufferReferenceStrength strength_to_assign)
Change the strength of the underlying reference.
BufferReferenceStrength get_strength() const
Get the reference strength to the underlying data wrapped by the buffer.
size_t capacity() const
Returns the total capacity of the buffer (used and unused)
size_t size() const
Returns the current size of the buffer.