akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [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_FULL_LEAF_H |
| 24 | #define SYNC_FULL_LEAF_H |
| 25 | |
| 26 | #include "sync-leaf.h" |
| 27 | |
| 28 | namespace Sync { |
| 29 | |
| 30 | /** |
| 31 | * @ingroup sync |
| 32 | * @brief SYNC leaf for the full state (with support of Digest calculation) |
| 33 | */ |
| 34 | class FullLeaf : public Leaf |
| 35 | { |
| 36 | public: |
| 37 | /** |
| 38 | * @brief Constructor to create an UPDATE diff leaf |
| 39 | * @param info Smart pointer to leaf's name |
| 40 | * @param seq Initial sequence number of the pointer |
| 41 | */ |
| 42 | FullLeaf (NameInfoConstPtr info, const SeqNo &seq); |
| 43 | virtual ~FullLeaf () { } |
| 44 | |
| 45 | /** |
| 46 | * @brief Get hash digest of the leaf |
| 47 | * |
| 48 | * The underlying Digest object is recalculated on every update or removal |
| 49 | * (including updates of child classes) |
| 50 | */ |
| 51 | const Digest & |
| 52 | getDigest () const { return m_digest; } |
| 53 | |
| 54 | // from Leaf |
| 55 | virtual void |
| 56 | setSeq (const SeqNo &seq); |
| 57 | |
| 58 | private: |
| 59 | void |
| 60 | updateDigest (); |
| 61 | |
| 62 | private: |
| 63 | Digest m_digest; |
| 64 | }; |
| 65 | |
| 66 | typedef boost::shared_ptr<FullLeaf> FullLeafPtr; |
| 67 | typedef boost::shared_ptr<const FullLeaf> FullLeafConstPtr; |
| 68 | |
| 69 | } // Sync |
| 70 | |
| 71 | #endif // SYNC_FULL_LEAF_H |