blob: be2ed924c7f440849297324c6f99fc26c89bc7ff [file] [log] [blame]
peizhen guocf4df2d2014-08-12 13:22:32 -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_NODE_HPP
23#define NLS_CORE_NODE_HPP
24#include <stddef.h>
25#include <time.h>
26
27#include <ndn-cxx/util/crypto.hpp>
28
29namespace nsl {
30
31class Index
32{
33public:
34 Index()
35 {
36 }
37
38 Index(const Index& idx)
39 : number(idx.number),
40 level(idx.level)
41 {
42 }
43
44 bool operator<(const Index& other) const
45 {
46 if (number < other.number)
47 {
48 return true;
49 }
50 else if (number == other.number)
51 {
52 return level < other.level;
53 }
54 else
55 {
56 return false;
57 }
58
59 }
60
61public:
62 uint64_t number;
63 uint64_t level;
64};
65
66
67class Node
68{
69public:
70
71 Node()
72 {
73 }
74
75
76 Node(uint64_t sequenceNumber, uint64_t level, time_t timestamp);
77
78
79 ~Node()
80 {
81 }
82
83
84 const Index&
85 getIndex() const;
86
87
88 time_t
89 getTimestamp() const;
90
91
92 void
93 setHash(ndn::ConstBufferPtr digest);
94
95
96 ndn::ConstBufferPtr
97 getHash() const;
98
99private:
100 ndn::ConstBufferPtr m_hash;
101 Index m_index; // Node index.number starts from 0 (the index of current root)
102 time_t m_timeStamp;
103};
104
105} // namespace nsl
106
107#endif // NLS_CORE_NODE_HPP