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_UNKNOWN = -1,
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
00044 class Value: public sigc::trackable {
00045 public:
00046
00048 Value ();
00049
00051 Value (Type type);
00052
00054 Value( float x );
00055
00057 Value( double x );
00058
00060 Value( short int x );
00061
00063 Value( unsigned short int x );
00064
00066 Value( int x );
00067
00069 Value( unsigned int x );
00070
00072 Value( long int x );
00073
00075 Value( long long int x );
00076
00078 Value( const char* x, Type type=TYPE_STRING );
00079
00081 Value( const std::string& x, Type type=TYPE_STRING );
00082
00084 Value( void* x, Type type=TYPE_EXTERNAL_ADDRESS );
00085
00086 Value( const Value& value );
00087
00089 ~Value();
00090
00091 double as_float() const;
00092 long long int as_integer() const;
00093 std::string& as_string() const;
00094 void* as_address() const;
00095
00096 Value& set( float x, bool change_type=false );
00097 Value& set( double x, bool change_type=false );
00098 Value& set( short int x, bool change_type=false );
00099 Value& set( unsigned short int x, bool change_type=false );
00100 Value& set( int x, bool change_type=false );
00101 Value& set( unsigned int x, bool change_type=false );
00102 Value& set( long int x, bool change_type=false );
00103 Value& set( long long int x, bool change_type=false );
00104 Value& set( const std::string& x, bool change_type=false, Type type=TYPE_STRING );
00105 Value& set( const char* x, bool change_type=false, Type type=TYPE_STRING );
00106 Value& set( void* x, bool change_type=false, Type type=TYPE_EXTERNAL_ADDRESS );
00107
00108 operator float( ) const;
00109 operator double( ) const;
00110 operator short int( ) const;
00111 operator unsigned short int( ) const;
00112 operator int( ) const;
00113 operator unsigned int( ) const;
00114 operator long int( ) const;
00115 operator long long int( ) const;
00116 operator std::string&( ) const;
00117 operator const char*( ) const;
00118 operator void*( ) const;
00119
00121
00122
00124
00125
00126
00127
00128
00130
00131
00136 size_t size() const;
00137
00139
00140
00141
00142
00143
00144 Value& operator=( float x );
00145 Value& operator=( double x );
00146 Value& operator=( short int x );
00147 Value& operator=( unsigned short int x );
00148 Value& operator=( int x );
00149 Value& operator=( unsigned int x );
00150 Value& operator=( long int x );
00151 Value& operator=( long long int x );
00152 Value& operator=( const std::string& x );
00153 Value& operator=( const char* x );
00154 Value& operator=( void* x );
00155 Value& operator=( const Value& x );
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==( long 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
00169 bool operator!=( float x ) const;
00170 bool operator!=( double x ) const;
00171 bool operator!=( short int x ) const;
00172 bool operator!=( unsigned short int x ) const;
00173 bool operator!=( int x ) const;
00174 bool operator!=( unsigned int x ) const;
00175 bool operator!=( long int x ) const;
00176 bool operator!=( long long int x ) const;
00177 bool operator!=( const std::string& x ) const;
00178 bool operator!=( const char* x ) const;
00179 bool operator!=( void* x ) const;
00180
00190
00191
00192
00193
00194
00195
00205
00206
00207
00208
00209
00210
00220
00221
00222
00223
00224
00225
00235
00236
00237
00238
00239
00240
00250
00251
00252
00253
00254
00255
00257 Type type() const;
00258
00260 Type set_type( Type type );
00261
00263 sigc::signal<void> signal_changed();
00264
00265 protected:
00267 void* m_value;
00268
00270 Type m_clips_type;
00271
00273 sigc::signal<void> m_signal_changed;
00274
00275 void deallocate_storage();
00276 };
00277
00278 typedef std::vector<Value> Values;
00279
00280 }
00281
00282 #endif