00001 /* 00002 00003 Copyright 2007, 2008 Damian Stewart damian@frey.co.nz 00004 Distributed under the terms of the GNU Lesser General Public License v3 00005 00006 This file is part of the ofxOsc openFrameworks OSC addon. 00007 00008 ofxOsc is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU Lesser General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 ofxOsc is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public License 00019 along with ofxOsc. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 #ifndef _OFXOSCARG_H 00023 #define _OFXOSCARG_H 00024 00025 #include <ofConstants.h> 00026 #include <string> 00027 00028 typedef enum _ofxOscArgType 00029 { 00030 OFXOSC_TYPE_NONE, 00031 OFXOSC_TYPE_INT32, 00032 OFXOSC_TYPE_FLOAT, 00033 OFXOSC_TYPE_STRING, 00034 OFXOSC_TYPE_BLOB, 00035 OFXOSC_TYPE_BUNDLE, 00036 OFXOSC_TYPE_INDEXOUTOFBOUNDS 00037 } ofxOscArgType; 00038 00039 /* 00040 00041 ofxOscArg 00042 00043 base class for arguments 00044 00045 */ 00046 00047 class ofxOscArg 00048 { 00049 public: 00050 ofxOscArg() {}; 00051 virtual ~ofxOscArg() {}; 00052 00053 virtual ofxOscArgType getType() { return OFXOSC_TYPE_NONE; } 00054 virtual string getTypeName() { return "none"; } 00055 00056 private: 00057 }; 00058 00059 00060 /* 00061 00062 subclasses for each possible argument type 00063 00064 */ 00065 00066 #if defined TARGET_WIN32 && defined _MSC_VER 00067 // required because MSVC isn't ANSI-C compliant 00068 typedef long int32_t; 00069 #endif 00070 00071 class ofxOscArgInt32 : public ofxOscArg 00072 { 00073 public: 00074 ofxOscArgInt32( int32_t _value ) { value = _value; } 00075 ~ofxOscArgInt32() {}; 00076 00078 ofxOscArgType getType() { return OFXOSC_TYPE_INT32; } 00079 string getTypeName() { return "int32"; } 00080 00082 int32_t get() const { return value; } 00084 void set( int32_t _value ) { value = _value; } 00085 00086 private: 00087 int32_t value; 00088 }; 00089 00090 class ofxOscArgFloat : public ofxOscArg 00091 { 00092 public: 00093 ofxOscArgFloat( float _value ) { value = _value; } 00094 ~ofxOscArgFloat() {}; 00095 00097 ofxOscArgType getType() { return OFXOSC_TYPE_FLOAT; } 00098 string getTypeName() { return "float"; } 00099 00101 float get() const { return value; } 00103 void set( float _value ) { value = _value; } 00104 00105 private: 00106 float value; 00107 }; 00108 00109 class ofxOscArgString : public ofxOscArg 00110 { 00111 public: 00112 ofxOscArgString( string _value ) { value = _value; } 00113 ~ofxOscArgString() {}; 00114 00116 ofxOscArgType getType() { return OFXOSC_TYPE_STRING; } 00117 string getTypeName() { return "string"; } 00118 00120 string get() const { return value; } 00122 void set( const char* _value ) { value = _value; } 00123 00124 private: 00125 std::string value; 00126 }; 00127 00128 #endif