00001 #ifndef OPTFRAME_SOLUTION_HPP_
00002 #define OPTFRAME_SOLUTION_HPP_
00003
00004 #include <cstdlib>
00005 #include <iostream>
00006
00007 using namespace std;
00008
00009 template<class R>
00010 class Solution
00011 {
00012 protected:
00013 R& r;
00014
00015 public:
00016 Solution(R& rr):r(*new R(rr)){};
00017 Solution(const Solution<R>& s):r(*new R(s.r)){}
00018
00019 virtual ~Solution() { delete &r; }
00020
00021 void setR(const R& rr){ r = rr; }
00022
00023 const R& getR() const { return r; }
00024 R& getR() { return r; }
00025
00026 virtual void print() const
00027 {
00028 cout << "Solution: "<< r << endl;
00029 }
00030
00031 virtual Solution<R>& operator= (const Solution<R>& s)
00032 {
00033 if(&s == this)
00034 return *this;
00035
00036 r = s.r;
00037
00038 return *this;
00039 }
00040
00041 virtual Solution<R>& clone() const
00042 {
00043 return * new Solution<R>(*this);
00044 }
00045
00046 };
00047
00048 #endif