blob: 46140d61c907b43703dbfdf1661a91287f86aecb [file] [log] [blame]
Zhenkai Zhuda686882013-01-29 22:32:24 -08001/* -*- 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 Afanasyev1dd37ed2013-08-14 18:08:09 -070025#include <ndnx-common.h>
26#include <ndnx-name.h>
Zhenkai Zhuda686882013-01-29 22:32:24 -080027#include <boost/filesystem.hpp>
28#include <boost/shared_ptr.hpp>
29
30class FetchTaskDb
31{
32public:
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 Afanasyev1dd37ed2013-08-14 18:08:09 -070039 addTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName, uint64_t minSeqNo, uint64_t maxSeqNo, int priority);
Zhenkai Zhuda686882013-01-29 22:32:24 -080040
41 void
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070042 deleteTask(const Ndnx::Name &deviceName, const Ndnx::Name &baseName);
Zhenkai Zhuda686882013-01-29 22:32:24 -080043
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070044 typedef boost::function<void(const Ndnx::Name &, const Ndnx::Name &, uint64_t, uint64_t, int)> FetchTaskCallback;
Zhenkai Zhuda686882013-01-29 22:32:24 -080045
46 void
47 foreachTask(const FetchTaskCallback &callback);
48
49private:
50 sqlite3 *m_db;
51};
52
53typedef boost::shared_ptr<FetchTaskDb> FetchTaskDbPtr;
54
55#endif // FETCH_TASK_DB_H