blob: 77533b259558863a26f4cabe8099c4e76c38a85f [file] [log] [blame]
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Alexander Afanasyev8722d872014-07-02 13:00:29 -07003 * Copyright (c) 2012-2014 University of California, Los Angeles
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08004 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -07005 * This file is part of ChronoSync, synchronization library for distributed realtime
6 * applications for NDN.
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08007 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -07008 * 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 Afanasyev7a696fb2012-03-01 17:17:22 -080011 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -070012 * 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 Afanasyev7a696fb2012-03-01 17:17:22 -080015 *
Alexander Afanasyev8722d872014-07-02 13:00:29 -070016 * 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 Afanasyev7a696fb2012-03-01 17:17:22 -080022 */
23
24#ifndef SYNC_FULL_STATE_H
25#define SYNC_FULL_STATE_H
26
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070027#include <ndn-cxx/util/time.hpp>
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080028#include "sync-state.h"
29
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080030namespace Sync {
31
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070032class FullState;
33typedef boost::shared_ptr<FullState> FullStatePtr;
34typedef boost::shared_ptr<FullState> FullStateConstPtr;
35
36
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080037/**
38 * \ingroup sync
39 * @brief Cumulative SYNC state
40 */
41class FullState : public State
42{
43public:
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 Yu6e1c9cd2014-03-25 10:26:54 -070055 ndn::time::system_clock::Duration
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080056 getTimeFromLastUpdate () const;
Alexander Afanasyevd94542d2012-03-05 08:41:46 -080057
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 Yu7c64e5c2014-04-30 14:06:37 -070065
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080066 // from State
Alexander Afanasyev750d1872012-03-12 15:33:56 -070067 virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080068 update (NameInfoConstPtr info, const SeqNo &seq);
69
Alexander Afanasyeve4e2bf72012-03-12 12:44:54 -070070 virtual bool
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080071 remove (NameInfoConstPtr info);
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070072
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080073private:
Yingdi Yu6e1c9cd2014-03-25 10:26:54 -070074 ndn::time::system_clock::TimePoint m_lastUpdated; ///< @brief Time when state was updated last time
Alexander Afanasyevd94542d2012-03-05 08:41:46 -080075 DigestPtr m_digest;
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080076};
77
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080078} // Sync
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080079
80#endif // SYNC_STATE_H