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_LEAF_H |
| 24 | #define SYNC_DIFF_LEAF_H |
| 25 | |
| 26 | #include "sync-leaf.h" |
| 27 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 28 | namespace Sync { |
| 29 | |
| 30 | /** |
| 31 | * @ingroup sync |
| 32 | * @brief Annotation for SYNC leaf |
| 33 | */ |
| 34 | enum Operation |
| 35 | { |
| 36 | UPDATE, ///< @brief Leaf was added or updated |
| 37 | REMOVE ///< @brief Leaf was removed |
| 38 | }; |
| 39 | |
| 40 | /** |
| 41 | * @ingroup sync |
| 42 | * @brief Annotated SYNC leaf |
| 43 | */ |
| 44 | class DiffLeaf : public Leaf |
| 45 | { |
| 46 | public: |
| 47 | /** |
| 48 | * @brief Constructor to create an UPDATE diff leaf |
| 49 | * @param info Smart pointer to leaf's name |
| 50 | * @param seq Initial sequence number of the pointer |
| 51 | */ |
| 52 | DiffLeaf (boost::shared_ptr<const NameInfo> info, const SeqNo &seq) |
| 53 | : Leaf (info, seq) |
Alexander Afanasyev | b5547e3 | 2012-03-01 21:59:38 -0800 | [diff] [blame] | 54 | , m_op (UPDATE) |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 55 | { |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * @brief Constructor to create an REMOVE diff leaf |
| 60 | * @param info Smart pointer to leaf's name |
| 61 | * |
| 62 | * This constructor creates a leaf with phony sequence number |
| 63 | * with 0 session ID and 0 sequence number |
| 64 | */ |
| 65 | DiffLeaf (boost::shared_ptr<const NameInfo> info) |
| 66 | : Leaf (info, SeqNo (0,0)) |
Alexander Afanasyev | b5547e3 | 2012-03-01 21:59:38 -0800 | [diff] [blame] | 67 | , m_op (REMOVE) |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 68 | { |
| 69 | } |
| 70 | |
| 71 | virtual ~DiffLeaf () |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | Operation |
| 76 | getOperation () const |
| 77 | { |
| 78 | return m_op; |
| 79 | } |
| 80 | |
| 81 | private: |
| 82 | Operation m_op; |
| 83 | }; |
| 84 | |
Alexander Afanasyev | b5547e3 | 2012-03-01 21:59:38 -0800 | [diff] [blame] | 85 | typedef boost::shared_ptr<DiffLeaf> DiffLeafPtr; |
| 86 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 87 | } // Sync |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 88 | |
| 89 | #endif // SYNC_DIFF_LEAF_H |