NodeID.h

Go to the documentation of this file.
00001 /* ex: set tabstop=4 expandtab: */
00002 /*                                                                                                                      */
00003 /*  (c) 2004-2006 Iowa State University                                         */
00004 /*      see the LICENSE file in the top level directory         */
00005 /*                                                                                                                      */
00006 /* $Header: /afs/scl/project/cvsroot/fountain/source/common/NodeID.h,v 1.13 2006/02/19 21:59:39 samm Exp $ */
00010 
00011 #ifndef NODEID__H__
00012 #define NODEID__H__
00013 
00014 #include "define.h"
00015 #include "FountainErrors.h"
00016 #include <string>
00017 #include <ostream>
00018 
00025 class NodeID {
00026         private:
00028                 std::string ID_;
00029         
00031                 std::string hostname_;
00032         
00034                 int listenPort_;
00035                 
00036         public:
00040                 NodeID(const std::string& ID);
00041                 
00045                 NodeID(const std::string& hostname, int listenPort);
00046                 
00048                 NodeID(const NodeID& rhs) : ID_(rhs.ID_), hostname_(rhs.hostname_), listenPort_(rhs.listenPort_) {}
00049                 
00051                 const NodeID& operator=(const NodeID& rhs);
00052                 
00054                 inline operator std::string() const { return ID_; }
00055                 
00057                 inline operator const char*() const { return ID_.c_str(); }
00058                 
00061                 const std::string& getHostname() const { return hostname_; };
00062                 
00065                 int getListenPort() const { return listenPort_; };
00066                 
00071                 bool operator==(const NodeID& rhs) const { return (ID_.compare(rhs.ID_) == 0); };
00072                 
00077                 bool operator!=(const NodeID& rhs) const { return (ID_.compare(rhs.ID_) != 0); };
00078                 
00083                 bool operator<(const NodeID& rhs) const { return ID_ < rhs.ID_; };
00084                 
00086         friend std::ostream& operator<<(std::ostream& output, const NodeID& _node);
00087 };
00088 
00089 #endif

Generated on Wed Mar 8 14:43:31 2006 for Fountain by  doxygen 1.4.6