Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2007 George Tzanetakis <gtzan@cs.uvic.ca> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 #ifndef MARSYAS_EX_COMMON_H 00019 #define MARSYAS_EX_COMMON_H 00020 00021 #include <marsyas/common_header.h> 00022 00023 #include <string> 00024 #include <iostream> 00025 #include <sstream> 00026 00027 namespace Marsyas 00028 { 00029 00039 enum { 00040 NONE=0, 00041 T_CONST, 00042 T_LIB, 00043 T_FUN, // a function call 00044 T_VAR, 00045 T_LIST, 00046 00047 T_REAL, 00048 T_NATURAL, 00049 T_STR, 00050 T_BOOL, 00051 T_NAME, 00052 T_CNAME, 00053 T_COND, // conditional 00054 OP_BNEG, 00055 OP_MNEG, 00056 OP_ADD, 00057 OP_SUB, 00058 OP_MUL, 00059 OP_DIV, 00060 OP_MOD, 00061 OP_AND, 00062 OP_NE, 00063 OP_OR, 00064 OP_EQ, 00065 OP_GT, 00066 OP_LT, 00067 OP_GE, 00068 OP_LE, 00069 OP_LINK, 00070 OP_ASGN, // lchild=expr, rchild=nm 00071 OP_SETCTRL, // lchild=expr, rchild=nm 00072 OP_GETCTRL, 00073 OP_CONV 00074 }; 00075 00076 #define ExT_mrs_unit 1 00077 #define ExT_mrs_bool 2 00078 #define ExT_mrs_natural 4 00079 #define ExT_mrs_real 8 00080 #define ExT_mrs_string 16 00081 #define ExT_mrs_timer 32 00082 #define ExT_mrs_scheduler 64 00083 00084 00089 unsigned int ex_string_to_typeid(std::string tp); 00094 std::string ex_typeid_to_string(unsigned int tp); 00095 00100 std::string dtos(double d); 00101 00106 std::string dtos(float d); 00107 00112 std::string ltos(long l); 00113 00118 std::string btos(bool b); 00119 00124 long stol(std::string n); 00125 00134 class ExRefCount { 00135 private: 00136 int ref_count; 00137 protected: 00138 ExRefCount() { ref_count=0; } 00139 public: 00140 virtual ~ExRefCount() { } 00141 // reference counting 00142 void inc_ref() { ref_count++; } 00143 void deref() { --ref_count; if(ref_count<1) delete this; } 00144 int get_ref_count() { return ref_count; } 00145 void op_ref() { std::cout<<"Obj<"<<this<<":"<<ref_count<<">\n"; } 00146 }; 00147 00148 } 00149 #endif 00150