blob: 14202c4f69223136f1f58a4c3411dbf3bd0fe494 [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
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080028namespace Sync {
29
30class DiffState;
31typedef boost::shared_ptr<DiffState> DiffStatePtr;
32typedef boost::shared_ptr<DiffState> DiffStateConstPtr;
33
34/**
35 * @ingroup ccnx
36 * @brief Differential SYNC state
37 */
38class DiffState : public State
39{
40public:
41 /**
42 * @see Default constructor
43 */
44 DiffState ();
45 virtual ~DiffState ();
46
47 /**
48 * @brief Set successor for the diff state
49 * @param next successor state
50 */
51 void
52 setNext (DiffStatePtr next)
53 {
54 m_next = next;
55 }
56
57 // void
58 // setDigest (Hash digest);
59
60 // Hash
61 // getDigest () const;
62
63 /**
64 * @brief Accumulate differences from `this' state to the most current state
65 * @returns Accumulated differences from `this' state to the most current state
66 */
67 DiffStatePtr
68 diff () const;
69
70 /**
71 * @brief Combine differences from `this' and `state'
72 * @param state Differential state to combine with
73 * @return Combined differences
74 *
75 * In case of collisions, `this' leaf will be replaced with the leaf of `state'
76 */
77 DiffState&
78 operator += (const DiffState &state);
79
80 // from State
81 virtual void
82 update (NameInfoConstPtr info, const SeqNo &seq);
83
84 virtual void
85 remove (NameInfoConstPtr info);
86
87private:
88 DiffStatePtr m_next;
89 // Hash m_digest;
90};
91
92} // Sync
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080093
94#endif // SYNC_DIFF_STATE_H