#include #include #include "agddHasName.hh" #include "agddSection.hh" #include "agddAGDD.hh" #include "ExpatInterface/Element.h" #include "agddAttribute.hh" namespace agdd { Section::Section() : HasName(), KnowsDTDVersion(), Buildable("section"), _version ("version" , Attribute::required), _date ("date" , Attribute::required), _author ("author" , Attribute::required), _topVolAtt("top_volume", Attribute::required), _topVolPtr(0) { cout << "Should have just initialised any section member elements etc" << endl; setDate(); }; void Section::basicBuild() { cout << "Starting basic section build ... " << endl; makeTheElement(); nameThisElement(theElement()); versionThisElement(theElement()); _version .addAttributeTo(theElement()); _date .addAttributeTo(theElement()); _author .addAttributeTo(theElement()); _topVolAtt.addAttributeTo(theElement()); // LESTER Must complete ... add checks // Lastly the children. assert(_topVolPtr); // The next line is, perhaps, the most important line in the program. _topVolPtr->putMyselfIn(this); cout << "done basic section build." << endl; }; void Section::howToBuildMe() { basicBuild(); }; void Section::putMyselfIn(AGDD * const agdd) { cout << "Starting section put me in" << endl; assert(agdd); xml::Element * const parent = agdd->theElement(); assert(parent); basicBuild(); parent->addChild(theElement()); cout << "done section put me in." << endl; }; void Section::setVersion(const string & s) { _version.setValue(s); }; void Section::setDate() { time_t t=time(0); string s(ctime(&t)); // Get rid of annoying "\n" at end of s: s.resize(s.size()-1); _date.setValue(s); }; void Section::setAuthor(const string & authorName) { _author.setValue(authorName); }; // ATT Must Complete void Section::setTopVol(Volume * volume) { _topVolPtr = volume; _topVolAtt.setValue( volume->getName() ); }; // Section & Section::setEnvelope(); // ATT Can complete when this is // defined in the dtd. } // end of agdd namespace