00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CLIPSVALUE_H
00021 #define CLIPSVALUE_H
00022
00023 #include <string>
00024 #include <vector>
00025
00026 #include <sigc++/sigc++.h>
00027
00028 namespace CLIPS {
00029
00030 typedef enum Type {
00031 TYPE_FLOAT = 0,
00032 TYPE_INTEGER = 1,
00033 TYPE_SYMBOL = 2,
00034 TYPE_STRING = 3,
00035 TYPE_EXTERNAL_ADDRESS = 5,
00036 TYPE_INSTANCE_ADDRESS = 7,
00037 TYPE_INSTANCE_NAME = 8,
00038 } Type;
00039
00043 class Value: public sigc::trackable {
00044 public:
00045
00047 Value (Type type);
00048
00050 Value( float x );
00051
00053 Value( double x );
00054
00056 Value( short int x );
00057
00059 Value( unsigned short int x );
00060
00062 Value( int x );
00063
00065 Value( unsigned int x );
00066
00068 Value( long int x );
00069
00071 Value( char* x, Type type=TYPE_STRING );
00072
00074 Value( const std::string& x, Type type=TYPE_STRING );
00075
00077 Value( void* x, Type type=TYPE_EXTERNAL_ADDRESS );
00078
00079 Value( const Value& value );
00080
00082 ~Value();
00083
00084 double as_float() const;
00085 long int as_integer() const;
00086 std::string& as_string() const;
00087 void* as_address() const;
00088
00089 Value& set( float x, bool change_type=false );
00090 Value& set( double x, bool change_type=false );
00091 Value& set( short int x, bool change_type=false );
00092 Value& set( unsigned short int x, bool change_type=false );
00093 Value& set( int x, bool change_type=false );
00094 Value& set( unsigned int x, bool change_type=false );
00095 Value& set( long int x, bool change_type=false );
00096 Value& set( const std::string& x, bool change_type=false, Type type=TYPE_STRING );
00097 Value& set( const char* x, bool change_type=false, Type type=TYPE_STRING );
00098 Value& set( void* x, bool change_type=false, Type type=TYPE_EXTERNAL_ADDRESS );
00099
00100 operator float( ) const;
00101 operator double( ) const;
00102 operator short int( ) const;
00103 operator unsigned short int( ) const;
00104 operator int( ) const;
00105 operator unsigned int( ) const;
00106 operator long int( ) const;
00107 operator std::string&( ) const;
00108 operator const char*( ) const;
00109 operator void*( ) const;
00110
00112
00113
00115
00116
00117
00118
00119
00121
00122
00127 size_t size() const;
00128
00130
00131
00132
00133
00134
00135 Value& operator=( float x );
00136 Value& operator=( double x );
00137 Value& operator=( short int x );
00138 Value& operator=( unsigned short int x );
00139 Value& operator=( int x );
00140 Value& operator=( unsigned int x );
00141 Value& operator=( long int x );
00142 Value& operator=( const std::string& x );
00143 Value& operator=( const char* x );
00144 Value& operator=( void* x );
00145 Value& operator=( const Value& x );
00146
00147 bool operator==( float x ) const;
00148 bool operator==( double x ) const;
00149 bool operator==( short int x ) const;
00150 bool operator==( unsigned short int x ) const;
00151 bool operator==( int x ) const;
00152 bool operator==( unsigned int x ) const;
00153 bool operator==( long int x ) const;
00154 bool operator==( const std::string& x ) const;
00155 bool operator==( const char* x ) const;
00156 bool operator==( void* x ) const;
00157
00158 bool operator!=( float x ) const;
00159 bool operator!=( double x ) const;
00160 bool operator!=( short int x ) const;
00161 bool operator!=( unsigned short int x ) const;
00162 bool operator!=( int x ) const;
00163 bool operator!=( unsigned int x ) const;
00164 bool operator!=( long int x ) const;
00165 bool operator!=( const std::string& x ) const;
00166 bool operator!=( const char* x ) const;
00167 bool operator!=( void* x ) const;
00168
00178
00179
00180
00181
00182
00183
00193
00194
00195
00196
00197
00198
00208
00209
00210
00211
00212
00213
00223
00224
00225
00226
00227
00228
00238
00239
00240
00241
00242
00243
00245 Type type() const;
00246
00248 Type set_type( Type type );
00249
00251 sigc::signal<void> signal_changed();
00252
00253 protected:
00255 void* m_value;
00256
00258 Type m_clips_type;
00259
00261 sigc::signal<void> m_signal_changed;
00262
00263 void deallocate_storage();
00264 };
00265
00266 typedef std::vector<Value> Values;
00267
00268 }
00269
00270 #endif