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