#ifndef __LINK_DESCRIPTOR_H #define __LINK_DESCRIPTOR_H #include #include #include #include #include #include "ariba/utility/messages.h" #include "ariba/utility/types.h" #include "ariba/CommunicationListener.h" namespace ariba { class CommunicationListener; } using std::deque; using ariba::utility::Message; using ariba::utility::NodeID; using ariba::utility::SpoVNetID; using ariba::utility::ServiceID; using ariba::utility::LinkID; using ariba::CommunicationListener; namespace ariba { namespace overlay { class LinkDescriptor; std::ostream& operator<<(std::ostream& s, const LinkDescriptor* ld ); std::ostream& operator<<(std::ostream& s, const LinkDescriptor& ld ); /// LinkDescriptor class LinkDescriptor { public: // ctor LinkDescriptor() { // default values this->up = false; this->dropWhenRelaysLeft = false; this->fromRemote = false; this->remoteNode = NodeID::UNSPECIFIED; this->overlayId = LinkID::UNSPECIFIED; this->communicationUp = false; this->communicationId = LinkID::UNSPECIFIED; this->keepAliveTime = time(NULL); this->keepAliveMissed = 0; this->usedAsRelay = false; this->timeUsedAsRelay = time(NULL); this->service = ServiceID::UNSPECIFIED; this->listener = &CommunicationListener::DEFAULT; this->relay = false; this->localRelay = NodeID::UNSPECIFIED; this->remoteRelay = NodeID::UNSPECIFIED; this->remoteLinkId = LinkID::UNSPECIFIED; this->autolink = false; this->lastuse = time(NULL); } // dtor ~LinkDescriptor() { flushQueue(); } // general information about the link --------------------------------- bool up; ///< flag wheter this link is up and running bool dropWhenRelaysLeft; bool fromRemote; /// messageQueue; ///< waiting messages to be delivered /// updates the timestamp void markAsUsed() { lastuse = time(NULL); } /// drops waiting messsages void flushQueue() { BOOST_FOREACH( Message* msg, messageQueue ) delete msg; messageQueue.clear(); } std::string to_string() const { std::ostringstream s; s << "up=" << up << " "; s << "fromRem=" << fromRemote << " "; s << "remNode=" << remoteNode.toString().substr(0,6) << " "; s << "serv=" << service.toString() << " "; s << "overId=" << overlayId.toString().substr(0,6) << " "; s << "commId=" << communicationId.toString().substr(0,6) << " "; s << "usedAsRel=" << usedAsRelay << " "; s << "KeepAliveMiss=" << keepAliveMissed << " "; if ( !localRelay.isUnspecified() ) { s << "locRel=" << localRelay.toString().substr(0,6) << " "; s << "remRel=" << remoteRelay.toString().substr(0,6) << " "; s << "remLink=" << remoteLinkId.toString().substr(0,6) << " "; } s << "auto=" << autolink; return s.str(); } }; }} // namespace ariba, overlay #endif // __LINK_DESCRIPTOR_H