#ifndef INTERFACE_H #define INTERFACE_H ///////////////////////////////////////////////////////////////////// // interface.h - provides protocol for clients to use with // // component classes // // // // Language: Visual C++, version 6.0, sp5 // // Platform: Dell Dimension 8100, Windows 2000 sp2 // // Application: CSE791 - Distributed Objects // // Demonstration of Programming to Interface // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // ///////////////////////////////////////////////////////////////////// /* Component Operations: ===================== This component supports the announce interface, declared in this file. It provides means for a client to create either one of two derived class objects and a protocol for the client to use them. The protocol supports an announce function that identifies itself on std::cout. Interface Functions: ==================== announce::registerObjects(); // register avail. objs announce *ptr ptr = announce::makeObj(announce::type(1)); // create one of them ptr->announcer("some string"); // use it delete ptr; // delete it */ // ///////////////////////////////////////////////////////////////////// // component build process // ///////////////////////////////////////////////////////////////////// // Required Files: // // - creatable.h, interface.h, component.h, component.cpp // // // // To Build component dll: // // - create Win32 Dynamic-Link Library project // // - add all the files cited above to the project // // - click on Project\Settings\C/C++ and select Code Generation // // in the Category comboBox. Select component project in tree // // view and select Debug Multithreaded DLL in the list view. // // in the use run-time library comboBox. // // - click on Build\build component.dll // // - copy component.dll and component.lib into client\debug // // you need to do this every time you rebuild the component // // // // To Build client.exe: // // - create Win32 console application // // - add client.cpp and component.lib to the project // // - click on Project\Settings\C/C++ and select Code Generation // // in the Category comboBox. Select client project in tree // // view and select Debug Multithreaded DLL in the list view. // // in the use run-time library comboBox. // // - click on Build\build client.exe // // - click on Build\Execute client.exe // // // // Note: // // This project uses no multithreaded processing. However, when // // building a dll it is essential that you use the dll form of // // the C and C++ libraries for both client and dll, and selecting // // Debug Multithreaded dll causes that to happen. If you forget // // this step, certain uses of the dynamic memory manager will // // cause a process crash. // // // ///////////////////////////////////////////////////////////////////// /* Maintenance History =================== ver 1.0 : 14 Jan 2002 - first release */ // ///////////////////////////////////////////////////////////////////// // declare dll exports if included by component (defines IN_DLL) // declare dll imports in client (does not define IN_DLL) #ifdef IN_DLL #define DLL_DECL __declspec(dllexport) #else #define DLL_DECL __declspec(dllimport) #endif #pragma warning(disable : 4786) #include "creatable.h" ///////////////////////////////////////////////////////////////////// // announce abstract class declaration // - provides protocol for derived classes announce1 and announce2 class announce : private objFactory { public: virtual DLL_DECL ~announce() { } virtual DLL_DECL void setString(const char *s) = 0; virtual DLL_DECL void announcer() = 0; static DLL_DECL void registerObjects(); static DLL_DECL std::string type(int n); static DLL_DECL announce* makeObj(classID id); }; //----< create an object using inherited objFactory >---------------- inline DLL_DECL announce* announce::makeObj(classID id) { return objFactory::makeObj(id); } #endif