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_Address_H
00037 #define MPS_Address_H
00038
00039 namespace MPS {
00040
00041 /**
00042 * Represents a resolved name for an object.
00043 */
00044 class Address {
00045 private:
00046 string transport; ///< The name of the transport this address refers to
00047 vector<string> params; ///< Vector of transport-specific parameters for this address
00048
00049 /// Splits a resolved name string into its constituent parts.
00050 vector<string> splitResolvedName(string const &resolvedName);
00051
00052 /// Sets this to be equivalent to the resolved name passed in.
00053 void become(string const &resolvedName);
00054
00055 /// Scope the assignment operator as "private". It's deliberately unimplemented.
00056 Address const &operator=(Address const &other);
00057
00058 public:
00059 /// Initialise this from the resolved name string passed in.
00060 Address(string const &resolvedName) {
00061 become(resolvedName);
00062 }
00063
00064 /// Copy constructor
00065 Address(Address const &other)
00066 : transport(other.transport),
00067 params(other.params)
00068 {}
00069
00070 string getResolvedName() const; ///< Return the connection spec as a string
00071 string getTransport() const { return transport; } ///< Return the transport name
00072
00073 /// Return the count of parameters in the connection spec
00074 int getParamCount() const { return params.size(); }
00075
00076 /// Return a parameter string
00077 string getParam(unsigned int index) const {
00078 if (index >= params.size())
00079 return "";
00080 else
00081 return params[index];
00082 }
00083
00084 /// Modify a parameter string
00085 void setParam(unsigned int index, string const &value) {
00086 if (index >= params.size())
00087 params.resize(index + 1);
00088 params[index] = value;
00089 }
00090 };
00091
00092 }
00093
00094 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001