1 /*------------------------------------------------------------------------------
  2 Name:      ServerRef.cpp
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 Comment:   Holding serverRef address string and protocol string to
  6            access XmlBlaster
  7 Version:   $Id: ServerRef.cpp 16474 2007-09-06 22:34:23Z laghi $
  8 ------------------------------------------------------------------------------*/
  9 
 10 /**
 11  * Helper class holding serverRef address string and protocol string.
 12  * <p />
 13  * Holds example a CORBA "IOR:00012..." string
 14  * @version $Revision: 1.6 $
 15  * @author xmlBlaster@marcelruff.info
 16  * @author michele@laghi.eu
 17  */
 18 
 19 #include <util/ServerRef.h>
 20 #include <string>
 21 
 22 using namespace std;
 23 
 24 namespace org { namespace xmlBlaster { namespace util {
 25 
 26 ServerRef::ServerRef(const ServerRef& serverRef)
 27 {
 28    type_    = serverRef.type_;
 29    address_ = serverRef.address_;
 30 }
 31 
 32 ServerRef& ServerRef::operator =(const ServerRef& serverRef)
 33 {
 34    type_    = serverRef.type_;
 35    address_ = serverRef.address_;
 36    return *this;
 37 }
 38 
 39 
 40 ServerRef::ServerRef(const string& type, const string& address)
 41 {
 42    type_ = type;
 43    address_ = address;
 44 }
 45 
 46 void ServerRef::setAddress(const string& address)
 47 {
 48    address_ = address;
 49 }
 50 
 51 string ServerRef::getAddress() const
 52 {
 53    return address_;
 54 }
 55 
 56 string ServerRef::getType() const
 57 {
 58    return type_;
 59 }
 60 
 61 string ServerRef::toXml() const
 62 {
 63    return toXml("");
 64 }
 65 
 66 string ServerRef::toXml(const string& extraOffset) const
 67 {
 68    string ret = "";
 69    string offset = "\n   ";
 70    offset += extraOffset;
 71 
 72    ret += offset + "<serverRef type='" + getType() + "'>";
 73    ret += offset + "   " + getAddress();
 74    ret += offset + "</serverRef>";
 75 
 76    return ret;
 77 }
 78 
 79 }}} // namespaces
 80 
 81 
 82 #ifdef _XMLBLASTER_CLASSTEST
 83 
 84 #include <util/ServerRef.h>
 85 #include <string>
 86 
 87 using namespace org::xmlBlaster::util;
 88 
 89 /** For testing: java org.xmlBlaster.util.qos.address.ServerRef */
 90 int main()
 91 {
 92    try {
 93       ServerRef ref("IOR", "IOR:000102111000");
 94       std::cout << ref.toXml() << std::endl;
 95    }
 96    catch(...) {
 97       std::cerr << " an exception occured" << std::endl;
 98    }
 99 }
100 
101 #endif


syntax highlighted by Code2HTML, v. 0.9.1