From 5f3cb0bf02ed32976370cf6c7f656d000b4d7694 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Fri, 15 Jun 2012 11:26:32 +1000 Subject: Re-write heaps of code to work better. --- impl/VariableAssignment.hpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'impl/VariableAssignment.hpp') diff --git a/impl/VariableAssignment.hpp b/impl/VariableAssignment.hpp index 9d8137a..e0f7dc8 100644 --- a/impl/VariableAssignment.hpp +++ b/impl/VariableAssignment.hpp @@ -1,17 +1,29 @@ #ifndef VARIABLE_ASSIGNMENT_HPP #define VARIABLE_ASSIGNMENT_HPP -#include "Variable.hpp" +#include "Expression.hpp" #include "IdMap.hpp" -template -struct VariableAssignment : public IdMap,T> { - VariableAssignment(unsigned int length) - : IdMap,T>(length, -infinity()) { } - VariableAssignment(unsigned int length, const T& initial) - : IdMap,T>(length, initial) { } - VariableAssignment(const VariableAssignment& other) - : IdMap,T>(other) { } +template +struct VariableAssignment { + virtual ~VariableAssignment() { } + virtual const Domain& operator[](const Variable&) const = 0; +}; + +template +struct StableVariableAssignment +: public VariableAssignment, public IdMap, Domain> { + StableVariableAssignment(unsigned int length) + : IdMap,Domain>(length, -infinity()) { } + StableVariableAssignment(unsigned int length, const Domain& value) + : IdMap,Domain>(length, value) { } + + const Domain& operator[](const Variable& var) const { + return IdMap,Domain>::operator[](var); + } + Domain& operator[](const Variable& var) { + return IdMap,Domain>::operator[](var); + } }; #endif -- cgit v1.2.3