SmartFoxServer 2X C++ API
BaseVariable.h
1 // ===================================================================
2 //
3 // Description
4 // Contains the definition of BaseVariable
5 //
6 // Revision history
7 // Date Description
8 // 30-Nov-2016 First version
9 //
10 // ===================================================================
11 #ifndef __BaseVariable__
12 #define __BaseVariable__
13 
14 #if defined(_MSC_VER)
15 #pragma warning(disable:4786) // STL library: disable warning 4786; this warning is generated due to a Microsoft bug
16 #endif
17 #include <string> // STL library: string object
18 using namespace std; // STL library: declare the STL namespace
19 
20 #include "../../Util/Common.h"
21 #include "Variable.h"
22 #include "VariableType.h"
23 #include "../Data/ISFSObject.h"
24 #include "../Data/ISFSArray.h"
25 #include "../Data/SFSArray.h"
26 #include "../Data/SFSObject.h"
27 #include "../../Exceptions/SFSError.h"
28 
29 #include <boost/shared_ptr.hpp> // Boost Asio shared pointer
30 
31 namespace Sfs2X {
32 namespace Entities {
33 namespace Variables {
34 
35  // -------------------------------------------------------------------
36  // Class BaseVariable
37  // -------------------------------------------------------------------
38 
47  class DLLImportExport BaseVariable : public Variable
48  {
49  public:
50 
51  // -------------------------------------------------------------------
52  // Public methods
53  // -------------------------------------------------------------------
54 
64  BaseVariable(string name, boost::shared_ptr<void> val, long int type);
65 
74  BaseVariable(string name, boost::shared_ptr<long int> val);
75  BaseVariable(string name, boost::shared_ptr<unsigned long int> val);
76  BaseVariable(string name, boost::shared_ptr<int> val);
77  BaseVariable(string name, boost::shared_ptr<unsigned int> val);
78  BaseVariable(string name, boost::shared_ptr<bool> val);
79  BaseVariable(string name, boost::shared_ptr<double> val);
80  BaseVariable(string name, boost::shared_ptr<string> val);
81  BaseVariable(string name, boost::shared_ptr<SFSObject> val);
82  BaseVariable(string name, boost::shared_ptr<SFSArray> val);
83 
84  virtual ~BaseVariable();
85 
87  virtual boost::shared_ptr<string> Name();
88 
90  virtual VariableType Type();
91 
93  virtual boost::shared_ptr<void> Value();
94 
96  virtual boost::shared_ptr<bool> GetBoolValue();
97 
99  virtual boost::shared_ptr<long int> GetIntValue();
100 
102  virtual boost::shared_ptr<double> GetDoubleValue();
103 
105  virtual boost::shared_ptr<string> GetStringValue();
106 
108  virtual boost::shared_ptr<ISFSObject> GetSFSObjectValue();
109 
111  virtual boost::shared_ptr<ISFSArray> GetSFSArrayValue();
112 
114  virtual bool IsNull();
115 
116  virtual boost::shared_ptr<ISFSArray> ToSFSArray();
117 
118  boost::shared_ptr<string> TypeAsString();
119  boost::shared_ptr<string> ValueAsString();
120 
121  // -------------------------------------------------------------------
122  // Public members
123  // -------------------------------------------------------------------
124 
125  protected:
126 
127  // -------------------------------------------------------------------
128  // Protected methods
129  // -------------------------------------------------------------------
130 
131  // -------------------------------------------------------------------
132  // Protected members
133  // -------------------------------------------------------------------
134 
135  private:
136 
137  // -------------------------------------------------------------------
138  // Private methods
139  // -------------------------------------------------------------------
140 
141  void PopulateArrayWithValue(boost::shared_ptr<ISFSArray> arr);
142  void SetValue(boost::shared_ptr<long int> val);
143  void SetValue(boost::shared_ptr<unsigned long int> val);
144  void SetValue(boost::shared_ptr<int> val);
145  void SetValue(boost::shared_ptr<unsigned int> val);
146  void SetValue(boost::shared_ptr<bool> val);
147  void SetValue(boost::shared_ptr<double> val);
148  void SetValue(boost::shared_ptr<string> val);
149  void SetValue(boost::shared_ptr<SFSObject> val);
150  void SetValue(boost::shared_ptr<SFSArray> val);
151 
152  // -------------------------------------------------------------------
153  // Private members
154  // -------------------------------------------------------------------
155 
157  boost::shared_ptr<string> name;
158 
160  VariableType type;
161 
163  boost::shared_ptr<void> val;
164  };
165 
166 } // namespace Variables
167 } // namespace Entities
168 } // namespace Sfs2X
169 
170 #endif
The Variable interface defines all the default public methods and properties that an object represent...
Definition: Variable.h:25
STL namespace.
The BaseVariable object is the base class for all SmartFoxServer Variable entities on the client...
Definition: BaseVariable.h:47
Definition: SmartFox.cpp:24