blob: 48a1f968f143eb7e0a211d5bc48f273f45d8eba3 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoquefdbddb12014-05-02 18:35:19 -050023#ifndef NLSR_SEQUENCING_MANAGER_HPP
24#define NLSR_SEQUENCING_MANAGER_HPP
akmhoque53353462014-04-22 08:43:45 -050025
26#include <list>
27#include <string>
akmhoquefdbddb12014-05-02 18:35:19 -050028#include <boost/cstdint.hpp>
29
akmhoquec8a10f72014-04-25 18:42:55 -050030#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -050031
32namespace nlsr {
33class SequencingManager
34{
35public:
36 SequencingManager()
37 : m_nameLsaSeq(0)
38 , m_adjLsaSeq(0)
39 , m_corLsaSeq(0)
40 , m_combinedSeqNo(0)
41 , m_seqFileNameWithPath()
42 {
43 }
44
45 SequencingManager(uint64_t seqNo)
46 {
47 splittSequenceNo(seqNo);
48 }
49
50 SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn)
51 {
52 m_nameLsaSeq = nlsn;
53 m_adjLsaSeq = alsn;
54 m_corLsaSeq = clsn;
55 combineSequenceNo();
56 }
57
58 uint64_t
59 getNameLsaSeq() const
60 {
61 return m_nameLsaSeq;
62 }
63
64 void
65 setNameLsaSeq(uint64_t nlsn)
66 {
67 m_nameLsaSeq = nlsn;
68 combineSequenceNo();
69 }
70
71 uint64_t
72 getAdjLsaSeq() const
73 {
74 return m_adjLsaSeq;
75 }
76
77 void
78 setAdjLsaSeq(uint64_t alsn)
79 {
80 m_adjLsaSeq = alsn;
81 combineSequenceNo();
82 }
83
84 uint64_t
85 getCorLsaSeq() const
86 {
87 return m_corLsaSeq;
88 }
89
90 void
91 setCorLsaSeq(uint64_t clsn)
92 {
93 m_corLsaSeq = clsn;
94 combineSequenceNo();
95 }
96
akmhoquefdbddb12014-05-02 18:35:19 -050097 void
98 increaseNameLsaSeq()
99 {
100 m_nameLsaSeq++;
101 combineSequenceNo();
102 }
103
104 void
105 increaseAdjLsaSeq()
106 {
107 m_adjLsaSeq++;
108 combineSequenceNo();
109 }
110
111 void
112 increaseCorLsaSeq()
113 {
114 m_corLsaSeq++;
115 combineSequenceNo();
116 }
117
akmhoque53353462014-04-22 08:43:45 -0500118 uint64_t
119 getCombinedSeqNo() const
120 {
121 return m_combinedSeqNo;
122 }
123
124 void
125 writeSeqNoToFile();
126
127 void
128 initiateSeqNoFromFile();
129
130 void
131 setSeqFileName(std::string filePath);
132
133 std::string
134 getUserHomeDirectory();
135
136private:
137 void
138 splittSequenceNo(uint64_t seqNo);
139
140 void
141 combineSequenceNo();
142
akmhoque53353462014-04-22 08:43:45 -0500143private:
144 uint64_t m_nameLsaSeq;
145 uint64_t m_adjLsaSeq;
146 uint64_t m_corLsaSeq;
147 uint64_t m_combinedSeqNo;
148 std::string m_seqFileNameWithPath;
149};
150
151
152std::ostream&
153operator<<(std::ostream& os, const SequencingManager& sm);
154
155}//namespace nlsr
akmhoquefdbddb12014-05-02 18:35:19 -0500156#endif //NLSR_SEQUENCING_MANAGER_HPP