blob: 084b5fc2a0e33aca20b24653b3a7a2af2ec364bf [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 */
Alexander Afanasyeve00ffbe2012-03-05 00:01:36 -080052 DiffLeaf (NameInfoConstPtr info, const SeqNo &seq);
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080053
54 /**
55 * @brief Constructor to create an REMOVE diff leaf
56 * @param info Smart pointer to leaf's name
57 *
58 * This constructor creates a leaf with phony sequence number
59 * with 0 session ID and 0 sequence number
60 */
Alexander Afanasyeve00ffbe2012-03-05 00:01:36 -080061 DiffLeaf (NameInfoConstPtr info);
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080062
Alexander Afanasyeve00ffbe2012-03-05 00:01:36 -080063 virtual ~DiffLeaf () { }
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080064
Alexander Afanasyeve00ffbe2012-03-05 00:01:36 -080065 /**
66 * @brief Get diff leaf type
67 */
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080068 Operation
Alexander Afanasyeve00ffbe2012-03-05 00:01:36 -080069 getOperation () const { return m_op; }
70
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080071private:
72 Operation m_op;
73};
74
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080075typedef boost::shared_ptr<DiffLeaf> DiffLeafPtr;
76
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080077} // Sync
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080078
79#endif // SYNC_DIFF_LEAF_H