/home/coin/SVN-release/OS-2.4.2/Bcp/src/Member/BCP_warmstart_pack.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #include "BCP_warmstart_dual.hpp"
00005 #include "BCP_warmstart_primaldual.hpp"
00006 #include "BCP_warmstart_basis.hpp"
00007 #include "BCP_buffer.hpp"
00008 #include "BCP_error.hpp"
00009 
00010 void
00011 BCP_pack_warmstart(const BCP_warmstart* ws, BCP_buffer& buf)
00012 {
00013    const BCP_warmstart_basis* wsb =
00014       dynamic_cast<const BCP_warmstart_basis*>(ws);
00015    if (wsb) {
00016       const int type = 1;
00017       buf.pack(type);
00018       wsb->pack(buf);
00019       return;
00020    }
00021 
00022    const BCP_warmstart_dual* wsd =
00023       dynamic_cast<const BCP_warmstart_dual*>(ws);
00024    if (wsd) {
00025       const int type = 2;
00026       buf.pack(type);
00027       wsd->pack(buf);
00028       return;
00029    }
00030 
00031    const BCP_warmstart_primaldual* wspd =
00032       dynamic_cast<const BCP_warmstart_primaldual*>(ws);
00033    if (wspd) {
00034       const int type = 3;
00035       buf.pack(type);
00036       wspd->pack(buf);
00037       return;
00038    }
00039 
00040    const int type = 0;
00041    buf.pack(type);
00042 }
00043 
00044 BCP_warmstart*
00045 BCP_unpack_warmstart(BCP_buffer& buf)
00046 {
00047    int type;
00048    buf.unpack(type);
00049    switch (type) {
00050    case 0: return NULL;
00051    case 1: return new BCP_warmstart_basis(buf);
00052    case 2: return new BCP_warmstart_dual(buf);
00053    case 3: return new BCP_warmstart_primaldual(buf);
00054    default:
00055       throw BCP_fatal_error("Unknown warmstart in BCP_unpack_warmstart.\n");
00056    }
00057    return 0;
00058 }

Generated on Wed Nov 30 03:03:50 2011 by  doxygen 1.4.7