blob: 28e0078838ee26ed768ec23040948452aafcbd83 [file] [log] [blame]
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08001/* -*- 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>
Chaoyi Bian3e1eb162012-04-03 16:59:32 -070019 * Chaoyi Bian <bcy@pku.edu.cn>
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080020 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
23#ifndef SYNC_FULL_STATE_H
24#define SYNC_FULL_STATE_H
25
Alexander Afanasyev531803b2014-02-05 15:57:35 -080026#include <ndn-cpp-dev/util/time.hpp>
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080027#include "sync-state.h"
28
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080029namespace Sync {
30
Alexander Afanasyevf3c03a92012-05-09 12:00:37 -070031class FullState;
32typedef boost::shared_ptr<FullState> FullStatePtr;
33typedef boost::shared_ptr<FullState> FullStateConstPtr;
34
35
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080036/**
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 */
Alexander Afanasyev531803b2014-02-05 15:57:35 -080054 ndn::time::Duration
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080055 getTimeFromLastUpdate () const;
Alexander Afanasyevd94542d2012-03-05 08:41:46 -080056
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 ();
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080064
65 // from State
Alexander Afanasyev750d1872012-03-12 15:33:56 -070066 virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080067 update (NameInfoConstPtr info, const SeqNo &seq);
68
Alexander Afanasyeve4e2bf72012-03-12 12:44:54 -070069 virtual bool
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080070 remove (NameInfoConstPtr info);
71
72private:
Alexander Afanasyev531803b2014-02-05 15:57:35 -080073 ndn::time::Point m_lastUpdated; ///< @brief Time when state was updated last time
Alexander Afanasyevd94542d2012-03-05 08:41:46 -080074 DigestPtr m_digest;
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080075};
76
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080077} // Sync
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080078
79#endif // SYNC_STATE_H