blob: 0905004269176bbd21ba88509d237cf111a7986c [file] [log] [blame]
akmhoque66e66182014-02-21 17:56:03 -06001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * Chaoyi Bian <bcy@pku.edu.cn>
Vince Lehman0a7da612014-10-29 14:39:29 -050020 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
akmhoque66e66182014-02-21 17:56:03 -060021 */
22
23#ifndef SYNC_FULL_STATE_H
24#define SYNC_FULL_STATE_H
25
akmhoquec8a10f72014-04-25 18:42:55 -050026#include <ndn-cxx/util/time.hpp>
akmhoque66e66182014-02-21 17:56:03 -060027#include "sync-state.h"
28
29namespace Sync {
30
31class FullState;
Vince Lehman0a7da612014-10-29 14:39:29 -050032typedef shared_ptr<FullState> FullStatePtr;
33typedef shared_ptr<FullState> FullStateConstPtr;
akmhoque66e66182014-02-21 17:56:03 -060034
35
36/**
37 * \ingroup sync
38 * @brief Cumulative SYNC state
39 */
40class FullState : public State
41{
42public:
43 /**
44 * @brief Default constructor
45 */
46 FullState ();
47 virtual ~FullState ();
48
49 /**
50 * @brief Get time period since last state update
51 *
52 * This value can be used to randomize reconciliation waiting time in SyncApp
53 */
akmhoque05d5fcf2014-04-15 14:58:45 -050054 ndn::time::system_clock::Duration
akmhoque66e66182014-02-21 17:56:03 -060055 getTimeFromLastUpdate () const;
56
57 /**
58 * @brief Obtain a read-only copy of the digest
59 *
60 * If m_digest is 0, then it is automatically created. On every update and removal, m_digest is reset to 0
61 */
62 DigestConstPtr
63 getDigest ();
Vince Lehman0a7da612014-10-29 14:39:29 -050064
akmhoque66e66182014-02-21 17:56:03 -060065 // from State
Vince Lehman0a7da612014-10-29 14:39:29 -050066 virtual tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
akmhoque66e66182014-02-21 17:56:03 -060067 update (NameInfoConstPtr info, const SeqNo &seq);
68
69 virtual bool
70 remove (NameInfoConstPtr info);
Vince Lehman0a7da612014-10-29 14:39:29 -050071
akmhoque66e66182014-02-21 17:56:03 -060072private:
akmhoque05d5fcf2014-04-15 14:58:45 -050073 ndn::time::system_clock::TimePoint m_lastUpdated; ///< @brief Time when state was updated last time
akmhoque66e66182014-02-21 17:56:03 -060074 DigestPtr m_digest;
75};
76
77} // Sync
78
79#endif // SYNC_STATE_H