Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2016, Regents of the University of California. |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 5 | * This file is part of ChronoShare, a decentralized file sharing application over NDN. |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 7 | * ChronoShare is free software: you can redistribute it and/or modify it under the terms |
| 8 | * of the GNU General Public License as published by the Free Software Foundation, either |
| 9 | * version 3 of the License, or (at your option) any later version. |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 11 | * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 14 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 15 | * You should have received copies of the GNU General Public License along with |
| 16 | * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * See AUTHORS.md for complete list of ChronoShare authors and contributors. |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 19 | */ |
| 20 | #ifndef FETCH_TASK_DB_H |
| 21 | #define FETCH_TASK_DB_H |
| 22 | |
| 23 | #include <sqlite3.h> |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 24 | #include <ndnx-common.h> |
| 25 | #include <ndnx-name.h> |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 26 | #include <boost/filesystem.hpp> |
| 27 | #include <boost/shared_ptr.hpp> |
| 28 | |
| 29 | class FetchTaskDb |
| 30 | { |
| 31 | public: |
| 32 | FetchTaskDb(const boost::filesystem::path &folder, const std::string &tag); |
| 33 | ~FetchTaskDb(); |
| 34 | |
| 35 | // task with same deviceName and baseName combination will be added only once |
| 36 | // if task already exists, this call does nothing |
| 37 | void |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 38 | addTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName, uint64_t minSeqNo, uint64_t maxSeqNo, int priority); |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 39 | |
| 40 | void |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 41 | deleteTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName); |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 42 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 43 | typedef boost::function<void(const Ndnx::Name &, const Ndnx::Name &, uint64_t, uint64_t, int)> FetchTaskCallback; |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 44 | |
| 45 | void |
| 46 | foreachTask(const FetchTaskCallback &callback); |
| 47 | |
| 48 | private: |
| 49 | sqlite3 *m_db; |
| 50 | }; |
| 51 | |
| 52 | typedef boost::shared_ptr<FetchTaskDb> FetchTaskDbPtr; |
| 53 | |
| 54 | #endif // FETCH_TASK_DB_H |