00001 /* 00002 * Copyright 2007 Baylor University 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 #ifndef _PROPHET_LINK_FACADE_H_ 00018 #define _PROPHET_LINK_FACADE_H_ 00019 00020 #include <string.h> 00021 #include <string> 00022 00023 #include "AckList.h" 00024 00025 namespace prophet 00026 { 00027 00028 class Link 00029 { 00030 public: 00034 virtual ~Link() {} 00035 00037 virtual const char* nexthop() const = 0; 00038 virtual const char* remote_eid() const = 0; 00039 AckList* acks() { return &acks_; } 00041 00043 virtual bool operator==(const Link* l) const 00044 { return strncmp(nexthop(),l->nexthop(),strlen(nexthop())) == 0; } 00045 virtual bool operator<(const Link* l) const 00046 { return strncmp(nexthop(),l->nexthop(),strlen(nexthop())) < 0; } 00047 virtual bool operator==(const Link& l) const 00048 { return strncmp(nexthop(),l.nexthop(),strlen(nexthop())) == 0; } 00049 virtual bool operator<(const Link& l) const 00050 { return strncmp(nexthop(),l.nexthop(),strlen(nexthop())) < 0; } 00052 00053 protected: 00054 mutable AckList acks_; 00055 00056 }; // class Link 00057 00058 class LinkImpl : public Link 00059 { 00060 public: 00064 LinkImpl(const std::string& nexthop = "") : 00065 next_hop_(nexthop) {} 00066 00070 virtual ~LinkImpl() {} 00071 00073 const char* nexthop() const { return next_hop_.c_str(); } 00074 const char* remote_eid() const { return next_hop_.c_str(); } 00076 00078 void set_nexthop( const std::string& nexthop ) 00079 { 00080 next_hop_.assign(nexthop); 00081 } 00083 00084 protected: 00085 std::string next_hop_; 00086 }; // class LinkImpl 00087 00088 }; // namespace prophet 00089 00090 #endif // _PROPHET_LINK_FACADE_H_