mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 03:02:29 +00:00
feat(datastore): add CDataStoreCache
This commit is contained in:
parent
a43c4b9112
commit
125ffec928
2 changed files with 29 additions and 0 deletions
|
|
@ -2,5 +2,6 @@
|
|||
#define COMMON_DATA_STORE_HPP
|
||||
|
||||
#include "common/datastore/CDataStore.hpp"
|
||||
#include "common/datastore/CDataStoreCache.hpp"
|
||||
|
||||
#endif
|
||||
|
|
|
|||
28
common/datastore/CDataStoreCache.hpp
Normal file
28
common/datastore/CDataStoreCache.hpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef COMMON_DATASTORE_C_DATA_STORE_CACHE_HPP
|
||||
#define COMMON_DATASTORE_C_DATA_STORE_CACHE_HPP
|
||||
|
||||
#include "common/datastore/CDataStore.hpp"
|
||||
#include <cstdlib>
|
||||
|
||||
template <size_t size>
|
||||
class CDataStoreCache : public CDataStore {
|
||||
public:
|
||||
// Member variables
|
||||
uint8_t m_cache[size];
|
||||
|
||||
// Virtual member functions
|
||||
virtual void InternalInitialize(uint8_t*& data, uint32_t& base, uint32_t& alloc);
|
||||
|
||||
// Member functions
|
||||
CDataStoreCache() {
|
||||
this->InternalInitialize(this->m_data, this->m_base, this->m_alloc);
|
||||
}
|
||||
};
|
||||
|
||||
template <size_t size>
|
||||
void CDataStoreCache<size>::InternalInitialize(uint8_t*& data, uint32_t& base, uint32_t& alloc) {
|
||||
data = this->m_cache;
|
||||
alloc = size;
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue