Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2012-2014 University of California, Los Angeles |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 5 | * This file is part of ChronoSync, synchronization library for distributed realtime |
| 6 | * applications for NDN. |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 8 | * ChronoSync 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, either |
| 10 | * version 3 of the License, or (at your option) any later version. |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 12 | * ChronoSync 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. |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * @author Zhenkai Zhu <http://irl.cs.ucla.edu/~zhenkai/> |
| 20 | * @author Chaoyi Bian <bcy@pku.edu.cn> |
| 21 | * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html> |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | #ifndef SYNC_FULL_STATE_H |
| 25 | #define SYNC_FULL_STATE_H |
| 26 | |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 27 | #include <ndn-cxx/util/time.hpp> |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 28 | #include "sync-state.h" |
| 29 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 30 | namespace Sync { |
| 31 | |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 32 | class FullState; |
| 33 | typedef boost::shared_ptr<FullState> FullStatePtr; |
| 34 | typedef boost::shared_ptr<FullState> FullStateConstPtr; |
| 35 | |
| 36 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 37 | /** |
| 38 | * \ingroup sync |
| 39 | * @brief Cumulative SYNC state |
| 40 | */ |
| 41 | class FullState : public State |
| 42 | { |
| 43 | public: |
| 44 | /** |
| 45 | * @brief Default constructor |
| 46 | */ |
| 47 | FullState (); |
| 48 | virtual ~FullState (); |
| 49 | |
| 50 | /** |
| 51 | * @brief Get time period since last state update |
| 52 | * |
| 53 | * This value can be used to randomize reconciliation waiting time in SyncApp |
| 54 | */ |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 55 | ndn::time::system_clock::Duration |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 56 | getTimeFromLastUpdate () const; |
Alexander Afanasyev | d94542d | 2012-03-05 08:41:46 -0800 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * @brief Obtain a read-only copy of the digest |
| 60 | * |
| 61 | * If m_digest is 0, then it is automatically created. On every update and removal, m_digest is reset to 0 |
| 62 | */ |
| 63 | DigestConstPtr |
| 64 | getDigest (); |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 65 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 66 | // from State |
Alexander Afanasyev | 750d187 | 2012-03-12 15:33:56 -0700 | [diff] [blame] | 67 | virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/> |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 68 | update (NameInfoConstPtr info, const SeqNo &seq); |
| 69 | |
Alexander Afanasyev | e4e2bf7 | 2012-03-12 12:44:54 -0700 | [diff] [blame] | 70 | virtual bool |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 71 | remove (NameInfoConstPtr info); |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 72 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 73 | private: |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 74 | ndn::time::system_clock::TimePoint m_lastUpdated; ///< @brief Time when state was updated last time |
Alexander Afanasyev | d94542d | 2012-03-05 08:41:46 -0800 | [diff] [blame] | 75 | DigestPtr m_digest; |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 76 | }; |
| 77 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 78 | } // Sync |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 79 | |
| 80 | #endif // SYNC_STATE_H |