Variable.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef H_DC_VARIABLE_INLCUDED
34 #define H_DC_VARIABLE_INLCUDED
35 
36 #include <Dynacoe/Util/Chain.h>
37 #include <Dynacoe/Util/Vector.h>
38 #include <string>
39 
40 namespace Dynacoe {
41 
42 
50 class Variable {
51  public:
52 
55  enum class Type {
56  Boolean,
57  Int,
58  Float,
59  Vector,
60  String,
61  Address,
62  Unknown
63  };
64 
65 
69  Variable();
70  Variable(const std::string & name, bool & v);
71  Variable(const std::string & name, int & v);
72  Variable(const std::string & name, float & v);
73  Variable(const std::string & name, std::string & v);
74  Variable(const std::string & name, void * v);
75  Variable(const std::string & name, Vector & v);
77 
78  friend bool operator<(const Variable &, const Variable & );
79 
82  std::string GetName();
83 
86  Type GetType();
87 
90  std::string ToString();
91 
97  void Set(const std::string &);
98 
99 
100  private:
101 
102  std::string name;
103  void * data;
104  Type type;
105 
106 
107 };
108 
109 bool operator<(const Variable &, const Variable &);
110 }
111 
112 
113 #endif
Error type. Set only when the variable is built with the default constructor and never Set...
3D and 2D positional vector.
Definition: Vector.h:55
Definition: AssetID.h:37
std::string GetName()
reutrns the name of the variable.
std::string ToString()
Returns a text reduction of the variable.
Type GetType()
Returns the type of the variable.
Abstraction for a variable in Dynacoe.
Definition: Variable.h:50
void Set(const std::string &)
Attempts to set the value of the Variable to the value denoted by the string. The function will guess...
Type
The type of the variable represented.
Definition: Variable.h:55