#pragma once #include "spit_type.hpp" #include "spit_message.hpp" #include "spit_repo.hpp" using namespace std; namespace spit { class SObjectListener; class SObject { public: template struct Property { friend SObject; Property(bool &confirmed) : rConfirmed(confirmed) { } bool set(const T& val) { if (mValue == val) return false; mValue = val; rConfirmed = false; return true; } T get () const { return mValue; } private: bool & rConfirmed; T mValue{}; }; Property Name{mConfirmed}; Property Remark{mConfirmed}; Property ServerParams{mConfirmed}; Property SPITTypeID{mConfirmed}; // 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 // true = the action is triggered on the server. The server waits for the client to play objects of this SPITType. Property ServerRemote{mConfirmed}; Property Fixed{mConfirmed}; Property FrameStart{mConfirmed}; Property FrameLength{mConfirmed}; Property FrameFadeInLength{mConfirmed}; Property FrameFadeOutLength{mConfirmed}; Property ValueUse{mConfirmed}; Property ValueFactor{mConfirmed}; Property Track{mConfirmed}; Property Delay{mConfirmed}; Property Duration{mConfirmed}; static void clearUnconfirmedObjects(SpitRepo &repo); static void setConfirmedFalse(SpitRepo &repo); static void eventProjectClosed(SpitRepo &repo, SpitRepo &remoteRepo); SObject(string iD) { mID = iD; } private: string mID; bool mConfirmed{}; bool mCreatedByClient{}; bool mActionAssigned{}; bool mActionAssignedType{}; // Virtual construct char mValueUse{0x01}; int mValueFactor{1000000}; // Values are given in ppm -> 1000000 = 1/1; bool mPlayPrePosition; uint64_t mPlayTimeInsideFrames; int mPlayValue; char mPlayValueFlag; public: string getID() const { return mID; } /** * 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. */ bool getConfirmed() const { return mConfirmed; } bool getCreatedByClient() const { return mCreatedByClient; } /** * 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 SObject with the SPITType. * @return true = an action is assigned for the SPITType. */ bool getActionAssignedType() const { return mActionAssignedType; } /** Returns if this SObject has an associated action or not. * @return true = the user has asscociated an action with this SObject or * the user has asscociated an action with the SPITType of this SObject */ bool getActionAssigned() const { return mActionAssigned || mActionAssignedType; } bool getProjectIndepended(SpitRepo &repo, SpitRepo &remoteRepo) const { SType *ptrSPITType; if (ServerRemote.get() == false) { ptrSPITType = repo.getEntry(SPITTypeID.get()); if (ptrSPITType == nullptr) return true; return ptrSPITType->ProjectIndepended.get(); } else { ptrSPITType = remoteRepo.getEntry(SPITTypeID.get()); if (ptrSPITType == nullptr) return true; return ptrSPITType->ProjectIndepended.get(); } }; bool setConfirmed(bool confirmed); void setCreatedByClient(bool createdByClient) { mCreatedByClient = createdByClient; } bool setActionAssignedType(bool actionAssigned); bool setActionAssigned(bool actionAssigned); bool setMessageOP(Message::ReportObject *message); void fillMessageOP(Message::ReportObject &message); void fillMessageOP(Message::RemoveObject &message); }; }