Zhenkai Zhu | 8d935c8 | 2012-03-06 10:44:12 -0800 | [diff] [blame] | 1 | /* -*- 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 Bian | 3e1eb16 | 2012-04-03 16:59:32 -0700 | [diff] [blame] | 19 | * Chaoyi Bian <bcy@pku.edu.cn> |
Zhenkai Zhu | 8d935c8 | 2012-03-06 10:44:12 -0800 | [diff] [blame] | 20 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 21 | */ |
| 22 | |
Zhenkai Zhu | 1ac6f80 | 2012-03-06 17:40:27 -0800 | [diff] [blame] | 23 | #ifndef SYNC_APP_DATA_FETCH_H |
| 24 | #define SYNC_APP_DATA_FETCH_H |
Alexander Afanasyev | 172d2b7 | 2012-03-08 23:43:39 -0800 | [diff] [blame] | 25 | |
Zhenkai Zhu | 8d935c8 | 2012-03-06 10:44:12 -0800 | [diff] [blame] | 26 | #include "sync-ccnx-wrapper.h" |
Alexander Afanasyev | 750d187 | 2012-03-12 15:33:56 -0700 | [diff] [blame] | 27 | #include "sync-seq-no.h" |
Zhenkai Zhu | 8d935c8 | 2012-03-06 10:44:12 -0800 | [diff] [blame] | 28 | |
| 29 | namespace Sync { |
| 30 | |
| 31 | /** |
| 32 | * \ingroup sync |
| 33 | * @brief fetch application data, by default it will try to fetch every piece |
| 34 | * of data |
| 35 | */ |
| 36 | class AppDataFetch |
| 37 | { |
| 38 | public: |
Alexander Afanasyev | 172d2b7 | 2012-03-08 23:43:39 -0800 | [diff] [blame] | 39 | /** |
| 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 Zhu | 46b26a1 | 2012-03-06 13:51:16 -0800 | [diff] [blame] | 49 | |
Alexander Afanasyev | 172d2b7 | 2012-03-08 23:43:39 -0800 | [diff] [blame] | 50 | /** |
| 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 Zhu | 46b26a1 | 2012-03-06 13:51:16 -0800 | [diff] [blame] | 59 | |
Alexander Afanasyev | 172d2b7 | 2012-03-08 23:43:39 -0800 | [diff] [blame] | 60 | /** |
Alexander Afanasyev | 750d187 | 2012-03-12 15:33:56 -0700 | [diff] [blame] | 61 | * @brief Fired from SyncLogic when new data is available |
Alexander Afanasyev | 172d2b7 | 2012-03-08 23:43:39 -0800 | [diff] [blame] | 62 | * |
| 63 | * @param prefix the prefix for the data |
Alexander Afanasyev | 750d187 | 2012-03-12 15:33:56 -0700 | [diff] [blame] | 64 | * @param newSeq old session ID/sequence number |
| 65 | * @param oldSeq new session ID/sequence number |
Alexander Afanasyev | 172d2b7 | 2012-03-08 23:43:39 -0800 | [diff] [blame] | 66 | */ |
| 67 | void |
Alexander Afanasyev | 750d187 | 2012-03-12 15:33:56 -0700 | [diff] [blame] | 68 | onUpdate (const std::string &prefix, const SeqNo &newSeq, const SeqNo &oldSeq); |
Zhenkai Zhu | 8d935c8 | 2012-03-06 10:44:12 -0800 | [diff] [blame] | 69 | |
Alexander Afanasyev | 750d187 | 2012-03-12 15:33:56 -0700 | [diff] [blame] | 70 | /** |
| 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 Zhu | 8d935c8 | 2012-03-06 10:44:12 -0800 | [diff] [blame] | 78 | private: |
Alexander Afanasyev | 172d2b7 | 2012-03-08 23:43:39 -0800 | [diff] [blame] | 79 | CcnxWrapperPtr m_ccnxHandle; |
| 80 | CcnxWrapper::DataCallback m_dataCallback; |
Zhenkai Zhu | 8d935c8 | 2012-03-06 10:44:12 -0800 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | |
| 84 | } // Sync |
| 85 | |
Zhenkai Zhu | 1ac6f80 | 2012-03-06 17:40:27 -0800 | [diff] [blame] | 86 | #endif // SYNC_APP_DATA_FETCH_H |