blob: 1e428605c1e5eb768510aaa9004c08549283113e [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>
Chaoyi Bian3e1eb162012-04-03 16:59:32 -070019 * Chaoyi Bian <bcy@pku.edu.cn>
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080020 * 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"
Alexander Afanasyev750d1872012-03-12 15:33:56 -070027#include "sync-seq-no.h"
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080028
29namespace Sync {
30
31/**
32 * \ingroup sync
33 * @brief fetch application data, by default it will try to fetch every piece
34 * of data
35 */
36class AppDataFetch
37{
38public:
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080039 /**
40 * @brief Constructor
41 * @param ccnxHandle handle for CCNx
42 * @param dataCallback the callback function to process data
43 */
44 AppDataFetch (CcnxWrapperPtr ccnxHandle,
45 CcnxWrapper::DataCallback dataCallback)
46 : m_ccnxHandle (ccnxHandle)
47 , m_dataCallback (dataCallback)
48 { }
Zhenkai Zhu46b26a12012-03-06 13:51:16 -080049
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080050 /**
51 * @brief Set data callback
52 * @param dataCallback the callback function to process data
53 */
54 void
55 setDataCallback(CcnxWrapper::DataCallback dataCallback)
56 {
57 m_dataCallback = dataCallback;
58 }
Zhenkai Zhu46b26a12012-03-06 13:51:16 -080059
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080060 /**
Alexander Afanasyev750d1872012-03-12 15:33:56 -070061 * @brief Fired from SyncLogic when new data is available
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080062 *
63 * @param prefix the prefix for the data
Alexander Afanasyev750d1872012-03-12 15:33:56 -070064 * @param newSeq old session ID/sequence number
65 * @param oldSeq new session ID/sequence number
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080066 */
67 void
Alexander Afanasyev750d1872012-03-12 15:33:56 -070068 onUpdate (const std::string &prefix, const SeqNo &newSeq, const SeqNo &oldSeq);
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080069
Alexander Afanasyev750d1872012-03-12 15:33:56 -070070 /**
71 * @brief Fired from SyncLogic when data is removed
72 *
73 * @param prefix the prefix for the data
74 */
75 void
76 onRemove (const std::string &prefix);
77
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080078private:
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080079 CcnxWrapperPtr m_ccnxHandle;
80 CcnxWrapper::DataCallback m_dataCallback;
Zhenkai Zhu8d935c82012-03-06 10:44:12 -080081};
82
83
84} // Sync
85
Zhenkai Zhu1ac6f802012-03-06 17:40:27 -080086#endif // SYNC_APP_DATA_FETCH_H