NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-api-face.h
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2013 University of California, Los Angeles
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19  * Zhenkai Zhu <zhenkai@cs.ucla.edu>
20  * Chaoyi Bian <bcy@pku.edu.cn>
21  */
22 
23 #ifndef NDN_API_FACE_H
24 #define NDN_API_FACE_H
25 
26 #include <ns3/ptr.h>
27 #include <ns3/node.h>
28 #include <ns3/callback.h>
29 #include <ns3/ndn-face.h>
30 #include <ns3/ndn-name.h>
31 #include <ns3/ndn-interest.h>
32 #include <ns3/ndn-data.h>
33 
34 namespace ns3 {
35 namespace ndn {
36 
37 class ApiFacePriv;
38 
51 class ApiFace
52  : public ns3::ndn::Face
53 {
54 public:
55  typedef Callback<void, Ptr<const Name>, Ptr<const Interest> > InterestCallback;
56  typedef Callback<void, Ptr<const Interest>, Ptr<const Data> > DataCallback;
57  typedef Callback<void, Ptr<const Interest> > TimeoutCallback;
58 
64  ApiFace (Ptr<Node> node);
65  ~ApiFace ();
66 
70  virtual void
71  Shutdown ();
72 
80  void
81  ExpressInterest (Ptr<Interest> interest,
82  DataCallback onData,
83  TimeoutCallback onTimeout); // = MakeNullCallback< void, Ptr<Interest> > ()
84 
91  void
92  SetInterestFilter (Ptr<const Name> prefix, InterestCallback onInterest);
93 
98  void
99  ClearInterestFilter (Ptr<const Name> prefix);
100 
105  void
106  Put (Ptr<Data> data);
107 
108 public:
109  virtual bool
110  SendInterest (Ptr<const Interest> interest);
111 
112  virtual bool
113  SendData (Ptr<const Data> data);
114 
115  virtual std::ostream&
116  Print (std::ostream &os) const;
117 
118 private:
119  ApiFace () : Face (0) {}
120  ApiFace (const ApiFace &) : Face (0) {}
121  ApiFace& operator= (const ApiFace &) { return *this; }
122 
123 private:
124  ApiFacePriv *m_this;
125 };
126 
127 } // ndn
128 } // ns3
129 
130 #endif // NDN_API_HANDLER_H
void ExpressInterest(Ptr< Interest > interest, DataCallback onData, TimeoutCallback onTimeout)
Express Interest.
Virtual class defining NDN face.
Definition: ndn-face.h:58
virtual bool SendData(Ptr< const Data > data)
Send out Dat packet through the face.
void ClearInterestFilter(Ptr< const Name > prefix)
clear Interest filter
virtual bool SendInterest(Ptr< const Interest > interest)
Send out interest through the face.
void Put(Ptr< Data > data)
Publish data.
An application NDN face, providing richer API interface, compared to ndn::AppFace.
Definition: ndn-api-face.h:51
Face(Ptr< Node > node)
Default constructor.
Definition: ndn-face.cc:69
virtual void Shutdown()
Shutdown the API face.
Definition: ndn-api-face.cc:84
void SetInterestFilter(Ptr< const Name > prefix, InterestCallback onInterest)
set Interest filter (specify what interest you want to receive)
virtual std::ostream & Print(std::ostream &os) const
Print information about the face into the stream.