#ifndef IELEMENT_H #define IELEMENT_H ///////////////////////////////////////////////////////////////////// // IElement.h - Abstract base class defines interface for // // ver 2.0 building tagged, attributed element strings. // // // // Language: Visual Studio.Net, using standard C++ // // Platform: Dell Dimension 8100, Windows 2000, SP 2 // // Application: Demonstration of Programming to Interface for // // CSE687, Spring 2003 // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // ///////////////////////////////////////////////////////////////////// /* Module Operation: ================= The IElement class provides an interface for creating simple tagged, attributed elements with string bodies, similar to that used with XML and HTML. When bound to the Element class, its product is of the form: some text Class interface: ================ IElement& e1 = *CreateElement("aTag"); e1.addAttribute("name","value"); e1.addBody("some text"); string elementString = e1.makeElement(); Note: - It is the user's responsibility to delete element objects created with the CreateElment(...) function. - You can see IElement and Element in action by looking at the test stubs in IElement.cpp and Element.cpp. */ ///////////////////////////////////////////////////////////////////// // Build Process // ///////////////////////////////////////////////////////////////////// // Required Files: // // IElement.h // // // // Build Process: // // This is an abstract class, so there is no build. // // // ///////////////////////////////////////////////////////////////////// /* Maintenance History: ==================== ver 2.0 : 01/24/06 - cosmetic changes to these comments ver 1.0 : 01/20/03 - first release */ // #include struct IElement { /////////////////////////////////////////////////////////////////// // Factory function so client does not have to include Element.h static IElement* CreateElement(const std::string &tag); /////////////////////////////////////////////////////////////////// // Pure virtual functions must be overridden by derived classes. virtual void addAttribute( const std::string &name, const std::string &value ) = 0; virtual void addBody(const std::string &body) = 0; virtual std::string makeElement() = 0; /////////////////////////////////////////////////////////////////// // virtual destructors are needed in all base classes. virtual ~IElement() {} }; // Note: The client, in IElement.cpp, includes this header to define // the IElement interface, but does not include the concrete // header Element.h. Therefore it sees none of the Element // implementation, and will not break if Element implementation // in Element.cpp changes. #endif