/** * proxy.h * Implemented by Blueprint Technologies, Inc. */ #ifndef _proxy_h #define _proxy_h /** * Defines a common interface for RealSubject and Proxy * so that a Proxy can be used anywhere a RealSubject * is expected. */ class Subject { public: virtual void request() = 0; }; /** * Defines the real object that the proxy represents. */ class RealSubject: public Subject { public: virtual void request() { // Do something. }; }; /** * Maintains a reference so that lets the proxy access the * real subject. Proxy may refer to a Subject if the RealSubject * and Subject interfaces are the same. Provides an interface * identical to Subject's so that a proxy can be substituted * for the real subject.Controls access to the real subject and * may be responsible for creating and deleting it. */ class Proxy: public Subject { private: RealSubject* subject; public: virtual void request() { /** * This is overly simplified. The connection to the * real subject may be over a network, into a database, etc. */ subject -> request(); }; /** * Accessors. */ RealSubject* getSubject() { return subject; }; void setSubject( RealSubject* subject ) { this -> subject = subject; }; }; #endif