blob: 49f61ae0d336a04db3454ddf901c78734329fd96 [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>
19 * 卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
20 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
23#ifndef SYNC_DIFF_STATE_H
24#define SYNC_DIFF_STATE_H
25
26#include "sync-state.h"
27
28namespace ns3 {
29namespace Sync {
30
31class DiffState;
32typedef boost::shared_ptr<DiffState> DiffStatePtr;
33typedef boost::shared_ptr<DiffState> DiffStateConstPtr;
34
35/**
36 * @ingroup ccnx
37 * @brief Differential SYNC state
38 */
39class DiffState : public State
40{
41public:
42 /**
43 * @see Default constructor
44 */
45 DiffState ();
46 virtual ~DiffState ();
47
48 /**
49 * @brief Set successor for the diff state
50 * @param next successor state
51 */
52 void
53 setNext (DiffStatePtr next)
54 {
55 m_next = next;
56 }
57
58 // void
59 // setDigest (Hash digest);
60
61 // Hash
62 // getDigest () const;
63
64 /**
65 * @brief Accumulate differences from `this' state to the most current state
66 * @returns Accumulated differences from `this' state to the most current state
67 */
68 DiffStatePtr
69 diff () const;
70
71 /**
72 * @brief Combine differences from `this' and `state'
73 * @param state Differential state to combine with
74 * @return Combined differences
75 *
76 * In case of collisions, `this' leaf will be replaced with the leaf of `state'
77 */
78 DiffState&
79 operator += (const DiffState &state);
80
81 // from State
82 virtual void
83 update (NameInfoConstPtr info, const SeqNo &seq);
84
85 virtual void
86 remove (NameInfoConstPtr info);
87
88private:
89 DiffStatePtr m_next;
90 // Hash m_digest;
91};
92
93} // Sync
94} // ns3
95
96#endif // SYNC_DIFF_STATE_H