blob: 37caf6ddf2a203270cf5c7a377da543bf5fb25cb [file] [log] [blame]
akmhoquefa8ee9b2014-03-14 09:06:24 -05001#include <iostream>
2#include <list>
3#include <ndn-cpp-dev/face.hpp>
4#include "nlsr_wle.hpp"
5
akmhoque05d5fcf2014-04-15 14:58:45 -05006#define THIS_FILE "nlsr_wle.cpp"
7
akmhoquefa8ee9b2014-03-14 09:06:24 -05008namespace 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 {
akmhoque05d5fcf2014-04-15 14:58:45 -050019 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() )
akmhoquefa8ee9b2014-03-14 09:06:24 -050022 {
akmhoque05d5fcf2014-04-15 14:58:45 -050023 m_waitingCerts.push_back(waiteeName);
akmhoquefa8ee9b2014-03-14 09:06:24 -050024 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}