Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 28 | namespace Sync { |
| 29 | |
| 30 | class DiffState; |
| 31 | typedef boost::shared_ptr<DiffState> DiffStatePtr; |
| 32 | typedef boost::shared_ptr<DiffState> DiffStateConstPtr; |
| 33 | |
| 34 | /** |
| 35 | * @ingroup ccnx |
| 36 | * @brief Differential SYNC state |
| 37 | */ |
| 38 | class DiffState : public State |
| 39 | { |
| 40 | public: |
| 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 | |
| 87 | private: |
| 88 | DiffStatePtr m_next; |
| 89 | // Hash m_digest; |
| 90 | }; |
| 91 | |
| 92 | } // Sync |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 93 | |
| 94 | #endif // SYNC_DIFF_STATE_H |