#pragma once
#include "ofConstants.h"
#include "ofFileUtils.h"
typedef enum _ofxOscArgType{
OFXOSC_TYPE_INT32 = 'i',
OFXOSC_TYPE_INT64 = 'h',
OFXOSC_TYPE_FLOAT = 'f',
OFXOSC_TYPE_DOUBLE = 'd',
OFXOSC_TYPE_STRING = 's',
OFXOSC_TYPE_SYMBOL = 'S',
OFXOSC_TYPE_CHAR = 'c',
OFXOSC_TYPE_MIDI_MESSAGE = 'm',
OFXOSC_TYPE_TRUE = 'T',
OFXOSC_TYPE_FALSE = 'F',
OFXOSC_TYPE_NONE = 'N',
OFXOSC_TYPE_TRIGGER = 'I',
OFXOSC_TYPE_TIMETAG = 't',
OFXOSC_TYPE_BLOB = 'b',
OFXOSC_TYPE_RGBA_COLOR = 'r',
OFXOSC_TYPE_INDEXOUTOFBOUNDS = 0
} ofxOscArgType;
class ofxOscArg{
public:
virtual ~ofxOscArg() {}
virtual ofxOscArgType getType() const {return OFXOSC_TYPE_NONE;}
virtual std::string getTypeName() const {return "N";}
};
class ofxOscArgInt32 : public ofxOscArg{
public:
ofxOscArgInt32(std::int32_t value) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_INT32;}
std::string getTypeName() const {return "i";}
std::int32_t get() const {return value;}
void set(std::int32_t value) {this->value = value;}
private:
std::int32_t value;
};
class ofxOscArgInt : public ofxOscArgInt32{
public:
ofxOscArgInt(std::int32_t value) : ofxOscArgInt32(value) {}
};
class ofxOscArgInt64 : public ofxOscArg{
public:
ofxOscArgInt64(std::int64_t value) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_INT64;}
std::string getTypeName() const {return "h";}
std::int64_t get() const {return value;}
void set(std::int64_t value) {this->value = value;}
private:
std::int64_t value;
};
class ofxOscArgFloat : public ofxOscArg{
public:
ofxOscArgFloat(float value) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_FLOAT;}
std::string getTypeName() const {return "f";}
float get() const {return value;}
void set(float value) {this->value = value;}
private:
float value;
};
class ofxOscArgDouble : public ofxOscArg{
public:
ofxOscArgDouble(double value) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_DOUBLE;}
std::string getTypeName() const {return "d";}
double get() const {return value;}
void set(double value) {this->value = value;}
private:
double value;
};
class ofxOscArgString : public ofxOscArg{
public:
ofxOscArgString(const std::string &value ) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_STRING;}
std::string getTypeName() const {return "s";}
const std::string &get() const {return value;}
void set(const char *value) {this->value = value;}
void set(const std::string &value) {this->value = value;}
private:
std::string value;
};
class ofxOscArgSymbol : public ofxOscArgString{
public:
ofxOscArgSymbol(const std::string &value) : ofxOscArgString(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_SYMBOL;}
std::string getTypeName() const {return "S";}
};
class ofxOscArgChar : public ofxOscArg{
public:
ofxOscArgChar(char value) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_CHAR;}
std::string getTypeName() const {return "c";}
char get() const {return value;}
void set(char value) {this->value = value;}
private:
char value;
};
class ofxOscArgMidiMessage : public ofxOscArg{
public:
ofxOscArgMidiMessage(std::uint32_t value) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_MIDI_MESSAGE;}
std::string getTypeName() const {return "m";}
std::uint32_t get() const {return value;}
void set(std::uint32_t value) {this->value = value;}
private:
std::uint32_t value;
};
class ofxOscArgBool : public ofxOscArg{
public:
ofxOscArgBool(bool value) : value(value) {}
ofxOscArgType getType() const {
return value ? OFXOSC_TYPE_TRUE : OFXOSC_TYPE_FALSE;
}
std::string getTypeName() const {
return value ? "T" : "F";
}
bool get() const {return value;}
void set(bool value) {this->value = value;}
private:
bool value;
};
class ofxOscArgNone : public ofxOscArgBool{
public:
ofxOscArgNone() : ofxOscArgBool(true) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_NONE;}
std::string getTypeName() const {return "N";}
};
class ofxOscArgTrigger : public ofxOscArgBool{
public:
ofxOscArgTrigger() : ofxOscArgBool(true) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_TRIGGER;}
std::string getTypeName() const {return "I";}
};
class ofxOscArgTimetag : public ofxOscArg{
public:
ofxOscArgTimetag(std::uint64_t value) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_TIMETAG;}
std::string getTypeName() const {return "t";}
std::uint64_t get() const {return value;}
void set(std::uint64_t value) {this->value = value;}
private:
std::uint64_t value;
};
class ofxOscArgBlob : public ofxOscArg{
public:
ofxOscArgBlob(const ofBuffer &value) : value(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_BLOB;}
std::string getTypeName() const {return "b";}
const ofBuffer &get() const {return value;}
void set(const char *value, unsigned int length) {
this->value.set(value, length);
}
private:
ofBuffer value;
};
class ofxOscArgRgbaColor : public ofxOscArgMidiMessage{
public:
ofxOscArgRgbaColor(std::uint32_t value) : ofxOscArgMidiMessage(value) {}
ofxOscArgType getType() const {return OFXOSC_TYPE_RGBA_COLOR;}
std::string getTypeName() const {return "r";}
};
Comments