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> |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 20 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame] | 21 | */ |
| 22 | |
dmcoomes | e689dd6 | 2017-03-29 11:05:12 -0500 | [diff] [blame^] | 23 | #ifndef NLSR_NSYNC_SYNC_DIFF_LEAF_H |
| 24 | #define NLSR_NSYNC_SYNC_DIFF_LEAF_H |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame] | 25 | |
| 26 | #include "sync-leaf.h" |
| 27 | #include <boost/exception/all.hpp> |
| 28 | |
| 29 | namespace Sync { |
| 30 | |
| 31 | /** |
| 32 | * @ingroup sync |
| 33 | * @brief Annotation for SYNC leaf |
| 34 | */ |
| 35 | enum Operation |
| 36 | { |
| 37 | UPDATE, ///< @brief Leaf was added or updated |
| 38 | REMOVE ///< @brief Leaf was removed |
| 39 | }; |
| 40 | |
| 41 | /** |
| 42 | * @ingroup sync |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 43 | * @brief Annotated SYNC leaf |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame] | 44 | */ |
| 45 | class DiffLeaf : public Leaf |
| 46 | { |
| 47 | public: |
| 48 | /** |
| 49 | * @brief Constructor to create an UPDATE diff leaf |
| 50 | * @param info Smart pointer to leaf's name |
| 51 | * @param seq Initial sequence number of the pointer |
| 52 | */ |
| 53 | DiffLeaf (NameInfoConstPtr info, const SeqNo &seq); |
| 54 | |
| 55 | /** |
| 56 | * @brief Constructor to create an REMOVE diff leaf |
| 57 | * @param info Smart pointer to leaf's name |
| 58 | * |
| 59 | * This constructor creates a leaf with phony sequence number |
| 60 | * with 0 session ID and 0 sequence number |
| 61 | */ |
| 62 | DiffLeaf (NameInfoConstPtr info); |
| 63 | |
| 64 | virtual ~DiffLeaf () { } |
| 65 | |
| 66 | /** |
| 67 | * @brief Get diff leaf type |
| 68 | */ |
| 69 | Operation |
| 70 | getOperation () const { return m_op; } |
| 71 | |
| 72 | private: |
| 73 | Operation m_op; |
| 74 | }; |
| 75 | |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 76 | typedef shared_ptr<DiffLeaf> DiffLeafPtr; |
| 77 | typedef shared_ptr<const DiffLeaf> DiffLeafConstPtr; |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame] | 78 | |
| 79 | std::ostream & |
| 80 | operator << (std::ostream &os, Operation op); |
| 81 | |
| 82 | std::istream & |
| 83 | operator >> (std::istream &is, Operation &op); |
| 84 | |
| 85 | namespace Error { |
| 86 | struct SyncDiffLeafOperationParseError : virtual boost::exception, virtual std::exception { }; |
| 87 | } // Error |
| 88 | |
| 89 | } // Sync |
| 90 | |
dmcoomes | e689dd6 | 2017-03-29 11:05:12 -0500 | [diff] [blame^] | 91 | #endif // NLSR_NSYNC_SYNC_DIFF_LEAF_H |