additional refactoring of object and type classes

This commit is contained in:
2025-04-03 21:31:08 +02:00
parent decaf80d1f
commit 1208bee756
5 changed files with 465 additions and 662 deletions
+46 -46
View File
@@ -25,28 +25,32 @@ class SPITObjectListener;
class SPITObject {
private:
static unordered_map<string, SPITObject *> s_SPITObjects;
static unordered_map<string, SPITObject *> s_SPITObjectsRemote;
static unordered_map<string, SPITObject *> sSpitObjects;
static unordered_map<string, SPITObject *> sSpitObjectsRemote;
public:
static SPITObject *getSPITObject(string p_ID);
static const SPITObject &getSPITObjectRef(string p_ID);
static bool addSPITObject(SPITObject *p_ptrSpitObject);
static bool removeSPITObject(SPITObject *p_ptrSpitObject);
static bool removeSPITObject(string p_SpitObjectID);
static int getSPITObjectCount();
static SPITObject *getSPITObject(const string &id);
static const SPITObject &getSPITObjectRef(const string &id);
static void addSPITObject(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();
static void clearUnconfirmedSPITObjects();
static void setConfirmedFalse();
static SPITObject *getSPITObjectRemote(string p_ID);
static const SPITObject &getSPITObjectRemoteRef(string p_ID);
static bool addSPITObjectRemote(SPITObject *p_ptrSpitObject);
static bool removeSPITObjectRemote(SPITObject *p_ptrSpitObject);
static bool removeSPITObjectRemote(string p_SpitObjectID);
static int getSPITObjectRemoteCount();
static SPITObject *getSPITObjectRemote(const string &id);
static const SPITObject &getSPITObjectRemoteRef(const string &id);
static void addSPITObjectRemote(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();
@@ -54,38 +58,34 @@ class SPITObject {
static void eventProjectClosed();
SPITObject();
// SPITObject(const SPITObject& orig);
~SPITObject();
private:
string m_ID;
string m_Name;
string m_SPITTypeID;
string m_ServerParams;
string m_Remark;
bool m_Confirmed;
bool m_Fixed;
bool m_CreatedByClient;
bool m_ServerRemote;
bool m_ActionAssigned;
bool m_ActionAssignedType; // Virtual construct
long long m_FrameStart;
long long m_FrameLength;
long long m_FrameFadeInLength;
long long m_FrameFadeOutLength;
char m_ValueUse;
int m_ValueFactor;
int m_Track;
long long m_Delay;
long long m_Duration;
string m_Name{};
string m_SPITTypeID{};
string m_ServerParams{};
string m_Remark{};
bool m_Confirmed{};
bool m_Fixed{};
bool m_CreatedByClient{};
bool m_ServerRemote{};
bool m_ActionAssigned{};
bool m_ActionAssignedType{}; // Virtual construct
long long m_FrameStart{};
long long m_FrameLength{};
long long m_FrameFadeInLength{};
long long m_FrameFadeOutLength{};
char m_ValueUse{0x01};
int m_ValueFactor{1000000}; // Values are given in ppm -> 1000000 = 1/1;
int m_Track{};
long long m_Delay{};
long long m_Duration{};
bool m_PlayPrePosition;
long long m_PlayTimeInsideFrames;
int m_PlayValue;
char m_PlayValueFlag;
void initMembers();
public:
string getID() const { return m_ID; }
string getName() const { return m_Name; }
@@ -95,7 +95,7 @@ class SPITObject {
/**
* Returns if the SPITType triggers an action on the Server or on the client.
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType<br>
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
*/
bool getServerRemote() const { return m_ServerRemote; }
@@ -106,16 +106,16 @@ class SPITObject {
*/
bool getConfirmed() const { return m_Confirmed; }
bool getFixed() const { return m_Fixed; }
bool getCreatedByClient() { return m_CreatedByClient; }
bool getCreatedByClient() const { return m_CreatedByClient; }
/**
* This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.<br>
* This is used when an action is associated with a SPITType. <br>
* This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.
* This is used when an action is associated with a SPITType.
* Then this action is done for every SPITObject with the SPITType.
* @return true = an action is assigned for the SPITType.
*/
bool getActionAssignedType() const { return m_ActionAssignedType; }
/** Returns if this SPITObject has an associated action or not.<br>
* @return true = the user has asscociated an action with this SPITObject or <br>
/** Returns if this SPITObject has an associated action or not.
* @return true = the user has asscociated an action with this SPITObject or
* the user has asscociated an action with the SPITType of this SPITObject
*/
bool getActionAssigned() const { return m_ActionAssigned || m_ActionAssignedType; }
@@ -136,18 +136,18 @@ class SPITObject {
SPITType *ptrSPITType;
if (m_ServerRemote == false) {
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
if (ptrSPITType == NULL)
if (ptrSPITType == nullptr)
return true;
return ptrSPITType->getProjectIndepended();
} else {
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
if (ptrSPITType == NULL)
if (ptrSPITType == nullptr)
return true;
return ptrSPITType->getProjectIndepended();
}
};
void setID(string p_ID);
void setID(const string &id);
bool setConfirmed(bool p_Confirmed);
void setCreatedByClient(bool p_CreatedByClient);
bool setName(string p_Name);
+35 -46
View File
@@ -25,25 +25,25 @@ class SPITTypeListener;
class SPITType {
private:
static unordered_map<string, SPITType *> s_SPITTypes;
static unordered_map<string, SPITType *> s_SPITTypesRemote;
static unordered_map<string, SPITType *> sSpitTypes;
static unordered_map<string, SPITType *> sSpitTypesRemote;
public:
static SPITType *getSPITType(string p_ID);
static const SPITType &getSPITTypeRef(string p_ID);
static bool addSPITType(SPITType *p_ptrSpitType);
static bool removeSPITType(SPITType *p_ptrSpitType);
static int getSPITTypeCount();
static SPITType *getSPITType(const string &id);
static const SPITType &getSPITTypeRef(const string &id);
static void addSPITType(SPITType &spitType);
static bool removeSPITType(const SPITType &spitType);
static int getSPITTypeCount() { return sSpitTypes.size(); }
static SPITType *getSPITType(int p_Index);
static const SPITType &getSPITTypeRef(int p_Index);
static void clearSPITTypes();
static void setConfirmedFalse();
static SPITType *getSPITTypeRemote(string p_ID);
static const SPITType &getSPITTypeRemoteRef(string p_ID);
static bool addSPITTypeRemote(SPITType *p_ptrSpitType);
static bool removeSPITTypeRemote(SPITType *p_ptrSpitType);
static int getSPITTypeRemoteCount();
static SPITType *getSPITTypeRemote(const string &id);
static const SPITType &getSPITTypeRemoteRef(const string &id);
static void addSPITTypeRemote(SPITType &spitType);
static bool removeSPITTypeRemote(const SPITType &spitType);
static int getSPITTypeRemoteCount() { return sSpitTypesRemote.size(); }
static SPITType *getSPITTypeRemote(int p_Index);
static const SPITType &getSPITTypeRemoteRef(int p_Index);
static void clearSPITTypesRemote();
@@ -52,19 +52,17 @@ class SPITType {
SPITType();
SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended, long long p_DefaultDelay, long long p_DefaultDuration);
// SPITType(const SPITType& orig);
~SPITType();
private:
bool m_Confirmed;
bool m_Confirmed{};
string m_ID;
bool m_Fixed;
bool m_ServerRemote;
bool m_ServerProjectIndepended;
string m_GroupName;
string m_Name;
long long m_DefaultDelay;
long long m_DefaultDuration;
bool m_Fixed{};
bool m_ServerRemote{};
bool m_ServerProjectIndepended{};
string m_GroupName{};
string m_Name{};
long long m_DefaultDelay{};
long long m_DefaultDuration{};
bool m_CreatedByClient; // flag true = the SPITTyype is created by the client
// false = the SPITType is received from the server
@@ -72,24 +70,18 @@ class SPITType {
bool m_ActionAssigned; // This is a virtual flag if user associates an action with a SPITType.
// Can be used to setActionAssigned for all SPITObjects with this SPITType
void initMembers();
public:
string getID() const { return m_ID; }
string getGroupName() const { return m_GroupName; }
string getName() const { return m_Name; }
/**
* Returns if the SPITType triggers an action on the Server or on the client.
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType<br>
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
*/
bool getServerRemote() const {
return m_ServerRemote;
}
bool getServerRemote() const { return m_ServerRemote; }
bool getProjectIndepended() const {
return m_ServerProjectIndepended;
}
bool getProjectIndepended() const { return m_ServerProjectIndepended; }
/**
* This is used by the server and client to tell if the other side has registered the changes.
* @return true = other side has registered the changes.
@@ -101,40 +93,37 @@ class SPITType {
bool getCreatedByClient() const { return m_CreatedByClient; }
/**
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
* This can used to setActionAssigned to all SPITObjects with this SPITType.
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.
* @return true = the user has associated an action with this SPITType.
*/
bool getActionAssigned() const {
return m_ActionAssigned;
}
public:
void setID(string p_ID);
bool setGroupName(string p_GroupName);
bool setName(string p_Name);
void setID(const string &p_ID) { m_ID = p_ID; }
bool setGroupName(const string &p_GroupName);
bool setName(const string &p_Name);
bool setServerRemote(bool p_BelongstoServer);
bool setProjectIndepended(bool p_ProjectIndepeneded);
bool setConfirmed(bool p_Confirmed);
bool setFixed(bool p_Fixed);
bool setDefaultDelay(long long p_Delay);
bool setDefaultDuration(long long p_Duration);
void setCreatedByClient(bool p_CreatedByClient);
/**
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
* This can used to setActionAssigned to all SPITObjects with this SPITType.
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.
* @return true = the m_ActionAssigned has changed.
*/
bool setActionAssigned(bool p_ActionAssigned);
bool setMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType);
void fillMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType);
void fillMessageOP(SPIT_Message::RemoveSPITType *p_RemoveSPITType);
// static char* stringCopy(const char* p_String);
bool setMessageOP(SPIT_Message::ReportSPITType &reportSpitType);
void fillMessageOP(SPIT_Message::ReportSPITType &smReportSpitType) const;
void fillMessageOP(SPIT_Message::RemoveSPITType &smRemoveSpitType) const;
};
#endif /* SPITTYPE_H */