refactor: concentrating repo functions into repo class
This commit is contained in:
@@ -16,47 +16,17 @@
|
||||
|
||||
#include "SPITType.h"
|
||||
#include "SPIT_Message.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include "SpitRepo.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SPITObjectListener;
|
||||
|
||||
class SPITObject {
|
||||
private:
|
||||
static unordered_map<string, unique_ptr<SPITObject>> sSpitObjects;
|
||||
static unordered_map<string, unique_ptr<SPITObject>> sSpitObjectsRemote;
|
||||
|
||||
public:
|
||||
static SPITObject *getSPITObject(const string &id);
|
||||
static const SPITObject &getSPITObjectRef(const string &id);
|
||||
static void addSPITObject(unique_ptr<SPITObject> spitObject);
|
||||
static bool removeSPITObject(const SPITObject &spitObject);
|
||||
static bool removeSPITObject(const string & spitObjectID);
|
||||
static int getSPITObjectCount() {
|
||||
return sSpitObjects.size();
|
||||
}
|
||||
static SPITObject *getSPITObject(int p_Index);
|
||||
static const SPITObject &getSPITObjectRef(int p_Index);
|
||||
static void clearSPITObjects() { sSpitObjects.clear(); }
|
||||
static void clearUnconfirmedSPITObjects();
|
||||
static void setConfirmedFalse();
|
||||
|
||||
static SPITObject *getSPITObjectRemote(const string &id);
|
||||
static const SPITObject &getSPITObjectRemoteRef(const string &id);
|
||||
static void addSPITObjectRemote(unique_ptr<SPITObject> spitObject);
|
||||
static bool removeSPITObjectRemote(const SPITObject &spitObject);
|
||||
static bool removeSPITObjectRemote(const string & spitObjectID);
|
||||
static int getSPITObjectRemoteCount() {
|
||||
return sSpitObjectsRemote.size();
|
||||
}
|
||||
static SPITObject *getSPITObjectRemote(int p_Index);
|
||||
static const SPITObject &getSPITObjectRemoteRef(int p_Index);
|
||||
static void clearSPITObjectsRemote(){ sSpitObjectsRemote.clear(); }
|
||||
|
||||
static void eventProjectClosed();
|
||||
static void clearUnconfirmedSPITObjects(SpitRepo<SPITObject> &repo);
|
||||
static void setConfirmedFalse(SpitRepo<SPITObject> &repo);
|
||||
static void eventProjectClosed(SpitRepo<SPITObject> &repo, SpitRepo<SPITObject> &remoteRepo);
|
||||
|
||||
SPITObject(string p_ID);
|
||||
|
||||
@@ -133,15 +103,15 @@ class SPITObject {
|
||||
long long getDelay() const { return m_Delay; }
|
||||
long long getDuration() const { return m_Duration; }
|
||||
|
||||
bool getProjectIndepended() const {
|
||||
bool getProjectIndepended(SpitRepo<SPITType> &repo, SpitRepo<SPITType> &remoteRepo) const {
|
||||
SPITType *ptrSPITType;
|
||||
if (m_ServerRemote == false) {
|
||||
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
|
||||
ptrSPITType = repo.getEntry(m_SPITTypeID);
|
||||
if (ptrSPITType == nullptr)
|
||||
return true;
|
||||
return ptrSPITType->getProjectIndepended();
|
||||
} else {
|
||||
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
|
||||
ptrSPITType = remoteRepo.getEntry(m_SPITTypeID);
|
||||
if (ptrSPITType == nullptr)
|
||||
return true;
|
||||
return ptrSPITType->getProjectIndepended();
|
||||
|
||||
Reference in New Issue
Block a user