mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[ion/storage] Private constructor and cleaner sharedStorage()
This commit is contained in:
committed by
EmilieNumworks
parent
bbb8308a6d
commit
efe5b4d6f8
@@ -86,8 +86,6 @@ public:
|
||||
uint32_t m_fullNameCRC32;
|
||||
};
|
||||
|
||||
Storage();
|
||||
|
||||
#if ION_STORAGE_LOG
|
||||
void log();
|
||||
#endif
|
||||
@@ -126,6 +124,8 @@ private:
|
||||
constexpr static uint32_t Magic = 0xEE0BDDBA;
|
||||
constexpr static size_t k_maxRecordSize = (1 << sizeof(record_size_t)*8);
|
||||
|
||||
Storage();
|
||||
|
||||
/* Getters/Setters on recordID */
|
||||
const char * fullNameOfRecord(const Record record);
|
||||
Record::ErrorStatus setFullNameOfRecord(const Record record, const char * fullName);
|
||||
|
||||
@@ -28,10 +28,7 @@ constexpr char Storage::seqExtension[];
|
||||
constexpr char Storage::eqExtension[];
|
||||
|
||||
Storage * Storage::sharedStorage() {
|
||||
static Storage * storage = nullptr;
|
||||
if (storage == nullptr) {
|
||||
storage = new (staticStorageArea) Storage();
|
||||
}
|
||||
static Storage * storage = new (staticStorageArea) Storage();
|
||||
return storage;
|
||||
}
|
||||
|
||||
@@ -90,20 +87,6 @@ Storage::Record::Record(const char * basename, int basenameLength, const char *
|
||||
|
||||
// STORAGE
|
||||
|
||||
Storage::Storage() :
|
||||
m_magicHeader(Magic),
|
||||
m_buffer(),
|
||||
m_magicFooter(Magic),
|
||||
m_delegate(nullptr),
|
||||
m_lastRecordRetrieved(nullptr),
|
||||
m_lastRecordRetrievedPointer(nullptr)
|
||||
{
|
||||
assert(m_magicHeader == Magic);
|
||||
assert(m_magicFooter == Magic);
|
||||
// Set the size of the first record to 0
|
||||
overrideSizeAtPosition(m_buffer, 0);
|
||||
}
|
||||
|
||||
#if ION_STORAGE_LOG
|
||||
void Storage::log() {
|
||||
for (char * p : *this) {
|
||||
@@ -305,6 +288,22 @@ void Storage::destroyRecordsWithExtension(const char * extension) {
|
||||
}
|
||||
}
|
||||
|
||||
// PRIVATE
|
||||
|
||||
Storage::Storage() :
|
||||
m_magicHeader(Magic),
|
||||
m_buffer(),
|
||||
m_magicFooter(Magic),
|
||||
m_delegate(nullptr),
|
||||
m_lastRecordRetrieved(nullptr),
|
||||
m_lastRecordRetrievedPointer(nullptr)
|
||||
{
|
||||
assert(m_magicHeader == Magic);
|
||||
assert(m_magicFooter == Magic);
|
||||
// Set the size of the first record to 0
|
||||
overrideSizeAtPosition(m_buffer, 0);
|
||||
}
|
||||
|
||||
const char * Storage::fullNameOfRecord(const Record record) {
|
||||
char * p = pointerOfRecord(record);
|
||||
if (p != nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user