blob: eb162098c54df01d56165f66273c239f0c8d5842 [file] [log] [blame]
akmhoque66e66182014-02-21 17:56:03 -06001/* -*- 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 Lehman0a7da612014-10-29 14:39:29 -050020 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
akmhoque66e66182014-02-21 17:56:03 -060021 */
22
dmcoomese689dd62017-03-29 11:05:12 -050023#ifndef NLSR_NSYNC_SYNC_DIFF_LEAF_H
24#define NLSR_NSYNC_SYNC_DIFF_LEAF_H
akmhoque66e66182014-02-21 17:56:03 -060025
26#include "sync-leaf.h"
27#include <boost/exception/all.hpp>
28
29namespace Sync {
30
31/**
32 * @ingroup sync
33 * @brief Annotation for SYNC leaf
34 */
35enum Operation
36 {
37 UPDATE, ///< @brief Leaf was added or updated
38 REMOVE ///< @brief Leaf was removed
39 };
40
41/**
42 * @ingroup sync
Vince Lehman0a7da612014-10-29 14:39:29 -050043 * @brief Annotated SYNC leaf
akmhoque66e66182014-02-21 17:56:03 -060044 */
45class DiffLeaf : public Leaf
46{
47public:
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
72private:
73 Operation m_op;
74};
75
Vince Lehman0a7da612014-10-29 14:39:29 -050076typedef shared_ptr<DiffLeaf> DiffLeafPtr;
77typedef shared_ptr<const DiffLeaf> DiffLeafConstPtr;
akmhoque66e66182014-02-21 17:56:03 -060078
79std::ostream &
80operator << (std::ostream &os, Operation op);
81
82std::istream &
83operator >> (std::istream &is, Operation &op);
84
85namespace Error {
86struct SyncDiffLeafOperationParseError : virtual boost::exception, virtual std::exception { };
87} // Error
88
89} // Sync
90
dmcoomese689dd62017-03-29 11:05:12 -050091#endif // NLSR_NSYNC_SYNC_DIFF_LEAF_H