blob: 617d20cc26d80b5c54b3e954c589bbd276a457f3 [file] [log] [blame]
peizhen guo410e0e12014-08-12 13:24:14 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014, Regents of the University of California
4 *
5 * This file is part of NSL (NDN Signature Logger).
6 * See AUTHORS.md for complete list of NSL authors and contributors.
7 *
8 * NSL is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NSL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * NSL, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @author Peizhen Guo <patrick.guopz@gmail.com>
20 */
21
22#ifndef NLS_CORE_MERKLE_TREE_SQLITE3_HPP
23#define NLS_CORE_MERKLE_TREE_SQLITE3_HPP
24
25#include <sqlite3.h>
26#include <map>
27#include "sub-tree.hpp"
28typedef ndn::shared_ptr<const nsl::SubTree> ConstSubTreePtr;
29typedef ndn::shared_ptr<nsl::SubTree> SubTreePtr;
30
31struct sqlite3;
32
33namespace nsl {
34
35class MerkleTreeSqlite3
36{
37public:
38
39 MerkleTreeSqlite3();
40
41 ~MerkleTreeSqlite3();
42
43 // SubTree
44 void
45 addSubTree(SubTreePtr oldSubTree);
46
47 std::string
48 getSubTree(Index rootIndex);
49
50 bool
51 doesSubTreeExist(Index rootIndex);
52
53 void
54 deleteSubTree(Index rootIndex);
55
56 void
57 getAllSubTree(std::vector<std::string> subTreeInfoList);
58
59
60 // LeafInfo (no need of encoding/decoding scheme)
61 void
62 addLeafInfo(uint64_t sequence, ndn::ConstBufferPtr buf_ptr);
63
64 ndn::ConstBufferPtr
65 getLeafInfo(uint64_t sequence);
66
67 bool
68 doesLeafInfoExist(uint64_t sequence);
69
70 void
71 deleteLeafInfo(uint64_t sequence);
72
73 void
74 getAllLeafInfo(std::map<uint64_t, ndn::ConstBufferPtr> leaves);
75
76
77private:
78 sqlite3* m_database;
79
80};
81
82
83} // namespace nsl
84
85
86#endif // NLS_CORE_MERKLE_TREE_SQLITE3_HPP