BM_var.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2003, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef _BM_VAR_H
00004 #define _BM_VAR_H
00005 
00006 #include "BCP_buffer.hpp"
00007 #include "BCP_var.hpp"
00008 #include "BCP_mempool.hpp"
00009 
00010 class BCP_buffer;
00011 
00012 //#############################################################################
00013     
00014 class BM_branching_var : public BCP_var_algo {
00015 private:
00016     static BCP_MemPool memPool;
00017 public:
00018     static inline void * operator new(size_t size) {
00019         return memPool.alloc(size);
00020     }
00021     static inline void operator delete(void *p, size_t size) {
00022         memPool.free(p, size);
00023     }
00024 
00025 public:
00026     int sos_index;
00027     int split;
00028 
00029 public:
00030     BM_branching_var(int i, int s) : BCP_var_algo(BCP_BinaryVar, 0, 0, 1),
00031                                      sos_index(i), split(s) {}
00032     BM_branching_var(BCP_buffer& buf)  : BCP_var_algo(BCP_BinaryVar, 0, 0, 1) {
00033         buf.unpack(sos_index).unpack(split);
00034     }
00035     ~BM_branching_var() {}
00036     void pack(BCP_buffer& buf) const {
00037         buf.pack(sos_index).pack(split);
00038     }
00039 };
00040 
00041 //#############################################################################
00042     
00043 static inline void
00044 BM_pack_var(const BCP_var_algo* var, BCP_buffer& buf)
00045 {
00046     const BM_branching_var* bv = dynamic_cast<const BM_branching_var*>(var);
00047     if (!bv)
00048         throw BCP_fatal_error("pack_var_algo() : unknown var type!\n");
00049     bv->pack(buf);
00050 }
00051 
00052 static inline BCP_var_algo*
00053 BM_unpack_var(BCP_buffer& buf)
00054 {
00055     return new BM_branching_var(buf);
00056 }
00057 
00058 //#############################################################################
00059     
00060 #endif

Generated on Fri May 16 21:05:57 2008 for Bonmin by  doxygen 1.4.7