Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 1 | /* -*- 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 | #ifndef FETCH_TASK_DB_H |
| 22 | #define FETCH_TASK_DB_H |
| 23 | |
| 24 | #include <sqlite3.h> |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 25 | #include <ndnx-common.h> |
| 26 | #include <ndnx-name.h> |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 27 | #include <boost/filesystem.hpp> |
| 28 | #include <boost/shared_ptr.hpp> |
| 29 | |
| 30 | class FetchTaskDb |
| 31 | { |
| 32 | public: |
| 33 | FetchTaskDb(const boost::filesystem::path &folder, const std::string &tag); |
| 34 | ~FetchTaskDb(); |
| 35 | |
| 36 | // task with same deviceName and baseName combination will be added only once |
| 37 | // if task already exists, this call does nothing |
| 38 | void |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 39 | 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] | 40 | |
| 41 | void |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 42 | deleteTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName); |
Zhenkai Zhu | da68688 | 2013-01-29 22:32:24 -0800 | [diff] [blame] | 43 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 44 | 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] | 45 | |
| 46 | void |
| 47 | foreachTask(const FetchTaskCallback &callback); |
| 48 | |
| 49 | private: |
| 50 | sqlite3 *m_db; |
| 51 | }; |
| 52 | |
| 53 | typedef boost::shared_ptr<FetchTaskDb> FetchTaskDbPtr; |
| 54 | |
| 55 | #endif // FETCH_TASK_DB_H |