blob: 3f368cb61ec7243929b60ecc9baa657d63cfbdea [file] [log] [blame]
Zhenkai Zhu8d935c82012-03-06 10:44:12 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012 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 * 卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
20 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
Zhenkai Zhu1ac6f802012-03-06 17:40:27 -080023#ifndef SYNC_APP_DATA_FETCH_H
24#define SYNC_APP_DATA_FETCH_H
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080025
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080026#include "sync-ccnx-wrapper.h"
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080027
28namespace Sync {
29
30/**
31 * \ingroup sync
32 * @brief fetch application data, by default it will try to fetch every piece
33 * of data
34 */
35class AppDataFetch
36{
37public:
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080038 /**
39 * @brief Constructor
40 * @param ccnxHandle handle for CCNx
41 * @param dataCallback the callback function to process data
42 */
43 AppDataFetch (CcnxWrapperPtr ccnxHandle,
44 CcnxWrapper::DataCallback dataCallback)
45 : m_ccnxHandle (ccnxHandle)
46 , m_dataCallback (dataCallback)
47 { }
Zhenkai Zhu46b26a12012-03-06 13:51:16 -080048
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080049 /**
50 * @brief Set data callback
51 * @param dataCallback the callback function to process data
52 */
53 void
54 setDataCallback(CcnxWrapper::DataCallback dataCallback)
55 {
56 m_dataCallback = dataCallback;
57 }
Zhenkai Zhu46b26a12012-03-06 13:51:16 -080058
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080059 /**
60 * @brief Fetch data for a certain name prefix
61 *
62 * @param prefix the prefix for the data
63 * @param startSeq the start of sequence number range (inclusive)
64 * @param endSeq the end of sequence number range (inclusive)
65 */
66 void
67 fetch (const std::string &prefix, uint32_t startSeq, uint32_t endSeq);
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080068
69private:
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080070 CcnxWrapperPtr m_ccnxHandle;
71 CcnxWrapper::DataCallback m_dataCallback;
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080072};
73
74
75} // Sync
76
Zhenkai Zhu1ac6f802012-03-06 17:40:27 -080077#endif // SYNC_APP_DATA_FETCH_H