98 lines
3.6 KiB
C++
98 lines
3.6 KiB
C++
#pragma once
|
|
|
|
#include "spit_object.hpp"
|
|
#include <unordered_map>
|
|
|
|
namespace spit {
|
|
|
|
class SPlayer {
|
|
|
|
//----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------
|
|
public:
|
|
enum PTypes {
|
|
// diescrete player: This player is used to transmit single discrete values.
|
|
PTYPE_DISCRETE = 0x00,
|
|
// continous player: This player plays SPIT objects sometime during the project.
|
|
PTYPE_CONTINOUS = 0x01,
|
|
// continous main player: time value can be used like a timecode.<br>The time value is the position in server's project.<br>A server should use only one main player.
|
|
PTYPE_MAIN = 0x02,
|
|
};
|
|
|
|
enum VFlags {
|
|
// Set the given value directly
|
|
VFLAG_DIRECT = 0x00,
|
|
// Increase the existing value by the given value.<br>This is usefull e.g. when instead of a fader a endless wheel is used*/
|
|
VFLAG_INCREASE = 0x01,
|
|
// Decrease the existing value by the given value.<br>This is usefull e.g. when instead of a fader a endless wheel is used*/
|
|
VFLAG_DECREASE = 0x02,
|
|
};
|
|
|
|
class PlayType {
|
|
public:
|
|
PlayType(SPlayer *spitPlayer, string spitObjectID);
|
|
PlayType(const PlayType &orig);
|
|
|
|
string getSPITTypeID() const { return mSpitTypeID; }
|
|
|
|
void startPlaySequence();
|
|
bool getIsNew() const { return mIsNew; }
|
|
void setIsNew(bool isNew) { mIsNew = isNew; }
|
|
bool getIsPlayed() const { return mIsPlayed; }
|
|
void setIsPlayed(bool p_IsFound) { mIsPlayed = p_IsFound; }
|
|
string getPlayerID() const { return mPlayerID; }
|
|
string getPlayerName() const { return mPlayerName; }
|
|
bool getPlayerIsRunning() const { return mPlayerRuns; }
|
|
void setPlayerIsRunning(bool playerRuns) { mPlayerRuns = playerRuns; }
|
|
void setValue(double value) { mValue = value; }
|
|
void addValue(double value, double valueFactor) { mValue += (value * valueFactor); }
|
|
double getValue() const { return mValue; }
|
|
|
|
private:
|
|
string mPlayerID;
|
|
string mPlayerName;
|
|
bool mPlayerRuns;
|
|
string mSpitTypeID;
|
|
bool mIsPlayed;
|
|
bool mIsNew;
|
|
double mValue;
|
|
};
|
|
|
|
//----- SPlayer ------
|
|
public:
|
|
// list the SPITPlayers
|
|
static unordered_map<string, unique_ptr<SPlayer>> sSpitPlayers; // all actual played objects
|
|
static SPlayer &getSPITPlayer(string pPlayerID); // if a player does not exist creates a new one
|
|
static void clearPlayers() { sSpitPlayers.clear(); }
|
|
|
|
SPlayer(string pPlayerID);
|
|
virtual ~SPlayer();
|
|
|
|
void startPlaySequence(); // called by SPIT_Client::parsePlaySPITStart
|
|
PlayType *addTypePlaying(string spitTypeID); // called by SPIT_Client::parsePlaySPITStart
|
|
void endPlaySequence(); // called by SPIT_Client::parsePlaySPITEnd
|
|
|
|
string getID() {
|
|
return mId;
|
|
}
|
|
|
|
unordered_map<string, unique_ptr<PlayType>> &getPlaySPITTypes() { return mPlaySPITTypes; }
|
|
void setIsRunning(bool isRunning) { mIsRunning = isRunning; }
|
|
void setName(string name) { mName = name; }
|
|
void setType(char type) { mType = type; }
|
|
void setTime(uint64_t frames) { mTimeFrames = frames; }
|
|
bool getIsRunning() const { return mIsRunning; }
|
|
string getName() const { return mName; }
|
|
char getType() const { return mType; }
|
|
uint64_t getTime() const { return mTimeFrames; }
|
|
|
|
private:
|
|
string mId;
|
|
string mName;
|
|
char mType;
|
|
unordered_map<string, unique_ptr<PlayType>> mPlaySPITTypes;
|
|
|
|
bool mIsRunning;
|
|
uint64_t mTimeFrames;
|
|
};
|
|
|
|
} // namespace spit
|