Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [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> |
Chaoyi Bian | 3e1eb16 | 2012-04-03 16:59:32 -0700 | [diff] [blame] | 19 | * Chaoyi Bian <bcy@pku.edu.cn> |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 20 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 21 | */ |
| 22 | |
| 23 | #ifndef SYNC_FULL_STATE_H |
| 24 | #define SYNC_FULL_STATE_H |
| 25 | |
Zhenkai Zhu | ea02698 | 2012-06-01 16:00:25 -0700 | [diff] [blame] | 26 | #ifdef NS3_MODULE |
Alexander Afanasyev | b5547e3 | 2012-03-01 21:59:38 -0800 | [diff] [blame] | 27 | #include "ns3/nstime.h" |
Alexander Afanasyev | 146a51b | 2012-03-05 10:47:35 -0800 | [diff] [blame] | 28 | typedef ns3::Time TimeType; |
| 29 | typedef ns3::Time TimeDurationType; |
| 30 | #else |
| 31 | #include <boost/date_time/posix_time/posix_time_types.hpp> |
| 32 | typedef boost::posix_time::ptime TimeType; |
| 33 | typedef boost::posix_time::time_duration TimeDurationType; |
Zhenkai Zhu | ea02698 | 2012-06-01 16:00:25 -0700 | [diff] [blame] | 34 | #endif // NS3_MODULE |
Alexander Afanasyev | 146a51b | 2012-03-05 10:47:35 -0800 | [diff] [blame] | 35 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 36 | #include "sync-state.h" |
| 37 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 38 | namespace Sync { |
| 39 | |
Alexander Afanasyev | f3c03a9 | 2012-05-09 12:00:37 -0700 | [diff] [blame] | 40 | class FullState; |
| 41 | typedef boost::shared_ptr<FullState> FullStatePtr; |
| 42 | typedef boost::shared_ptr<FullState> FullStateConstPtr; |
| 43 | |
| 44 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 45 | /** |
| 46 | * \ingroup sync |
| 47 | * @brief Cumulative SYNC state |
| 48 | */ |
| 49 | class FullState : public State |
| 50 | { |
| 51 | public: |
| 52 | /** |
| 53 | * @brief Default constructor |
| 54 | */ |
| 55 | FullState (); |
| 56 | virtual ~FullState (); |
| 57 | |
| 58 | /** |
| 59 | * @brief Get time period since last state update |
| 60 | * |
| 61 | * This value can be used to randomize reconciliation waiting time in SyncApp |
| 62 | */ |
Alexander Afanasyev | 146a51b | 2012-03-05 10:47:35 -0800 | [diff] [blame] | 63 | TimeDurationType |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 64 | getTimeFromLastUpdate () const; |
Alexander Afanasyev | d94542d | 2012-03-05 08:41:46 -0800 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * @brief Obtain a read-only copy of the digest |
| 68 | * |
| 69 | * If m_digest is 0, then it is automatically created. On every update and removal, m_digest is reset to 0 |
| 70 | */ |
| 71 | DigestConstPtr |
| 72 | getDigest (); |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 73 | |
| 74 | // from State |
Alexander Afanasyev | 750d187 | 2012-03-12 15:33:56 -0700 | [diff] [blame] | 75 | virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/> |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 76 | update (NameInfoConstPtr info, const SeqNo &seq); |
| 77 | |
Alexander Afanasyev | e4e2bf7 | 2012-03-12 12:44:54 -0700 | [diff] [blame] | 78 | virtual bool |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 79 | remove (NameInfoConstPtr info); |
| 80 | |
| 81 | private: |
Alexander Afanasyev | 146a51b | 2012-03-05 10:47:35 -0800 | [diff] [blame] | 82 | TimeType m_lastUpdated; ///< @brief Time when state was updated last time |
Alexander Afanasyev | d94542d | 2012-03-05 08:41:46 -0800 | [diff] [blame] | 83 | DigestPtr m_digest; |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 86 | } // Sync |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 87 | |
| 88 | #endif // SYNC_STATE_H |