refactor: simplifying project until runs on embedded system

This commit is contained in:
2025-03-26 21:28:50 +01:00
parent c13310d540
commit 171a48eb71
28 changed files with 1260 additions and 3208 deletions
+1 -17
View File
@@ -13,15 +13,13 @@
*/
#include "SPITObject.h"
#include "_SPITMACROS.h"
#include "SPITSocket.h"
unordered_map<string, SPITObject*> SPITObject::s_SPITObjects;
unordered_map<string, SPITObject*> SPITObject::s_SPITObjectsRemote;
fos::Mutex SPITObject::s_MutexSPITObject;
SPITObject* SPITObject::getSPITObject(string p_ID) {
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
auto i = s_SPITObjects.find(p_ID);
if (i == s_SPITObjects.end()) {
return NULL;
@@ -37,7 +35,6 @@
*/
const SPITObject& SPITObject::getSPITObjectRef(string p_ID) {
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
auto i = s_SPITObjects.find(p_ID);
if (i == s_SPITObjects.end()) {
throw "SPITObject no SPITObject with given id";
@@ -48,7 +45,6 @@
SPITObject* SPITObject::getSPITObjectRemote(string p_ID) {
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
auto i = s_SPITObjectsRemote.find(p_ID);
if (i == s_SPITObjectsRemote.end()) {
return NULL;
@@ -64,7 +60,6 @@
*/
const SPITObject& SPITObject::getSPITObjectRemoteRef(string p_ID) {
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
auto i = s_SPITObjectsRemote.find(p_ID);
if (i == s_SPITObjectsRemote.end()) {
throw "Remote SPITObject no SPITObject with given id";
@@ -76,7 +71,6 @@
bool SPITObject::addSPITObject(SPITObject* p_ptrSPITObject) {
if (p_ptrSPITObject == NULL) return false;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
s_SPITObjects[p_ptrSPITObject->getID()] = p_ptrSPITObject;
return true;
}
@@ -84,7 +78,6 @@
bool SPITObject::addSPITObjectRemote(SPITObject* p_ptrSPITObject) {
if (p_ptrSPITObject == NULL) return false;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
s_SPITObjectsRemote[p_ptrSPITObject->getID()] = p_ptrSPITObject;
return true;
}
@@ -92,7 +85,6 @@
bool SPITObject::removeSPITObject(SPITObject* p_ptrSPITObject) {
if (p_ptrSPITObject == NULL) return false;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
auto i = s_SPITObjects.find(p_ptrSPITObject->getID());
if (i == s_SPITObjects.end()) {
return false;
@@ -104,7 +96,6 @@
bool SPITObject::removeSPITObjectRemote(SPITObject* p_ptrSPITObject) {
if (p_ptrSPITObject == NULL) return false;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
auto i = s_SPITObjectsRemote.find(p_ptrSPITObject->getID());
if (i == s_SPITObjectsRemote.end()) {
return false;
@@ -123,7 +114,6 @@
SPITObject* SPITObject::getSPITObject(int p_Index) {
SPITObject* ptrSPITObject = NULL;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
if (p_Index >= 0 && p_Index < s_SPITObjects.size()) {
unordered_map<string, SPITObject*>::iterator i = next(s_SPITObjects.begin(), p_Index);
ptrSPITObject = i->second;
@@ -143,7 +133,6 @@
const SPITObject& SPITObject::getSPITObjectRef(int p_Index) {
SPITObject* ptrSPITObject = NULL;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
if (p_Index >= 0 && p_Index < s_SPITObjects.size()) {
unordered_map<string, SPITObject*>::iterator i = next(s_SPITObjects.begin(), p_Index);
ptrSPITObject = i->second;
@@ -157,7 +146,6 @@
SPITObject* SPITObject::getSPITObjectRemote(int p_Index) {
SPITObject* ptrSPITObject = NULL;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
if (p_Index >= 0 && p_Index < s_SPITObjectsRemote.size()) {
unordered_map<string, SPITObject*>::iterator i = next(s_SPITObjectsRemote.begin(), p_Index);
ptrSPITObject = i->second;
@@ -177,7 +165,6 @@
const SPITObject& SPITObject::getSPITObjectRemoteRef(int p_Index) {
SPITObject* ptrSPITObject = NULL;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
if (p_Index >= 0 && p_Index < s_SPITObjectsRemote.size()) {
unordered_map<string, SPITObject*>::iterator i = next(s_SPITObjectsRemote.begin(), p_Index);
ptrSPITObject = i->second;
@@ -192,7 +179,6 @@
void SPITObject::clearSPITObjects() {
SPITObject* ptrSPITObject;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) {
ptrSPITObject = i->second;
i = s_SPITObjects.erase(i);
@@ -206,7 +192,6 @@
void SPITObject::clearSPITObjectsRemote() {
SPITObject* ptrSPITObject;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
for (auto i = s_SPITObjectsRemote.begin(); i != s_SPITObjectsRemote.end(); i++) {
ptrSPITObject = i->second;
i = s_SPITObjectsRemote.erase(i);
@@ -227,7 +212,6 @@
void SPITObject::setConfirmedFalse() {
SPITObject* ptrSPITObject;
{
fos::MutexGuard o_LockObject(s_MutexSPITObject);
for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) {
ptrSPITObject = i->second;
ptrSPITObject->setConfirmed(false);