blob: 1a96582e1b7fdac5143145db396cc454e1bda30c [file] [log] [blame]
Alexander Afanasyevd6c2a902013-01-19 21:24:30 -08001/* -*- 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: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
20 */
21
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070022#include "ndnx-closure.h"
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080023
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070024namespace Ndnx {
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080025
Zhenkai Zhu8339e912013-01-18 18:10:17 -080026Closure::Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback)
Alexander Afanasyevd6c2a902013-01-19 21:24:30 -080027 : m_timeoutCallback (timeoutCallback)
28 , m_dataCallback (dataCallback)
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080029{
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080030}
31
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -080032Closure::~Closure ()
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080033{
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080034}
35
Zhenkai Zhuff4fa8a2013-01-28 22:02:40 -080036void
37Closure::runTimeoutCallback(Name interest, const Closure &closure, Selectors selectors)
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080038{
Zhenkai Zhuff4fa8a2013-01-28 22:02:40 -080039 if (!m_timeoutCallback.empty ())
Alexander Afanasyevd6c2a902013-01-19 21:24:30 -080040 {
Zhenkai Zhuff4fa8a2013-01-28 22:02:40 -080041 m_timeoutCallback (interest, closure, selectors);
Alexander Afanasyevd6c2a902013-01-19 21:24:30 -080042 }
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080043}
44
45
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -080046void
Zhenkai Zhu1888f742013-01-28 12:47:33 -080047Closure::runDataCallback(Name name, PcoPtr content)
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080048{
Alexander Afanasyevd6c2a902013-01-19 21:24:30 -080049 if (!m_dataCallback.empty ())
50 {
51 m_dataCallback (name, content);
52 }
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080053}
54
Alexander Afanasyev816251e2013-01-28 16:16:49 -080055////////////////////////////////////////////////////////////////////////////////////////////////////////
56////////////////////////////////////////////////////////////////////////////////////////////////////////
57////////////////////////////////////////////////////////////////////////////////////////////////////////
58////////////////////////////////////////////////////////////////////////////////////////////////////////
59////////////////////////////////////////////////////////////////////////////////////////////////////////
Zhenkai Zhu1888f742013-01-28 12:47:33 -080060
Alexander Afanasyev816251e2013-01-28 16:16:49 -080061// ExecutorClosure::ExecutorClosure(const Closure &closure, ExecutorPtr executor)
62// : Closure(closure.m_dataCallback, closure.m_timeoutCallback)
63// , m_executor(executor)
64// {
65// }
Zhenkai Zhu1888f742013-01-28 12:47:33 -080066
Alexander Afanasyev816251e2013-01-28 16:16:49 -080067// ExecutorClosure::~ExecutorClosure()
68// {
69// }
Zhenkai Zhu1888f742013-01-28 12:47:33 -080070
Alexander Afanasyev816251e2013-01-28 16:16:49 -080071// void
72// ExecutorClosure::runDataCallback(Name name, PcoPtr content)
73// {
74// m_executor->execute(boost::bind(&Closure::runDataCallback, this, name, content));
75// }
Zhenkai Zhu1888f742013-01-28 12:47:33 -080076
Alexander Afanasyev816251e2013-01-28 16:16:49 -080077// // void
78// // ExecutorClosure::execute(Name name, PcoPtr content)
79// // {
80// // Closure::runDataCallback(name, content);
81// // }
Zhenkai Zhu1888f742013-01-28 12:47:33 -080082
Zhenkai Zhu1888f742013-01-28 12:47:33 -080083
Alexander Afanasyev816251e2013-01-28 16:16:49 -080084////////////////////////////////////////////////////////////////////////////////////////////////////////
85////////////////////////////////////////////////////////////////////////////////////////////////////////
86////////////////////////////////////////////////////////////////////////////////////////////////////////
87////////////////////////////////////////////////////////////////////////////////////////////////////////
88////////////////////////////////////////////////////////////////////////////////////////////////////////
89
90
91// ExecutorInterestClosure::ExecutorInterestClosure(const InterestCallback &callback, ExecutorPtr executor)
92// : m_callback(callback)
93// , m_executor(executor)
94// {
95// }
96
97// void
98// ExecutorInterestClosure::runInterestCallback(Name interest)
99// {
100// m_executor->execute(boost::bind(&ExecutorInterestClosure::execute, this, interest));
101// }
102
103// void
104// ExecutorInterestClosure::execute(Name interest)
105// {
106// if (!m_callback.empty())
107// {
108// m_callback(interest);
109// }
110// }
Zhenkai Zhu19f81de2013-01-04 22:27:47 -0800111
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700112} // Ndnx