blob: a174ea8128d601c116436bab89a710bc8638743e (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#ifndef VARIABLE_HPP
#define VARIABLE_HPP
#include <string>
#include "Operator.hpp"
template<typename T>
struct Variable : public Operator<T> {
Variable(unsigned int id, const std::string& name)
: _id(id), _name(name) { }
Variable(const Variable& other)
: _id(other._id) { }
unsigned int id() const {
return _id;
}
std::string name() const {
return _name;
}
//T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass) const {
virtual T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& assignment) const {
//assert(args.size() == 0)
return assignment[*this];
}
private:
const unsigned int _id;
const std::string _name;
};
template<typename T>
std::ostream& operator<<(std::ostream& cout, const Variable<T>& v) {
cout << v.name() << "(" << v.id() << ")";
return cout;
}
#endif
|