value.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CLIPSVALUE_H
00020 #define CLIPSVALUE_H
00021
00022 #include <string>
00023 #include <vector>
00024
00025 #include <sigc++/sigc++.h>
00026
00027 namespace CLIPS {
00028
00029 typedef enum Type {
00030 TYPE_FLOAT = 0,
00031 TYPE_INTEGER = 1,
00032 TYPE_SYMBOL = 2,
00033 TYPE_STRING = 3,
00034 TYPE_EXTERNAL_ADDRESS = 5,
00035 TYPE_INSTANCE_ADDRESS = 7,
00036 TYPE_INSTANCE_NAME = 8,
00037 } Type;
00038
00042 class Value: public sigc::trackable {
00043 public:
00044
00046 Value (Type type);
00047
00049 Value( float x );
00050
00052 Value( double x );
00053
00055 Value( short int x );
00056
00058 Value( unsigned short int x );
00059
00061 Value( int x );
00062
00064 Value( unsigned int x );
00065
00067 Value( long int x );
00068
00070 Value( char* x, Type type=TYPE_STRING );
00071
00073 Value( const std::string& x, Type type=TYPE_STRING );
00074
00076 Value( void* x, Type type=TYPE_EXTERNAL_ADDRESS );
00077
00078 Value( const Value& value );
00079
00081 ~Value();
00082
00083 double as_float() const;
00084 long int as_integer() const;
00085 std::string& as_string() const;
00086 void* as_address() const;
00087
00088 Value& set( float x, bool change_type=false );
00089 Value& set( double x, bool change_type=false );
00090 Value& set( short int x, bool change_type=false );
00091 Value& set( unsigned short int x, bool change_type=false );
00092 Value& set( int x, bool change_type=false );
00093 Value& set( unsigned int x, bool change_type=false );
00094 Value& set( long int x, bool change_type=false );
00095 Value& set( const std::string& x, bool change_type=false, Type type=TYPE_STRING );
00096 Value& set( const char* x, bool change_type=false, Type type=TYPE_STRING );
00097 Value& set( void* x, bool change_type=false, Type type=TYPE_EXTERNAL_ADDRESS );
00098
00099 operator float( ) const;
00100 operator double( ) const;
00101 operator short int( ) const;
00102 operator unsigned short int( ) const;
00103 operator int( ) const;
00104 operator unsigned int( ) const;
00105 operator long int( ) const;
00106 operator std::string&( ) const;
00107 operator const char*( ) const;
00108 operator void*( ) const;
00109
00111
00112
00114
00115
00116
00117
00118
00120
00121
00126 size_t size() const;
00127
00129
00130
00131
00132
00133
00134 Value& operator=( float x );
00135 Value& operator=( double x );
00136 Value& operator=( short int x );
00137 Value& operator=( unsigned short int x );
00138 Value& operator=( int x );
00139 Value& operator=( unsigned int x );
00140 Value& operator=( long int x );
00141 Value& operator=( const std::string& x );
00142 Value& operator=( const char* x );
00143 Value& operator=( void* x );
00144 Value& operator=( const Value& x );
00145
00146 bool operator==( float x ) const;
00147 bool operator==( double x ) const;
00148 bool operator==( short int x ) const;
00149 bool operator==( unsigned short int x ) const;
00150 bool operator==( int x ) const;
00151 bool operator==( unsigned int x ) const;
00152 bool operator==( long int x ) const;
00153 bool operator==( const std::string& x ) const;
00154 bool operator==( const char* x ) const;
00155 bool operator==( void* x ) const;
00156
00157 bool operator!=( float x ) const;
00158 bool operator!=( double x ) const;
00159 bool operator!=( short int x ) const;
00160 bool operator!=( unsigned short int x ) const;
00161 bool operator!=( int x ) const;
00162 bool operator!=( unsigned int x ) const;
00163 bool operator!=( long int x ) const;
00164 bool operator!=( const std::string& x ) const;
00165 bool operator!=( const char* x ) const;
00166 bool operator!=( void* x ) const;
00167
00177
00178
00179
00180
00181
00182
00192
00193
00194
00195
00196
00197
00207
00208
00209
00210
00211
00212
00222
00223
00224
00225
00226
00227
00237
00238
00239
00240
00241
00242
00244 Type type() const;
00245
00247 Type set_type( Type type );
00248
00250 sigc::signal<void> signal_changed();
00251
00252 protected:
00254 void* m_value;
00255
00257 Type m_clips_type;
00258
00260 sigc::signal<void> m_signal_changed;
00261
00262 void deallocate_storage();
00263 };
00264
00265 typedef std::vector<Value> Values;
00266
00267 }
00268
00269 #endif