summaryrefslogtreecommitdiff
path: root/impl/MaxStrategy.hpp
blob: 3005ee2db002e3d2cabb398e3412d175f035e065 (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
36
#ifndef MAX_EXPRESSION_HPP
#define MAX_EXPRESSION_HPP

#include "Expression.hpp"
#include "EquationSystem.hpp"
#include "IdSet.hpp"

template<typename Domain>
struct MaxStrategy {
  virtual ~MaxStrategy() { }
  virtual unsigned int get(const MaxExpression<Domain>& e) const = 0;
};

template<typename Domain>
struct ConcreteMaxStrategy : public MaxStrategy<Domain> {
  ConcreteMaxStrategy(const EquationSystem<Domain>& system)
    : _strategy(system.maxExpressionCount(), 0) {
  }

  unsigned int get(const MaxExpression<Domain>& e) const {
    return _strategy[e];
  }
  unsigned int set(const MaxExpression<Domain>& e, unsigned int i) {
    _strategy[e] = i;
    return i;
  }

  void print(std::ostream& cout) const {
    cout << _strategy << std::endl;
  }

  private:
  IdMap<MaxExpression<Domain>,unsigned int> _strategy;
};

#endif