Tidied structure of all classes within the entire code base

Also some other small bits of tidying
This commit is contained in:
Nav
2021-10-06 21:12:31 +01:00
parent 1aef5bba79
commit 6edfb7376a
179 changed files with 3446 additions and 3493 deletions

View File

@@ -19,10 +19,6 @@ namespace Bloom
template<typename TypeA, typename TypeB>
class BiMap
{
private:
std::unordered_map<TypeA, TypeB> map = {};
std::unordered_map<TypeB, typename std::unordered_map<TypeA, TypeB>::iterator> flippedMap = {};
public:
BiMap(std::initializer_list<std::pair<TypeA, TypeB>> elements) {
for (auto it = elements.begin(); it != elements.end(); ++it) {
@@ -75,5 +71,9 @@ namespace Bloom
insertResultPair.first
));
}
private:
std::unordered_map<TypeA, TypeB> map = {};
std::unordered_map<TypeB, typename std::unordered_map<TypeA, TypeB>::iterator> flippedMap = {};
};
}

View File

@@ -11,9 +11,6 @@ namespace Bloom
*/
class DateTime
{
private:
static inline std::mutex currentDateTimeMutex;
public:
/**
* The QDateTime::currentDateTime() static function is not thread-safe. This may be caused by the
@@ -38,5 +35,8 @@ namespace Bloom
auto lock = std::unique_lock(DateTime::currentDateTimeMutex);
return dateTime.timeZoneAbbreviation();
}
private:
static inline std::mutex currentDateTimeMutex;
};
}

View File

@@ -25,26 +25,6 @@ namespace Bloom
*/
class EventNotifier
{
private:
int fileDescriptor = -1;
std::atomic<bool> initialised = false;
void init() {
this->fileDescriptor = ::eventfd(0, EFD_NONBLOCK);
if (this->fileDescriptor < -1) {
throw Exceptions::Exception("Failed to create new eventfd object - error number: "
+ std::to_string(errno));
}
this->initialised = true;
}
void close() {
::close(this->fileDescriptor);
this->initialised = false;
}
public:
EventNotifier() {
this->init();
@@ -78,5 +58,25 @@ namespace Bloom
"error number: " + std::to_string(errno));
}
}
private:
int fileDescriptor = -1;
std::atomic<bool> initialised = false;
void init() {
this->fileDescriptor = ::eventfd(0, EFD_NONBLOCK);
if (this->fileDescriptor < -1) {
throw Exceptions::Exception("Failed to create new eventfd object - error number: "
+ std::to_string(errno));
}
this->initialised = true;
}
void close() {
::close(this->fileDescriptor);
this->initialised = false;
}
};
}

View File

@@ -17,10 +17,6 @@ namespace Bloom
template<typename Type>
class SyncSafe
{
private:
std::mutex mutex;
Type value;
public:
SyncSafe() = default;
@@ -51,5 +47,9 @@ namespace Bloom
std::unique_lock<std::mutex> acquireLock() {
return std::unique_lock(this->mutex);
};
private:
std::mutex mutex;
Type value;
};
}

View File

@@ -18,8 +18,10 @@ namespace Bloom
class Thread
{
private:
SyncSafe<ThreadState> state = SyncSafe<ThreadState>(ThreadState::UNINITIALISED);
public:
virtual ThreadState getThreadState() {
return this->state.getValue();
};
protected:
virtual void setThreadState(ThreadState state) {
@@ -42,9 +44,7 @@ namespace Bloom
pthread_setname_np(pthread_self(), name.c_str());
}
public:
virtual ThreadState getThreadState() {
return this->state.getValue();
};
private:
SyncSafe<ThreadState> state = SyncSafe<ThreadState>(ThreadState::UNINITIALISED);
};
}