blob: 188cea69a7bbc059a2b9fb0667578851fde2ba15 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonc6a85222017-01-03 16:54:34 -06003 * Copyright (c) 2014-2017, The University of Memphis,
Vince Lehmanc2e51f62015-01-20 15:03:11 -06004 * Regents of the University of California,
5 * Arizona Board of Regents.
akmhoque3d06e792014-05-27 16:23:20 -05006 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
akmhoque3d06e792014-05-27 16:23:20 -050020 **/
Vince Lehmanc2e51f62015-01-20 15:03:11 -060021
akmhoquefdbddb12014-05-02 18:35:19 -050022#ifndef NLSR_SEQUENCING_MANAGER_HPP
23#define NLSR_SEQUENCING_MANAGER_HPP
akmhoque53353462014-04-22 08:43:45 -050024
25#include <list>
26#include <string>
akmhoquefdbddb12014-05-02 18:35:19 -050027#include <boost/cstdint.hpp>
28
akmhoquec8a10f72014-04-25 18:42:55 -050029#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -050030
Nick Gordon5c467f02016-07-13 13:40:10 -050031#include "conf-parameter.hpp"
32
akmhoque53353462014-04-22 08:43:45 -050033namespace nlsr {
Nick Gordon5c467f02016-07-13 13:40:10 -050034
akmhoque53353462014-04-22 08:43:45 -050035class SequencingManager
36{
37public:
38 SequencingManager()
39 : m_nameLsaSeq(0)
40 , m_adjLsaSeq(0)
41 , m_corLsaSeq(0)
akmhoque53353462014-04-22 08:43:45 -050042 , m_seqFileNameWithPath()
43 {
44 }
45
akmhoque53353462014-04-22 08:43:45 -050046 uint64_t
47 getNameLsaSeq() const
48 {
49 return m_nameLsaSeq;
50 }
51
52 void
53 setNameLsaSeq(uint64_t nlsn)
54 {
55 m_nameLsaSeq = nlsn;
akmhoque53353462014-04-22 08:43:45 -050056 }
57
58 uint64_t
59 getAdjLsaSeq() const
60 {
61 return m_adjLsaSeq;
62 }
63
64 void
65 setAdjLsaSeq(uint64_t alsn)
66 {
67 m_adjLsaSeq = alsn;
akmhoque53353462014-04-22 08:43:45 -050068 }
69
70 uint64_t
71 getCorLsaSeq() const
72 {
73 return m_corLsaSeq;
74 }
75
76 void
77 setCorLsaSeq(uint64_t clsn)
78 {
79 m_corLsaSeq = clsn;
akmhoque53353462014-04-22 08:43:45 -050080 }
81
akmhoquefdbddb12014-05-02 18:35:19 -050082 void
83 increaseNameLsaSeq()
84 {
85 m_nameLsaSeq++;
akmhoquefdbddb12014-05-02 18:35:19 -050086 }
87
88 void
89 increaseAdjLsaSeq()
90 {
91 m_adjLsaSeq++;
akmhoquefdbddb12014-05-02 18:35:19 -050092 }
93
94 void
95 increaseCorLsaSeq()
96 {
97 m_corLsaSeq++;
akmhoque53353462014-04-22 08:43:45 -050098 }
99
100 void
Vince Lehman0bcf9a32014-12-10 11:24:45 -0600101 writeSeqNoToFile() const;
akmhoque53353462014-04-22 08:43:45 -0500102
103 void
Nick Gordon5c467f02016-07-13 13:40:10 -0500104 initiateSeqNoFromFile(int hypState);
akmhoque53353462014-04-22 08:43:45 -0500105
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500106 /*! \brief Set the sequence file directory
akmhoque53353462014-04-22 08:43:45 -0500107
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500108 If the string is empty, home directory is set as sequence file directory
109
110 \param filePath The directory where sequence file will be stored
111 */
112 void
113 setSeqFileDirectory(std::string filePath);
akmhoque53353462014-04-22 08:43:45 -0500114
akmhoque2f423352014-06-03 11:49:35 -0500115 void
Vince Lehman904c2412014-09-23 19:36:11 -0500116 writeLog() const;
akmhoque2f423352014-06-03 11:49:35 -0500117
akmhoque53353462014-04-22 08:43:45 -0500118private:
akmhoque53353462014-04-22 08:43:45 -0500119 uint64_t m_nameLsaSeq;
120 uint64_t m_adjLsaSeq;
121 uint64_t m_corLsaSeq;
akmhoque53353462014-04-22 08:43:45 -0500122 std::string m_seqFileNameWithPath;
123};
124
Nick Gordonfad8e252016-08-11 14:21:38 -0500125} // namespace nlsr
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500126#endif // NLSR_SEQUENCING_MANAGER_HPP