static const char *NAME = "connection"; //===========================// //== This software is ==// //== (c)opyrighted in 1993 ==// //== by Chris Koeritz ==// //== cak0l@Virginia.EDU ==// //===========================// #include "connection.h" #include "guards.h" #include "basics.h" #include connection::connection() { conclusion_that_connection_causes = NIL; connection_link = NIL; } connection::~connection() { if (conclusion_that_connection_causes) delete conclusion_that_connection_causes; conclusion_that_connection_causes = NIL; connection_link = NIL; } void connection::yielder(string &name) { if ((char *)the_yielder) deadly_error(NAME, "yielder", "already set"); the_yielder = name; } string &connection::yielder() const { string *to_return = new string(the_yielder); return *to_return; } void connection::consequence_name(string &name) { if ((char *)conseq_name) deadly_error(NAME, "consequence_name", "already set"); conseq_name = name; } string &connection::consequence_name() const { string *to_return = new string(conseq_name); return *to_return; } string &connection::block() const { string *to_return = new string(block_name); return *to_return; } void connection::block(string &name) { if ((char *)block_name) deadly_error(NAME, "block", "already set"); block_name = name; } conclusion *connection::connected_conclusion() const { return conclusion_that_connection_causes; } void connection::connected_conclusion(conclusion *conclusion_occurs) { if (conclusion_that_connection_causes) deadly_error(NAME, "connected_conclusion", "already set"); conclusion_that_connection_causes = conclusion_occurs; } zeno_tree *connection::link() const { return connection_link; } void connection::link(zeno_tree *link) { if (connection_link) deadly_error(NAME, "link", "already set"); connection_link = link; } int connection::well_formed() const { if (!connection_link) return FALSE; // guarantee 1. // guarantee 2 is vacuously true. // guarantee 3 is vacuously true. if (conseq_name.length() == 0) return FALSE; // guarantee 4. if (the_yielder.length() == 0) return FALSE; // guarantee 5. return TRUE; } void connection::print() const { cout << "[ connection has yielder=" << yielder() << " and conseq name=" << consequence_name() << endl << " and block name=" << block() << endl << " the link is: " << flush; if (link()) link()->print(); else cout << "nil\n" << flush; cout << " the conclusion connected is: " << flush; if (connected_conclusion()) connected_conclusion()->print(); else cout << "nil\n" << flush; cout << "]\n" << flush; }