blob: 1172698df55e5bf487e6e858fb2d7b49ed63679d [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 }
23
24 return false;
25}
26
27std::ostream&
28operator<<(std::ostream& os, const WaitingListEntry& we)
29{
30 os << "-------------Wiating List Entry-------------" << std::endl;
31 os << "Responsible Certificate: " << we.getResponsibleCert() << std::endl;
32 std::list<std::string> waitee = we.getWaitingCerts();
33 int i = 1;
34 for (std::list<std::string>::iterator it = waitee.begin();
35 it != waitee.end(); ++i, ++it)
36 {
37 os << "Waite " << i << ": " << *(it) << std::endl;
38 }
39 return os;
40}
41}//namespace nlsr