TcaEndpointID.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2005-2006 University of Waterloo
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 
00018 #ifndef _TCA_ENDPOINTID_H_
00019 #define _TCA_ENDPOINTID_H_
00020 
00021 
00022 // Warning: 
00023 // There are 2 versions of the TcaEndpointID class, one which is a 
00024 // subclass of EndpointID and is to be used on the servlib side.
00025 // The other is a stand-alone class to be used on the applib side.
00026 // The interface and functionality is otherwise the same.
00027 // It would be nice to merge these into a single class someday.
00028 
00029 
00030 #include <string>
00031 #include "../../servlib/naming/EndpointID.h"
00032 
00033 namespace dtn {
00034 
00035 
00036 class TcaEndpointID : public EndpointID
00037 {
00038 public:
00039     TcaEndpointID() : EndpointID(), host_(""), app_("") { }
00040     TcaEndpointID(const EndpointID& eid);
00041     TcaEndpointID(const std::string& str);
00042     TcaEndpointID(const std::string& host, const std::string& app);
00043     TcaEndpointID(const TcaEndpointID& eid);
00044 
00045     const std::string& host() const { return host_; }
00046     const std::string& app() const { return app_; }
00047     
00048     void set_host(const std::string& host);
00049     void set_app(const std::string& app);
00050 
00051     const std::string get_hostid() const
00052         { return std::string("tca://") + host_; }
00053 
00054     static inline std::string
00055     build(const std::string& host, const std::string& app)
00056         { return std::string("tca://") + host + "/" + app; }
00057     
00058 protected:
00059     // TcaEndpointID caches host part and app part for easy lookup, but
00060     // always maintains the base class strings as well.
00061     std::string host_;
00062     std::string app_;
00063     void parse();
00064 };
00065 
00066 
00067 } // namespace dtn
00068 
00069 #endif /* _TCA_ENDPOINTID_H_ */

Generated on Thu Jun 7 16:56:52 2007 for DTN Reference Implementation by  doxygen 1.5.1