blob: 6b839049de48eaec894f24cfa15c8f72b2adcc30 [file] [log] [blame]
akmhoque53353462014-04-22 08:43:45 -05001#include <iostream>
2#include <list>
3#include <ndn-cpp-dev/face.hpp>
4#include "waiting-list-entry.hpp"
5
6namespace nlsr {
7static bool
8waiteeCompare(std::string& w1, std::string& w2)
9{
10 return w1 == w2 ;
11}
12
13bool
14WaitingListEntry::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 }
akmhoque53353462014-04-22 08:43:45 -050023 return false;
24}
25
26std::ostream&
27operator<<(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