lemon/glpk.h
changeset 956 4dd3dc8eb5a7
parent 833 d2bc45e8f6f2
child 1063 1782aa72495a
equal deleted inserted replaced
12:3fec802e7cf5 13:957a705a7244
     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-2010
     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); }
   122     struct FreeEnvHelper {
   122     struct FreeEnvHelper {
   123       ~FreeEnvHelper() {
   123       ~FreeEnvHelper() {
   124         freeEnv();
   124         freeEnv();
   125       }
   125       }
   126     };
   126     };
   127     
   127 
   128     static FreeEnvHelper freeEnvHelper;
   128     static FreeEnvHelper freeEnvHelper;
   129 
   129 
   130   protected:
   130   protected:
   131     
   131 
   132     int _message_level;
   132     int _message_level;
   133     
   133 
   134   public:
   134   public:
   135 
   135 
   136     ///Pointer to the underlying GLPK data structure.
   136     ///Pointer to the underlying GLPK data structure.
   137     _solver_bits::VoidPtr lpx() {return lp;}
   137     _solver_bits::VoidPtr lpx() {return lp;}
   138     ///Const pointer to the underlying GLPK data structure.
   138     ///Const pointer to the underlying GLPK data structure.