feat(datastore): add CDataStoreCache

This commit is contained in:
fallenoak 2022-12-30 14:43:23 -06:00 committed by GitHub
parent a43c4b9112
commit 125ffec928
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View file

@ -2,5 +2,6 @@
#define COMMON_DATA_STORE_HPP #define COMMON_DATA_STORE_HPP
#include "common/datastore/CDataStore.hpp" #include "common/datastore/CDataStore.hpp"
#include "common/datastore/CDataStoreCache.hpp"
#endif #endif

View 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