/home/coin/SVN-release/OS-2.3.2/ApplicationTemplates/branchCutPrice/Member/OS_packer.cpp

Go to the documentation of this file.
00001 /* $Id: OS_packer.cpp 2698 2009-06-09 04:14:07Z kmartin $ */
00002 // Last edit: 5/20/07
00003 //
00004 // Name:     OS_packer.cpp
00005 // Author:   Francois Margot
00006 //           Tepper School of Business
00007 //           Carnegie Mellon University, Pittsburgh, PA 15213
00008 //           email: fmargot@andrew.cmu.edu
00009 // Date:     5/18/07
00010 //-----------------------------------------------------------------------------
00011 // Copyright (C) 2007, Francois Margot, IBM and others.  All Rights Reserved.
00012 
00013 #include "BCP_buffer.hpp"
00014 #include "OS_cut.hpp"
00015 #include "OS_var.hpp"
00016 #include "OS_user_data.hpp"
00017 #include "OS_packer.hpp"
00018 
00019 using namespace std;
00020 
00021 /****************************************************************************/
00022 
00023 void OS_packer::pack_cut_algo(const BCP_cut_algo* cut, BCP_buffer& buf) {
00024         // we don't have indexed cuts so simplify
00025  // int typ;
00026   const OS_cut* bb_cut = dynamic_cast<const OS_cut*>(cut);
00027   //if (bb_cut) {
00028    // typ = 1;
00029    // buf.pack(typ);
00030  // std::cout << "INSIDE pack_cut_algo " << std::endl;
00031     bb_cut->pack(buf);
00032     return;
00033   //}
00034   throw BCP_fatal_error("OS_pack_cut(): unknown cut type.");
00035 }
00036 
00037 /****************************************************************************/
00038 
00039 BCP_cut_algo*  OS_packer::unpack_cut_algo(BCP_buffer& buf)
00040 {
00041         // we don't have indexed cuts so simplify
00042         //int typ;
00043         //buf.unpack(typ);
00044         //switch (typ) {
00045         //case 0:
00046         //      throw BCP_fatal_error("OS_unpack_cut(): unknown cut type.");
00047     //return new OS_indexed_cut(buf);
00048         //case 1:
00049         //std::cout << "INSIDE unpack_cut_algo " << std::endl;
00050         
00051         return new OS_cut( buf);
00052         //default:
00053         //      throw BCP_fatal_error("OS_unpack_cut(): unknown cut type.");
00054    // break;
00055  // }
00056   //return NULL; // fake return
00057 }
00058 
00059 
00060 
00061 void OS_packer::pack_var_algo(const BCP_var_algo* var, BCP_buffer& buf) {
00062 
00063     const OS_var* v = dynamic_cast<const OS_var*>(var);
00064     // don't worry about type, only one kind of variable
00065         //int type = 0;
00066         //buf.pack( type);
00067 
00068         v->pack( buf);
00069         return;
00070 
00071 }
00072 
00073 /*---------------------------------------------------------------------------*/
00074 
00075 BCP_var_algo* OS_packer::unpack_var_algo(BCP_buffer& buf) {
00076 
00077         
00078    // int type;
00079    // buf.unpack( type);
00080     
00081     return new OS_var(  buf);
00082 
00083 }
00084 
00085 
00086 
00087 /****************************************************************************/
00088 
00089 void  OS_packer::pack_user_data(const BCP_user_data* ud, BCP_buffer& buf)
00090 // Normally, no modifications required.
00091 {
00092   const MY_user_data *mud = dynamic_cast<const MY_user_data*> (ud);
00093   if(!mud)
00094     throw BCP_fatal_error("OS_lp::pack_user_data() : unknown data type!\n");
00095   
00096   printf("OS_lp::pack_user_data:\n");
00097   mud->print();
00098   mud->pack(buf);
00099 }
00100 
00101 /****************************************************************************/
00102 
00103 BCP_user_data*  OS_packer::unpack_user_data(BCP_buffer& buf)
00104   // Normally, no modifications required.
00105 {
00106   MY_user_data *p_ud = new MY_user_data(buf);
00107   printf("OS_lp::unpack_user_data:\n");
00108   p_ud->print();
00109 
00110   if (p_ud->is_processed) {
00111     p_ud->p_rud = NULL;
00112     delete(p_ud);
00113     p_ud = NULL;
00114     printf("user_data deleted\n");
00115   }
00116 
00117   return(p_ud); 
00118 }

Generated on Fri Jan 7 03:24:38 2011 by  doxygen 1.4.7