#ifndef AGDDBUILDABLEHH #define AGDDBUILDABLEHH #include #include #include "agddHasTag.hh" namespace agdd { class Buildable : public HasTag { private: bool _haveBeenBuiltAlready; public: Buildable(const string & tag) : HasTag(tag), _haveBeenBuiltAlready(false) { }; virtual ~Buildable() {}; private: virtual void howToBuildMe() = 0; public: void buildMe() { if (_haveBeenBuiltAlready) { cerr << "ERROR: An attempt has been made to build a Buildable element " << "which has already been made. " << "Build elements once and once only." << endl; }; assert (!_haveBeenBuiltAlready); howToBuildMe(); _haveBeenBuiltAlready=true; }; void sendMeTo(ostream & os) { if (!_haveBeenBuiltAlready) { cerr << "ERROR: You are trying to send an AGDD element to " << "an output stream without having first built it." << endl; }; assert(_haveBeenBuiltAlready); ostrstream preamble; preamble << "" << endl << ends; theElement()->print(os<