rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
big_buffer.h
Go to the documentation of this file.
1// This file handles the "big buffer" - a shared buffer that can be used by multiple users depending on which function is enabled
2
3#pragma once
4
5#ifndef BIG_BUFFER_SIZE
6#define BIG_BUFFER_SIZE 8192
7#endif
8
9enum class BigBufferUser {
10 None,
14 // todo: actually start using this!
16};
17
19public:
20 BigBufferHandle() = default;
23
24 // But allow moving (passing ownership of the buffer)
27
28 // Implicit conversion operator to bool, so you can do things like if (myBuffer) { ... } as if it was a raw pointer
29 constexpr explicit operator bool() const {
30 return m_bufferPtr != nullptr;
31 }
32
33 template <class TBuffer>
34 const TBuffer* get() const {
35 return reinterpret_cast<TBuffer*>(m_bufferPtr);
36 }
37
38 template <class TBuffer>
39 TBuffer* get() {
40 return reinterpret_cast<TBuffer*>(m_bufferPtr);
41 }
42
43 size_t size() const {
44 return BIG_BUFFER_SIZE;
45 }
46
47private:
48 void* m_bufferPtr = nullptr;
50};
51
BigBufferUser
Definition big_buffer.h:9
BigBufferHandle getBigBuffer(BigBufferUser user)
size_t size() const
Definition big_buffer.h:43
BigBufferHandle & operator=(BigBufferHandle &&)
const TBuffer * get() const
Definition big_buffer.h:34
BigBufferHandle()=default
TBuffer * get()
Definition big_buffer.h:39
BigBufferUser m_user
Definition big_buffer.h:49
void * m_bufferPtr
Definition big_buffer.h:48
static BigBufferHandle buffer