clipsmm - C++ CLIPS Interface Library

clipsmm logo
value.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2006 Rick L. Vinyard, Jr. <rvinyard@cs.nmsu.edu> *
3 * Copyright (C) 2013 Tim Niemueller [www.niemueller.de] *
4 * *
5 * This file is part of the clipsmm library. *
6 * *
7 * The clipsmm library is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU General Public License *
9 * version 3 as published by the Free Software Foundation. *
10 * *
11 * The clipsmm library is distributed in the hope that it will be *
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this software. If not see <http://www.gnu.org/licenses/>. *
18 ***************************************************************************/
19#ifndef CLIPSVALUE_H
20#define CLIPSVALUE_H
21
22#include <string>
23#include <vector>
24
25#include <sigc++/sigc++.h>
26
27namespace CLIPS {
28
39
44class Value: public sigc::trackable {
45 public:
46
48 Value ();
49
51 Value (Type type);
52
54 Value( float x );
55
57 Value( double x );
58
60 Value( short int x );
61
63 Value( unsigned short int x );
64
66 Value( int x );
67
69 Value( unsigned int x );
70
72 Value( long int x );
73
75 Value( long long int x );
76
78 Value( const char* x, Type type=TYPE_STRING );
79
81 Value( const std::string& x, Type type=TYPE_STRING );
82
85
86 Value( const Value& value );
87
89 ~Value();
90
91 double as_float() const;
92 long long int as_integer() const;
93 std::string& as_string() const;
94 void* as_address() const;
95
96 Value& set( float x, bool change_type=false );
97 Value& set( double x, bool change_type=false );
98 Value& set( short int x, bool change_type=false );
99 Value& set( unsigned short int x, bool change_type=false );
100 Value& set( int x, bool change_type=false );
101 Value& set( unsigned int x, bool change_type=false );
102 Value& set( long int x, bool change_type=false );
103 Value& set( long long int x, bool change_type=false );
104 Value& set( const std::string& x, bool change_type=false, Type type=TYPE_STRING );
105 Value& set( const char* x, bool change_type=false, Type type=TYPE_STRING );
106 Value& set( void* x, bool change_type=false, Type type=TYPE_EXTERNAL_ADDRESS );
107
108 operator float( ) const;
109 operator double( ) const;
110 operator short int( ) const;
111 operator unsigned short int( ) const;
112 operator int( ) const;
113 operator unsigned int( ) const;
114 operator long int( ) const;
115 operator long long int( ) const;
116 operator std::string&( ) const;
117 operator const char*( ) const;
118 operator void*( ) const;
119
121 // T& operator() () const { return this->get(); }
122
124 // Value<T,CLIPSType>& operator() ( const T& val ) {
125 // this->set( val );
126 // return *this;
127 // }
128
130 // const std::type_info& type_info() const { return typeid( T ); }
131
136 size_t size() const;
137
139 // Value<T,CLIPSType>& operator= ( const T& val ) {
140 // this->set( val );
141 // return *this;
142 // }
143
144 Value& operator=( float x );
145 Value& operator=( double x );
146 Value& operator=( short int x );
147 Value& operator=( unsigned short int x );
148 Value& operator=( int x );
149 Value& operator=( unsigned int x );
150 Value& operator=( long int x );
151 Value& operator=( long long int x );
152 Value& operator=( const std::string& x );
153 Value& operator=( const char* x );
154 Value& operator=( void* x );
155 Value& operator=( const Value& x );
156
157 bool operator==( float x ) const;
158 bool operator==( double x ) const;
159 bool operator==( short int x ) const;
160 bool operator==( unsigned short int x ) const;
161 bool operator==( int x ) const;
162 bool operator==( unsigned int x ) const;
163 bool operator==( long int x ) const;
164 bool operator==( long long int x ) const;
165 bool operator==( const std::string& x ) const;
166 bool operator==( const char* x ) const;
167 bool operator==( void* x ) const;
168
169 bool operator!=( float x ) const;
170 bool operator!=( double x ) const;
171 bool operator!=( short int x ) const;
172 bool operator!=( unsigned short int x ) const;
173 bool operator!=( int x ) const;
174 bool operator!=( unsigned int x ) const;
175 bool operator!=( long int x ) const;
176 bool operator!=( long long int x ) const;
177 bool operator!=( const std::string& x ) const;
178 bool operator!=( const char* x ) const;
179 bool operator!=( void* x ) const;
180
190 // template <typename X>
191 // Value& operator+=( X other ) {
192 // this->set( this->get() + other );
193 // return *this;
194 // }
195
205 // template <typename X>
206 // Value& operator-=( X other ) {
207 // this->set( this->get() - other );
208 // return *this;
209 // }
210
220 // template <typename X>
221 // Value& operator*=( X other ) {
222 // this->set( this->get() * other );
223 // return *this;
224 // }
225
235 // template <typename X>
236 // Value& operator/=( X other ) {
237 // this->set( this->get() / other );
238 // return *this;
239 // }
240
250 // template <typename X>
251 // Value& operator%=( X other ) {
252 // this->set( this->get() % other );
253 // return *this;
254 // }
255
257 Type type() const;
258
261
263 sigc::signal<void> signal_changed();
264
265 protected:
267 void* m_value;
268
271
273 sigc::signal<void> m_signal_changed;
274
275 void deallocate_storage();
276};
277
278 typedef std::vector<Value> Values;
279
280}
281
282#endif
Definition value.h:44
void * m_value
Storage for the underlying value.
Definition value.h:267
Type type() const
Arithmetic assignment operator.
Definition value.cpp:440
size_t size() const
Function call syntax to get the value with var() notation.
Definition value.cpp:264
sigc::signal< void > m_signal_changed
Signal emitted when underlying data is changed.
Definition value.h:273
Type m_clips_type
Stores the CLIPS type information.
Definition value.h:270
void * as_address() const
Definition value.cpp:129
Value & set(float x, bool change_type=false)
Definition value.cpp:140
bool operator!=(float x) const
Definition value.cpp:396
bool operator==(float x) const
Definition value.cpp:352
double as_float() const
Definition value.cpp:96
void deallocate_storage()
Definition value.cpp:475
sigc::signal< void > signal_changed()
Signal emitted when the value is changed.
Definition value.cpp:471
Value()
Typeless constructor.
Definition value.cpp:25
long long int as_integer() const
Definition value.cpp:107
~Value()
Destructor.
Definition value.cpp:92
Type set_type(Type type)
Sets the underlying storage type.
Definition value.cpp:444
Value & operator=(float x)
Allows assignment to the property from the contained value type.
Definition value.cpp:283
std::string & as_string() const
Definition value.cpp:118
Definition activation.cpp:29
std::vector< Value > Values
Definition value.h:278
Type
Definition value.h:29
@ TYPE_SYMBOL
Definition value.h:33
@ TYPE_UNKNOWN
Definition value.h:30
@ TYPE_INSTANCE_NAME
Definition value.h:37
@ TYPE_STRING
Definition value.h:34
@ TYPE_INTEGER
Definition value.h:32
@ TYPE_EXTERNAL_ADDRESS
Definition value.h:35
@ TYPE_FLOAT
Definition value.h:31
@ TYPE_INSTANCE_ADDRESS
Definition value.h:36
#define CLIPSPointer
Definition pointer.h:28

Generated on Wed Jan 24 2024 00:00:00 for clipsmm by doxygen 1.10.0