Line data Source code
1 : /* 2 : * A simple representation of a nexthop entry: the nexthop string and 3 : * its current state in the Nexthop DB. Used to send nexthop notifications 4 : * to registered clients. 5 : */ 6 : #ifndef _AGENT_NHS_NEXTHOP_ENTRY_H_ 7 : #define _AGENT_NHS_NEXTHOP_ENTRY_H_ 8 : 9 : #include <boost/array.hpp> 10 : #include <boost/asio.hpp> 11 : #include <boost/asio/signal_set.hpp> 12 : #include <boost/bind/bind.hpp> 13 : #include <boost/enable_shared_from_this.hpp> 14 : #include <boost/shared_ptr.hpp> 15 : #include <cstdio> 16 : #include <iostream> 17 : 18 : using namespace boost::placeholders; 19 : 20 : class NexthopDBEntry { 21 : 22 : static const int kNexthopEntryOverhead = 32; 23 : 24 : public: 25 : 26 : typedef boost::shared_ptr<NexthopDBEntry> NexthopPtr; 27 : 28 : enum NexthopDBEntryState { 29 : NEXTHOP_STATE_CLEAN, 30 : NEXTHOP_STATE_MARKED, 31 : NEXTHOP_STATE_DELETED 32 : }; 33 : 34 0 : NexthopDBEntry(const std::string& nh) 35 0 : : nexthop_string_(nh) {} 36 : 37 0 : ~NexthopDBEntry() { 38 0 : } 39 : 40 0 : int EncodedLength() { 41 0 : return (nexthop_string_.length() + kNexthopEntryOverhead); 42 : } 43 : 44 0 : void set_state (NexthopDBEntryState state) { 45 0 : state_ = state; 46 0 : } 47 : 48 0 : NexthopDBEntryState state() { 49 0 : return state_; 50 : } 51 : 52 0 : std::string& nexthop_string() { 53 0 : return nexthop_string_; 54 : } 55 : 56 0 : bool operator== (NexthopDBEntry& other) 57 : { 58 0 : return (nexthop_string_ == other.nexthop_string()); 59 : } 60 : 61 : private: 62 : std::string nexthop_string_; 63 : NexthopDBEntryState state_; 64 : }; 65 : 66 : #endif