KIDS  ver-0.0.1
KIDS : Kernel Integrated Dynamics Simulator
Loading...
Searching...
No Matches
Variable.h
Go to the documentation of this file.
1
29#ifndef KIDS_Variable_H
30#define KIDS_Variable_H
31
32#include <vector>
33
34#include "kids/Shape.h"
35
36namespace PROJECT_NS {
37
39 public:
40 virtual std::string name() = 0;
41 virtual std::string doc() = 0;
42
43 static std::vector<VARIABLE_BASE*> _LIST;
44};
45
46inline std::string _subreplace(std::string resource_str, std::string sub_str, std::string new_str) {
47 std::string dst_str = resource_str;
48 std::string::size_type pos = 0;
49 while ((pos = dst_str.find(sub_str)) != std::string::npos) { dst_str.replace(pos, sub_str.length(), new_str); }
50 return dst_str;
51}
52
53template <class T>
54class VARIABLE final : public VARIABLE_BASE {
55 public:
56 VARIABLE(const std::string& name, Shape* shape, const std::string& doc)
57 : _name{_subreplace(name, "::", ".")}, _shape{shape}, _doc{doc} {
58 VARIABLE_BASE::_LIST.push_back(this);
59 }
60
61 std::string name() { return _name; }
62
63 std::string doc() { return _doc; }
64
65 Shape& shape() const { return (*_shape); }
66
67 private:
68 std::string _name;
71 std::string _doc;
72 bool allocated = false;
73};
74
75}; // namespace PROJECT_NS
76
77#endif // KIDS_Variable_H
Declaration of the Shape class.
Shape class provide information about of a Tensor's shape.
Definition Shape.h:50
static std::vector< VARIABLE_BASE * > _LIST
Definition Variable.h:43
virtual std::string doc()=0
virtual std::string name()=0
std::string name()
Definition Variable.h:61
std::string _doc
Definition Variable.h:71
std::string _name
Definition Variable.h:68
std::string doc()
Definition Variable.h:63
VARIABLE(const std::string &name, Shape *shape, const std::string &doc)
Definition Variable.h:56
Shape & shape() const
Definition Variable.h:65
< http://warp.povusers.org/FunctionParser/fparser.html
Definition Context.h:39
std::string _subreplace(std::string resource_str, std::string sub_str, std::string new_str)
Definition Variable.h:46