blob: b5bb7cf5237e6dd572f005d008bd99efa722f621 [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#include "sync-diff-state.h"
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080024#include "sync-diff-leaf.h"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080025
26#include <boost/make_shared.hpp>
27
28using namespace boost;
29
30namespace ns3 {
31namespace Sync {
32
33DiffState::DiffState ()
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080034{
35}
36
37DiffState::~DiffState ()
38{
39}
40
41DiffStatePtr
42DiffState::diff () const
43{
44 DiffStatePtr ret = make_shared<DiffState> ();
45
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080046 DiffStatePtr state = m_next;
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080047 while (state != 0)
48 {
49 *ret += *state;
50 state = state->m_next;
51 }
52
53 return ret;
54}
55
56DiffState &
57DiffState::operator += (const DiffState &state)
58{
59 return *this;
60}
61
62// from State
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080063void
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080064DiffState::update (NameInfoConstPtr info, const SeqNo &seq)
65{
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080066 m_leaves.erase (*info);
67
68 DiffLeafPtr leaf = make_shared<DiffLeaf> (info, cref (seq));
69 m_leaves.insert (leaf);
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080070}
71
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080072void
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080073DiffState::remove (NameInfoConstPtr info)
74{
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080075 m_leaves.erase (*info);
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080076
Alexander Afanasyevb5547e32012-03-01 21:59:38 -080077 DiffLeafPtr leaf = make_shared<DiffLeaf> (info);
78 m_leaves.insert (leaf);
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080079}
80
81
82} // ns3
83} // Sync