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 {
37 } Type;
38 
42  class Value: public sigc::trackable {
43  public:
44 
46  Value (Type type);
47 
49  Value( float x );
50 
52  Value( double x );
53 
55  Value( short int x );
56 
58  Value( unsigned short int x );
59 
61  Value( int x );
62 
64  Value( unsigned int x );
65 
67  Value( long int x );
68 
70  Value( char* x, Type type=TYPE_STRING );
71 
73  Value( const std::string& x, Type type=TYPE_STRING );
74 
76  Value( void* x, Type type=TYPE_EXTERNAL_ADDRESS );
77 
78  Value( const Value& value );
79 
81  ~Value();
82 
83  double as_float() const;
84  long int as_integer() const;
85  std::string& as_string() const;
86  void* as_address() const;
87 
88  Value& set( float x, bool change_type=false );
89  Value& set( double x, bool change_type=false );
90  Value& set( short int x, bool change_type=false );
91  Value& set( unsigned short int x, bool change_type=false );
92  Value& set( int x, bool change_type=false );
93  Value& set( unsigned int x, bool change_type=false );
94  Value& set( long int x, bool change_type=false );
95  Value& set( const std::string& x, bool change_type=false, Type type=TYPE_STRING );
96  Value& set( const char* x, bool change_type=false, Type type=TYPE_STRING );
97  Value& set( void* x, bool change_type=false, Type type=TYPE_EXTERNAL_ADDRESS );
98 
99  operator float( ) const;
100  operator double( ) const;
101  operator short int( ) const;
102  operator unsigned short int( ) const;
103  operator int( ) const;
104  operator unsigned int( ) const;
105  operator long int( ) const;
106  operator std::string&( ) const;
107  operator const char*( ) const;
108  operator void*( ) const;
109 
111 // T& operator() () const { return this->get(); }
112 
114 // Value<T,CLIPSType>& operator() ( const T& val ) {
115 // this->set( val );
116 // return *this;
117 // }
118 
120 // const std::type_info& type_info() const { return typeid( T ); }
121 
126  size_t size() const;
127 
129 // Value<T,CLIPSType>& operator= ( const T& val ) {
130 // this->set( val );
131 // return *this;
132 // }
133 
134  Value& operator=( float x );
135  Value& operator=( double x );
136  Value& operator=( short int x );
137  Value& operator=( unsigned short int x );
138  Value& operator=( int x );
139  Value& operator=( unsigned int x );
140  Value& operator=( long int x );
141  Value& operator=( const std::string& x );
142  Value& operator=( const char* x );
143  Value& operator=( void* x );
144  Value& operator=( const Value& x );
145 
146  bool operator==( float x ) const;
147  bool operator==( double x ) const;
148  bool operator==( short int x ) const;
149  bool operator==( unsigned short int x ) const;
150  bool operator==( int x ) const;
151  bool operator==( unsigned int x ) const;
152  bool operator==( long int x ) const;
153  bool operator==( const std::string& x ) const;
154  bool operator==( const char* x ) const;
155  bool operator==( void* x ) const;
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!=( const std::string& x ) const;
165  bool operator!=( const char* x ) const;
166  bool operator!=( void* x ) const;
167 
177 // template <typename X>
178 // Value& operator+=( X other ) {
179 // this->set( this->get() + other );
180 // return *this;
181 // }
182 
192 // template <typename X>
193 // Value& operator-=( X other ) {
194 // this->set( this->get() - other );
195 // return *this;
196 // }
197 
207 // template <typename X>
208 // Value& operator*=( X other ) {
209 // this->set( this->get() * other );
210 // return *this;
211 // }
212 
222 // template <typename X>
223 // Value& operator/=( X other ) {
224 // this->set( this->get() / other );
225 // return *this;
226 // }
227 
237 // template <typename X>
238 // Value& operator%=( X other ) {
239 // this->set( this->get() % other );
240 // return *this;
241 // }
242 
244  Type type() const;
245 
247  Type set_type( Type type );
248 
250  sigc::signal<void> signal_changed();
251 
252  protected:
254  void* m_value;
255 
258 
260  sigc::signal<void> m_signal_changed;
261 
262  void deallocate_storage();
263  };
264 
265  typedef std::vector<Value> Values;
266 
267 }
268 
269 #endif

Generated on Thu Sep 27 2012 17:57:05 for clipsmm by doxygen 1.8.1.2