00001 /* -*- c++ -*- */
00002 /**************************************************************************
00003 Copyright (c) 2000-2001, Tony Garnock-Jones
00004 All rights reserved.
00005
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are
00008 met:
00009
00010 * Redistributions of source code must retain the above copyright
00011 notice, this list of conditions and the following disclaimer.
00012
00013 * Redistributions in binary form must reproduce the above
00014 copyright notice, this list of conditions and the following
00015 disclaimer in the documentation and/or other materials provided
00016 with the distribution.
00017
00018 * Neither the names of the copyright holders nor the names of this
00019 software's contributors may be used to endorse or promote
00020 products derived from this software without specific prior
00021 written permission.
00022
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
00027 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00028 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00029 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00030 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00031 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00032 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 **************************************************************************/
00035
00036 #ifndef MPS_Interface_H
00037 #define MPS_Interface_H
00038
00039 namespace MPS {
00040
00041 class InterfaceServer;
00042
00043 /**
00044 * Base class which all MPS Interfaces (implementations and proxies)
00045 * must inherit from. */
00046 class Interface: public Referenceable {
00047 private:
00048 /// Server that is presenting bound addresses for this interface
00049 InterfaceServer *interfaceServer;
00050
00051 /// If we are a proxy, this holds the bound address of the server we are proxying for
00052 string remoteAddress;
00053
00054 friend class InterfaceServer; // allow access to _setInterfaceServer.
00055
00056 /// Called by InterfaceServer::InterfaceServer. Yes, cleaner solutions do exist.
00057 void _setInterfaceServer(InterfaceServer *s) {
00058 if (interfaceServer)
00059 throw MPSException("_setInterfaceServer called when interfaceServer already non-zero");
00060 interfaceServer = s;
00061 }
00062
00063 protected:
00064 /// Called by auto-generated subclasses of Proxy, in their constructors. See gencpp.cc.
00065 void _setRemoteAddress(string const &addr) {
00066 remoteAddress = addr;
00067 }
00068
00069 public:
00070 Interface()
00071 : interfaceServer(0),
00072 remoteAddress()
00073 {}
00074
00075 virtual ~Interface() {}
00076
00077 /**
00078 * Retrieve the server object that is providing access to this
00079 * instance of Interface, or 0 if this Interface isn't (yet) managed
00080 * by an InterfaceServer. */
00081 InterfaceServer *_getInterfaceServer() const { return interfaceServer; }
00082
00083 /**
00084 * Returns the address of the remote object that we are using, or
00085 * the empty-string if we are not a proxy for some remote object
00086 * (ie we really do implement this interface locally). */
00087 string const &_getRemoteAddress() const { return remoteAddress; }
00088 };
00089
00090 }
00091
00092 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001