akmhoque | fa8ee9b | 2014-03-14 09:06:24 -0500 | [diff] [blame] | 1 | #include <iostream> |
| 2 | #include <list> |
| 3 | #include <ndn-cpp-dev/face.hpp> |
| 4 | #include "nlsr_wle.hpp" |
| 5 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 6 | #define THIS_FILE "nlsr_wle.cpp" |
| 7 | |
akmhoque | fa8ee9b | 2014-03-14 09:06:24 -0500 | [diff] [blame] | 8 | namespace nlsr |
| 9 | { |
| 10 | static bool |
| 11 | waiteeCompare(std::string& w1, std::string& w2) |
| 12 | { |
| 13 | return w1 == w2 ; |
| 14 | } |
| 15 | |
| 16 | bool |
| 17 | WaitingListEntry::addWaitee(std::string waiteeName) |
| 18 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 19 | std::list<std::string>::iterator it = std::find_if( m_waitingCerts.begin(), |
| 20 | m_waitingCerts.end(),ndn::bind(&waiteeCompare, _1, waiteeName)); |
| 21 | if( it == m_waitingCerts.end() ) |
akmhoque | fa8ee9b | 2014-03-14 09:06:24 -0500 | [diff] [blame] | 22 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 23 | m_waitingCerts.push_back(waiteeName); |
akmhoque | fa8ee9b | 2014-03-14 09:06:24 -0500 | [diff] [blame] | 24 | return true; |
| 25 | } |
| 26 | |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | std::ostream& |
| 31 | operator<<(std::ostream& os, const WaitingListEntry& we) |
| 32 | { |
| 33 | os<<"-------------Wiating List Entry-------------"<<std::endl; |
| 34 | os<<"Responsible Certificate: "<<we.getResponsibleCert()<<std::endl; |
| 35 | std::list<std::string> waitee=we.getWaitingCerts(); |
| 36 | int i=1; |
| 37 | for(std::list<std::string>::iterator it=waitee.begin(); |
| 38 | it!=waitee.end(); ++i, ++it) |
| 39 | { |
| 40 | os<<"Waite "<<i<<": "<<*(it)<<std::endl; |
| 41 | } |
| 42 | return os; |
| 43 | } |
| 44 | } |