blob: ab3fdc9cdf9141f11356fd2aa848dcfd665c601a [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
Zhenkai Zhuda686882013-01-29 22:32:24 -080023#include <boost/filesystem.hpp>
24#include <boost/shared_ptr.hpp>
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080025#include <ccnx-common.h>
26#include <ccnx-name.h>
27#include <sqlite3.h>
Zhenkai Zhuda686882013-01-29 22:32:24 -080028
29class FetchTaskDb
30{
31public:
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080032 FetchTaskDb(const boost::filesystem::path& folder, const std::string& tag);
Zhenkai Zhuda686882013-01-29 22:32:24 -080033 ~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 Afanasyeveda3b7a2016-12-25 11:26:40 -080038 addTask(const Ccnx::Name& deviceName, const Ccnx::Name& baseName, uint64_t minSeqNo,
39 uint64_t maxSeqNo, int priority);
Zhenkai Zhuda686882013-01-29 22:32:24 -080040
41 void
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080042 deleteTask(const Ccnx::Name& deviceName, const Ccnx::Name& baseName);
Zhenkai Zhuda686882013-01-29 22:32:24 -080043
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080044 typedef boost::function<void(const Ccnx::Name&, const Ccnx::Name&, uint64_t, uint64_t, int)>
45 FetchTaskCallback;
Zhenkai Zhuda686882013-01-29 22:32:24 -080046
47 void
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080048 foreachTask(const FetchTaskCallback& callback);
Zhenkai Zhuda686882013-01-29 22:32:24 -080049
50private:
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080051 sqlite3* m_db;
Zhenkai Zhuda686882013-01-29 22:32:24 -080052};
53
54typedef boost::shared_ptr<FetchTaskDb> FetchTaskDbPtr;
55
56#endif // FETCH_TASK_DB_H