blob: 1f8e16afa31d518a1c672375c57768d3d6c3b6f9 [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>
25#include <ccnx-common.h>
26#include <ccnx-name.h>
27#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
39 addTask(const Ccnx::Name &deviceName, const Ccnx::Name &baseName, uint64_t minSeqNo, uint64_t maxSeqNo, int priority);
40
41 void
42 deleteTask(const Ccnx::Name &deviceName, const Ccnx::Name &baseName);
43
44 typedef boost::function<void(const Ccnx::Name &, const Ccnx::Name &, uint64_t, uint64_t, int)> FetchTaskCallback;
45
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