blob: 573f836f50da348b7a20e8435d99908da0fb19ca [file] [log] [blame]
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016, Regents of the University of California.
Zhenkai Zhuda686882013-01-29 22:32:24 -08004 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08005 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
Zhenkai Zhuda686882013-01-29 22:32:24 -08006 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08007 * 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 Zhuda686882013-01-29 22:32:24 -080010 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080011 * 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 Zhuda686882013-01-29 22:32:24 -080014 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080015 * 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 Zhuda686882013-01-29 22:32:24 -080019 */
20#ifndef FETCH_TASK_DB_H
21#define FETCH_TASK_DB_H
22
23#include <sqlite3.h>
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070024#include <ndnx-common.h>
25#include <ndnx-name.h>
Zhenkai Zhuda686882013-01-29 22:32:24 -080026#include <boost/filesystem.hpp>
27#include <boost/shared_ptr.hpp>
28
29class FetchTaskDb
30{
31public:
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 Afanasyev1dd37ed2013-08-14 18:08:09 -070038 addTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName, uint64_t minSeqNo, uint64_t maxSeqNo, int priority);
Zhenkai Zhuda686882013-01-29 22:32:24 -080039
40 void
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070041 deleteTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName);
Zhenkai Zhuda686882013-01-29 22:32:24 -080042
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070043 typedef boost::function<void(const Ndnx::Name &, const Ndnx::Name &, uint64_t, uint64_t, int)> FetchTaskCallback;
Zhenkai Zhuda686882013-01-29 22:32:24 -080044
45 void
46 foreachTask(const FetchTaskCallback &callback);
47
48private:
49 sqlite3 *m_db;
50};
51
52typedef boost::shared_ptr<FetchTaskDb> FetchTaskDbPtr;
53
54#endif // FETCH_TASK_DB_H