blob: 4ebc6d5e01da45dced4635dfc31748ee7f5ad522 [file] [log] [blame]
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08001/* -*- 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 Afanasyev7a696fb2012-03-01 17:17:22 -080028namespace Sync {
29
30/**
31 * @ingroup sync
32 * @brief Annotation for SYNC leaf
33 */
34enum 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 */
44class DiffLeaf : public Leaf
45{
46public:
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 Afanasyevb5547e32012-03-01 21:59:38 -080054 , m_op (UPDATE)
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080055 {
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 Afanasyevb5547e32012-03-01 21:59:38 -080067 , m_op (REMOVE)
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080068 {
69 }
70
71 virtual ~DiffLeaf ()
72 {
73 }
74
75 Operation
76 getOperation () const
77 {
78 return m_op;
79 }
80
81private:
82 Operation m_op;
83};
84
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080085typedef boost::shared_ptr<DiffLeaf> DiffLeafPtr;
86
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080087} // Sync
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080088
89#endif // SYNC_DIFF_LEAF_H