static const char *NAME = "consequence"; //===========================// //== This software is ==// //== (c)opyrighted in 1993 ==// //== by Chris Koeritz ==// //== cak0l@Virginia.EDU ==// //===========================// #include "consequence.h" #include "basics.h" #include "guards.h" #include consequence::consequence() {} consequence::~consequence() {} int consequence::well_formed() const { if (!this->outcome::well_formed()) return FALSE; // guarantee 1. if (!this->result::well_formed()) return FALSE; // guarantee 2. } /* byte *consequence::pack(int &size) const { int packed_outcome_size; if (!well_formed()) deadly_error(NAME, "pack", "consequence is not well formed."); int ressize; byte *packed_outcome = this->outcome::pack(packed_outcome_size); byte *packed_result = this->result::pack(ressize); size = packed_outcome_size + ressize; size += 2 * sizeof(int); byte *to_return = new byte[size]; typed_copy(&packed_outcome_size, to_return, int); int temp = is_this_failure; typed_copy(&temp, to_return + sizeof(int), int); byte *to_stuff = to_return + 2 * sizeof(int); mcopy(packed_outcome, to_stuff, packed_outcome_size); to_stuff += packed_outcome_size; mcopy(packed_result, to_stuff, ressize); return to_return; } consequence *consequence_unpack(byte *packed_form) { int packed_outcome_size; typed_copy(packed_form, &packed_outcome_size, int); consequence *to_return = new consequence; typed_copy(packed_form + sizeof(int), to_return->is_this_failure, int); byte *to_stuff = packed_form + 2 * sizeof(int); outcome *temp = outcome_unpack(to_stuff); *(outcome *)to_return = *temp; delete temp; to_stuff += packed_outcome_size; result *temp2 = result_unpack(to_stuff); *(result *)to_return = *temp2; delete temp2; if (!to_return->well_formed()) deadly_error(NAME, "unpack constructor", "badly formed pack"); return to_return; } */ void consequence::print() const { cout << "[ consequence has outcome:" << flush; outcome::print(); cout << "and has result:" << flush; result::print(); cout << "]" << endl; } string consequence::name() const { return my_name; } void consequence::name(const string &new_name) { my_name = new_name; }