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 
27 namespace CLIPS {
28 
29 typedef enum Type {
38 } Type;
39 
44 class 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 
84  Value( void* x, Type type=TYPE_EXTERNAL_ADDRESS );
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 
260  Type set_type( Type type );
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

Generated on Sat Apr 13 2013 10:04:52 for clipsmm by doxygen 1.8.1.1