util/ServerRef.cpp

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      ServerRef.cpp
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 Comment:   Holding serverRef address string and protocol string to
00006            access XmlBlaster
00007 Version:   $Id: ServerRef.cpp 16474 2007-09-06 22:34:23Z laghi $
00008 ------------------------------------------------------------------------------*/
00009 
00019 #include <util/ServerRef.h>
00020 #include <string>
00021 
00022 using namespace std;
00023 
00024 namespace org { namespace xmlBlaster { namespace util {
00025 
00026 ServerRef::ServerRef(const ServerRef& serverRef)
00027 {
00028    type_    = serverRef.type_;
00029    address_ = serverRef.address_;
00030 }
00031 
00032 ServerRef& ServerRef::operator =(const ServerRef& serverRef)
00033 {
00034    type_    = serverRef.type_;
00035    address_ = serverRef.address_;
00036    return *this;
00037 }
00038 
00039 
00040 ServerRef::ServerRef(const string& type, const string& address)
00041 {
00042    type_ = type;
00043    address_ = address;
00044 }
00045 
00046 void ServerRef::setAddress(const string& address)
00047 {
00048    address_ = address;
00049 }
00050 
00051 string ServerRef::getAddress() const
00052 {
00053    return address_;
00054 }
00055 
00056 string ServerRef::getType() const
00057 {
00058    return type_;
00059 }
00060 
00061 string ServerRef::toXml() const
00062 {
00063    return toXml("");
00064 }
00065 
00066 string ServerRef::toXml(const string& extraOffset) const
00067 {
00068    string ret = "";
00069    string offset = "\n   ";
00070    offset += extraOffset;
00071 
00072    ret += offset + "<serverRef type='" + getType() + "'>";
00073    ret += offset + "   " + getAddress();
00074    ret += offset + "</serverRef>";
00075 
00076    return ret;
00077 }
00078 
00079 }}} // namespaces
00080 
00081 
00082 #ifdef _XMLBLASTER_CLASSTEST
00083 
00084 #include <util/ServerRef.h>
00085 #include <string>
00086 
00087 using namespace org::xmlBlaster::util;
00088 
00090 int main()
00091 {
00092    try {
00093       ServerRef ref("IOR", "IOR:000102111000");
00094       std::cout << ref.toXml() << std::endl;
00095    }
00096    catch(...) {
00097       std::cerr << " an exception occured" << std::endl;
00098    }
00099 }
00100 
00101 #endif