clipsmm - C++ CLIPS Interface Library

clipsmm logo
value.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Rick L. Vinyard, Jr. *
3  * rvinyard@cs.nmsu.edu *
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 
43 class Value: public sigc::trackable {
44  public:
45 
47  Value ();
48 
50  Value (Type type);
51 
53  Value( float x );
54 
56  Value( double x );
57 
59  Value( short int x );
60 
62  Value( unsigned short int x );
63 
65  Value( int x );
66 
68  Value( unsigned int x );
69 
71  Value( long int x );
72 
74  Value( const char* x, Type type=TYPE_STRING );
75 
77  Value( const std::string& x, Type type=TYPE_STRING );
78 
80  Value( void* x, Type type=TYPE_EXTERNAL_ADDRESS );
81 
82  Value( const Value& value );
83 
85  ~Value();
86 
87  double as_float() const;
88  long int as_integer() const;
89  std::string& as_string() const;
90  void* as_address() const;
91 
92  Value& set( float x, bool change_type=false );
93  Value& set( double x, bool change_type=false );
94  Value& set( short int x, bool change_type=false );
95  Value& set( unsigned short int x, bool change_type=false );
96  Value& set( int x, bool change_type=false );
97  Value& set( unsigned int x, bool change_type=false );
98  Value& set( long int x, bool change_type=false );
99  Value& set( const std::string& x, bool change_type=false, Type type=TYPE_STRING );
100  Value& set( const char* x, bool change_type=false, Type type=TYPE_STRING );
101  Value& set( void* x, bool change_type=false, Type type=TYPE_EXTERNAL_ADDRESS );
102 
103  operator float( ) const;
104  operator double( ) const;
105  operator short int( ) const;
106  operator unsigned short int( ) const;
107  operator int( ) const;
108  operator unsigned int( ) const;
109  operator long int( ) const;
110  operator std::string&( ) const;
111  operator const char*( ) const;
112  operator void*( ) const;
113 
115  // T& operator() () const { return this->get(); }
116 
118  // Value<T,CLIPSType>& operator() ( const T& val ) {
119  // this->set( val );
120  // return *this;
121  // }
122 
124  // const std::type_info& type_info() const { return typeid( T ); }
125 
130  size_t size() const;
131 
133  // Value<T,CLIPSType>& operator= ( const T& val ) {
134  // this->set( val );
135  // return *this;
136  // }
137 
138  Value& operator=( float x );
139  Value& operator=( double x );
140  Value& operator=( short int x );
141  Value& operator=( unsigned short int x );
142  Value& operator=( int x );
143  Value& operator=( unsigned int x );
144  Value& operator=( long int x );
145  Value& operator=( const std::string& x );
146  Value& operator=( const char* x );
147  Value& operator=( void* x );
148  Value& operator=( const Value& x );
149 
150  bool operator==( float x ) const;
151  bool operator==( double x ) const;
152  bool operator==( short int x ) const;
153  bool operator==( unsigned short int x ) const;
154  bool operator==( int x ) const;
155  bool operator==( unsigned int x ) const;
156  bool operator==( long int x ) const;
157  bool operator==( const std::string& x ) const;
158  bool operator==( const char* x ) const;
159  bool operator==( void* x ) const;
160 
161  bool operator!=( float x ) const;
162  bool operator!=( double x ) const;
163  bool operator!=( short int x ) const;
164  bool operator!=( unsigned short int x ) const;
165  bool operator!=( int x ) const;
166  bool operator!=( unsigned int x ) const;
167  bool operator!=( long int x ) const;
168  bool operator!=( const std::string& x ) const;
169  bool operator!=( const char* x ) const;
170  bool operator!=( void* x ) const;
171 
181  // template <typename X>
182  // Value& operator+=( X other ) {
183  // this->set( this->get() + other );
184  // return *this;
185  // }
186 
196  // template <typename X>
197  // Value& operator-=( X other ) {
198  // this->set( this->get() - other );
199  // return *this;
200  // }
201 
211  // template <typename X>
212  // Value& operator*=( X other ) {
213  // this->set( this->get() * other );
214  // return *this;
215  // }
216 
226  // template <typename X>
227  // Value& operator/=( X other ) {
228  // this->set( this->get() / other );
229  // return *this;
230  // }
231 
241  // template <typename X>
242  // Value& operator%=( X other ) {
243  // this->set( this->get() % other );
244  // return *this;
245  // }
246 
248  Type type() const;
249 
251  Type set_type( Type type );
252 
254  sigc::signal<void> signal_changed();
255 
256  protected:
258  void* m_value;
259 
262 
264  sigc::signal<void> m_signal_changed;
265 
266  void deallocate_storage();
267 };
268 
269  typedef std::vector<Value> Values;
270 
271 }
272 
273 #endif

Generated on Sat Mar 16 2013 15:13:43 for clipsmm by doxygen 1.8.3