1.1 --- a/lemon/glpk.h Thu Dec 10 09:14:47 2009 +0100
1.2 +++ b/lemon/glpk.h Sun Feb 14 23:12:59 2010 +0100
1.3 @@ -25,16 +25,28 @@
1.4
1.5 #include <lemon/lp_base.h>
1.6
1.7 -// forward declaration
1.8 -#if !defined _GLP_PROB && !defined GLP_PROB
1.9 -#define _GLP_PROB
1.10 -#define GLP_PROB
1.11 -typedef struct { double _opaque_prob; } glp_prob;
1.12 -/* LP/MIP problem object */
1.13 -#endif
1.14 -
1.15 namespace lemon {
1.16
1.17 + namespace _solver_bits {
1.18 + class VoidPtr {
1.19 + private:
1.20 + void *_ptr;
1.21 + public:
1.22 + VoidPtr() : _ptr(0) {}
1.23 +
1.24 + template <typename T>
1.25 + VoidPtr(T* ptr) : _ptr(reinterpret_cast<void*>(ptr)) {}
1.26 +
1.27 + template <typename T>
1.28 + VoidPtr& operator=(T* ptr) {
1.29 + _ptr = reinterpret_cast<void*>(ptr);
1.30 + return *this;
1.31 + }
1.32 +
1.33 + template <typename T>
1.34 + operator T*() const { return reinterpret_cast<T*>(_ptr); }
1.35 + };
1.36 + }
1.37
1.38 /// \brief Base interface for the GLPK LP and MIP solver
1.39 ///
1.40 @@ -43,8 +55,7 @@
1.41 class GlpkBase : virtual public LpBase {
1.42 protected:
1.43
1.44 - typedef glp_prob LPX;
1.45 - glp_prob* lp;
1.46 + _solver_bits::VoidPtr lp;
1.47
1.48 GlpkBase();
1.49 GlpkBase(const GlpkBase&);
1.50 @@ -122,9 +133,9 @@
1.51 public:
1.52
1.53 ///Pointer to the underlying GLPK data structure.
1.54 - LPX *lpx() {return lp;}
1.55 + _solver_bits::VoidPtr lpx() {return lp;}
1.56 ///Const pointer to the underlying GLPK data structure.
1.57 - const LPX *lpx() const {return lp;}
1.58 + _solver_bits::VoidPtr lpx() const {return lp;}
1.59
1.60 ///Returns the constraint identifier understood by GLPK.
1.61 int lpxRow(Row r) const { return rows(id(r)); }