lemon/glpk.h
branch1.1
changeset 803 79f149ee0230
parent 711 5100072d83ca
equal deleted inserted replaced
10:49f5eecb5cad 11:2c406e6c0109
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2008
     5  * Copyright (C) 2003-2011
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
    28 namespace lemon {
    28 namespace lemon {
    29 
    29 
    30   namespace _solver_bits {
    30   namespace _solver_bits {
    31     class VoidPtr {
    31     class VoidPtr {
    32     private:
    32     private:
    33       void *_ptr;      
    33       void *_ptr;
    34     public:
    34     public:
    35       VoidPtr() : _ptr(0) {}
    35       VoidPtr() : _ptr(0) {}
    36 
    36 
    37       template <typename T>
    37       template <typename T>
    38       VoidPtr(T* ptr) : _ptr(reinterpret_cast<void*>(ptr)) {}
    38       VoidPtr(T* ptr) : _ptr(reinterpret_cast<void*>(ptr)) {}
    39 
    39 
    40       template <typename T>
    40       template <typename T>
    41       VoidPtr& operator=(T* ptr) { 
    41       VoidPtr& operator=(T* ptr) {
    42         _ptr = reinterpret_cast<void*>(ptr); 
    42         _ptr = reinterpret_cast<void*>(ptr);
    43         return *this;
    43         return *this;
    44       }
    44       }
    45 
    45 
    46       template <typename T>
    46       template <typename T>
    47       operator T*() const { return reinterpret_cast<T*>(_ptr); }
    47       operator T*() const { return reinterpret_cast<T*>(_ptr); }
   121     struct FreeEnvHelper {
   121     struct FreeEnvHelper {
   122       ~FreeEnvHelper() {
   122       ~FreeEnvHelper() {
   123         freeEnv();
   123         freeEnv();
   124       }
   124       }
   125     };
   125     };
   126     
   126 
   127     static FreeEnvHelper freeEnvHelper;
   127     static FreeEnvHelper freeEnvHelper;
   128 
   128 
   129   protected:
   129   protected:
   130     
   130 
   131     int _message_level;
   131     int _message_level;
   132     
   132 
   133   public:
   133   public:
   134 
   134 
   135     ///Pointer to the underlying GLPK data structure.
   135     ///Pointer to the underlying GLPK data structure.
   136     _solver_bits::VoidPtr lpx() {return lp;}
   136     _solver_bits::VoidPtr lpx() {return lp;}
   137     ///Const pointer to the underlying GLPK data structure.
   137     ///Const pointer to the underlying GLPK data structure.