OS_user_data.cpp
Go to the documentation of this file.
1 /* $Id: OS_user_data.cpp 2698 2009-06-09 04:14:07Z kmartin $ */
2 // Last edit: 5/5/04
3 //
4 // Name: OS_user_data.cpp
5 // Author: Francois Margot
6 // Tepper School of Business
7 // Carnegie Mellon University, Pittsburgh, PA
8 // email: fmargot@andrew.cmu.edu
9 // Date: 12/28/03
10 //-----------------------------------------------------------------------------
11 // Copyright (C) 2003, Francois Margot. All Rights Reserved.
12 
13 #include "BCP_buffer.hpp"
14 #include "OS_user_data.hpp"
15 
16 
17 using namespace std;
18 
19 /****************************************************************************/
20  MY_user_data::MY_user_data(const int max_size)
21  : is_processed(0) {
22 
23  // Normally, no modifications required, except possibly modifying
24  // the parameters to the constructor
25 
26  p_rud = new real_user_data(max_size);
27 }
28 
29 /****************************************************************************/
31 {
32  // Normally, no modifications required.
33 
34  buf.unpack(is_processed);
35  buf.unpack(p_rud);
36 }
37 
38 /****************************************************************************/
40 
41  // Normally, no modifications required.
42 
43  if(is_processed && (p_rud != NULL)) {
44  delete p_rud;
45  p_rud = NULL;
46  }
47 }
48 
49 /****************************************************************************/
50 void
52 {
53  // Normally, no modifications required.
54 
55  buf.pack(is_processed);
56  buf.pack(p_rud);
57 } /* pack */
58 
59 
60 /****************************************************************************/
61 void
62 MY_user_data::print() const
63 {
64  // Normally, no modifications required.
65 
66  printf("is_processed: %d\n", is_processed);
67  if(p_rud != NULL) {
68  p_rud->print();
69  }
70 } /* print */
71 
72 
73 /****************************************************************************/
74 real_user_data::real_user_data(const int max_size) {
75 
76  /* Add : initialize fields of real_user_data */
77 
78  max_card_set_zero = max_size;
79  card_set_zero = 0;
80  set_zero = new int[max_card_set_zero];
81 }
82 
83 /****************************************************************************/
85 
86  /* Add : deletion of complex fields in real_user_data */
87 
88  delete[] set_zero;
89 }
90 
91 /****************************************************************************/
92 void
93 real_user_data::print() const {
94 
95  /* Add : print fields of real_user_data */
96 
97  printf("max_card_set_zero: %d\n", max_card_set_zero);
98  printf("card_set_zero: %d\n", card_set_zero);
99  if(card_set_zero > 0) {
100  printf("set_zero:\n");
101  for(int i=0; i<card_set_zero; i++) {
102  printf(" %4d", set_zero[i]);
103  }
104  printf("\n");
105  }
106  printf("\n");
107 } /* print */
108 
109 
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.