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 "ofConstants.h" 00027 #include <string> 00028 00029 typedef enum _ofxOscArgType 00030 { 00031 OFXOSC_TYPE_NONE, 00032 OFXOSC_TYPE_INT32, 00033 OFXOSC_TYPE_FLOAT, 00034 OFXOSC_TYPE_STRING, 00035 OFXOSC_TYPE_BLOB, 00036 OFXOSC_TYPE_BUNDLE, 00037 OFXOSC_TYPE_INDEXOUTOFBOUNDS 00038 } ofxOscArgType; 00039 00040 /* 00041 00042 ofxOscArg 00043 00044 base class for arguments 00045 00046 */ 00047 00048 class ofxOscArg 00049 { 00050 public: 00051 ofxOscArg() {}; 00052 virtual ~ofxOscArg() {}; 00053 00054 virtual ofxOscArgType getType() { return OFXOSC_TYPE_NONE; } 00055 virtual string getTypeName() { return "none"; } 00056 00057 private: 00058 }; 00059 00060 00061 /* 00062 00063 subclasses for each possible argument type 00064 00065 */ 00066 00067 #if defined TARGET_WIN32 && defined _MSC_VER 00068 // required because MSVC isn't ANSI-C compliant 00069 typedef long int32_t; 00070 #endif 00071 00072 class ofxOscArgInt32 : public ofxOscArg 00073 { 00074 public: 00075 ofxOscArgInt32( int32_t _value ) { value = _value; } 00076 ~ofxOscArgInt32() {}; 00077 00079 ofxOscArgType getType() { return OFXOSC_TYPE_INT32; } 00080 string getTypeName() { return "int32"; } 00081 00083 int32_t get() const { return value; } 00085 void set( int32_t _value ) { value = _value; } 00086 00087 private: 00088 int32_t value; 00089 }; 00090 00091 class ofxOscArgFloat : public ofxOscArg 00092 { 00093 public: 00094 ofxOscArgFloat( float _value ) { value = _value; } 00095 ~ofxOscArgFloat() {}; 00096 00098 ofxOscArgType getType() { return OFXOSC_TYPE_FLOAT; } 00099 string getTypeName() { return "float"; } 00100 00102 float get() const { return value; } 00104 void set( float _value ) { value = _value; } 00105 00106 private: 00107 float value; 00108 }; 00109 00110 class ofxOscArgString : public ofxOscArg 00111 { 00112 public: 00113 ofxOscArgString( string _value ) { value = _value; } 00114 ~ofxOscArgString() {}; 00115 00117 ofxOscArgType getType() { return OFXOSC_TYPE_STRING; } 00118 string getTypeName() { return "string"; } 00119 00121 string get() const { return value; } 00123 void set( const char* _value ) { value = _value; } 00124 00125 private: 00126 std::string value; 00127 }; 00128 00129 #endif