source: branches/devel/Bonmin/experimental/Bcp/BM_var.hpp @ 26

Last change on this file since 26 was 1, checked in by andreasw, 13 years ago

imported initial code

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 1.5 KB
Line 
1// Copyright (C) 2003, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef _BM_VAR_H
4#define _BM_VAR_H
5
6#include "BCP_buffer.hpp"
7#include "BCP_var.hpp"
8#include "BCP_mempool.hpp"
9
10class BCP_buffer;
11
12//#############################################################################
13   
14class BM_branching_var : public BCP_var_algo {
15private:
16    static BCP_MemPool memPool;
17public:
18    static inline void * operator new(size_t size) {
19        return memPool.alloc(size);
20    }
21    static inline void operator delete(void *p, size_t size) {
22        memPool.free(p, size);
23    }
24
25public:
26    int sos_index;
27    int split;
28
29public:
30    BM_branching_var(int i, int s) : BCP_var_algo(BCP_BinaryVar, 0, 0, 1),
31                                     sos_index(i), split(s) {}
32    BM_branching_var(BCP_buffer& buf)  : BCP_var_algo(BCP_BinaryVar, 0, 0, 1) {
33        buf.unpack(sos_index).unpack(split);
34    }
35    ~BM_branching_var() {}
36    void pack(BCP_buffer& buf) const {
37        buf.pack(sos_index).pack(split);
38    }
39};
40
41//#############################################################################
42   
43static inline void
44BM_pack_var(const BCP_var_algo* var, BCP_buffer& buf)
45{
46    const BM_branching_var* bv = dynamic_cast<const BM_branching_var*>(var);
47    if (!bv)
48        throw BCP_fatal_error("pack_var_algo() : unknown var type!\n");
49    bv->pack(buf);
50}
51
52static inline BCP_var_algo*
53BM_unpack_var(BCP_buffer& buf)
54{
55    return new BM_branching_var(buf);
56}
57
58//#############################################################################
59   
60#endif
Note: See TracBrowser for help on using the repository browser.