BB_user_data.cpp
Go to the documentation of this file.
1 // Last edit: 5/19/07
2 //
3 // Name: BB_user_data.cpp
4 // Author: Francois Margot
5 // Tepper School of Business
6 // Carnegie Mellon University, Pittsburgh, PA
7 // email: fmargot@andrew.cmu.edu
8 // Date: 12/28/03
9 //-----------------------------------------------------------------------------
10 // Copyright (C) 2003, Francois Margot. All Rights Reserved.
11 
12 #include "BCP_buffer.hpp"
13 #include "BB_user_data.hpp"
14 
15 using namespace std;
16 
17 /****************************************************************************/
18  MY_user_data::MY_user_data(const int max_size)
19  : is_processed(0) {
20 
21  // Normally, no modifications required, except possibly modifying
22  // the parameters to the constructor
23 
24  p_rud = new real_user_data(max_size);
25 }
26 
27 /****************************************************************************/
29 {
30  // Normally, no modifications required.
31 
32  buf.unpack(is_processed);
33  buf.unpack(p_rud);
34 }
35 
36 /****************************************************************************/
38 
39  // Normally, no modifications required.
40 
41  if(is_processed && (p_rud != NULL)) {
42  delete p_rud;
43  p_rud = NULL;
44  }
45 }
46 
47 /****************************************************************************/
48 void
50 {
51  // Normally, no modifications required.
52 
53  buf.pack(is_processed);
54  buf.pack(p_rud);
55 } /* pack */
56 
57 
58 /****************************************************************************/
59 void
61 {
62  // Normally, no modifications required.
63 
64  printf("is_processed: %d\n", is_processed);
65  if(p_rud != NULL) {
66  p_rud->print();
67  }
68 } /* print */
69 
70 
71 /****************************************************************************/
72 real_user_data::real_user_data(const int max_size) {
73 
74  /* Add : initialize fields of real_user_data */
75 
76  max_card_set_zero = max_size;
77  card_set_zero = 0;
78  set_zero = new int[max_card_set_zero];
79 }
80 
81 /****************************************************************************/
83 
84  /* Add : deletion of complex fields in real_user_data */
85 
86  delete[] set_zero;
87 }
88 
89 /****************************************************************************/
90 void
92 
93  /* Add : print fields of real_user_data */
94 
95  printf("max_card_set_zero: %d\n", max_card_set_zero);
96  printf("card_set_zero: %d\n", card_set_zero);
97  if(card_set_zero > 0) {
98  printf("set_zero:\n");
99  for(int i=0; i<card_set_zero; i++) {
100  printf(" %4d", set_zero[i]);
101  }
102  printf("\n");
103  }
104  printf("\n");
105 } /* print */
BCP_buffer & pack(const T &value)
Pack a single object of type T.
Definition: BCP_buffer.hpp:177
BCP_buffer & unpack(T &value)
Unpack a single object of type T.
Definition: BCP_buffer.hpp:186
real_user_data(const int max_size)
Constructor.
~MY_user_data()
Destructor.
int * set_zero
Variables that have been set to zero by branching decisions.
void print() const
Dump the fields of the class.
void print() const
Dump the fields of the class.
MY_user_data(const int max_size)
Initial constructor.
real_user_data * p_rud
Pointer on an object holding the user data itself.
void pack(BCP_buffer &buf) const
Packing to buffer.
int card_set_zero
Number of variables set to zero by branching descisions.
Class handling user data.
int is_processed
Indicator for mmory management: If is_processed = 1, the associated user data may be erased...
~real_user_data()
Desctructor.
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
int max_card_set_zero
Maximum number of variables that may be set to zero by branching decisions.