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> |
| 19 | * 卞超轶 Chaoyi Bian <bcy@pku.edu.cn> |
| 20 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 21 | */ |
| 22 | |
| 23 | #ifndef SYNC_FULL_STATE_H |
| 24 | #define SYNC_FULL_STATE_H |
| 25 | |
Alexander Afanasyev | 146a51b | 2012-03-05 10:47:35 -0800 | [diff] [blame^] | 26 | #ifndef STANDALONE |
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; |
| 34 | #endif // STANDALONE |
| 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 | |
| 40 | /** |
| 41 | * \ingroup sync |
| 42 | * @brief Cumulative SYNC state |
| 43 | */ |
| 44 | class FullState : public State |
| 45 | { |
| 46 | public: |
| 47 | /** |
| 48 | * @brief Default constructor |
| 49 | */ |
| 50 | FullState (); |
| 51 | virtual ~FullState (); |
| 52 | |
| 53 | /** |
| 54 | * @brief Get time period since last state update |
| 55 | * |
| 56 | * This value can be used to randomize reconciliation waiting time in SyncApp |
| 57 | */ |
Alexander Afanasyev | 146a51b | 2012-03-05 10:47:35 -0800 | [diff] [blame^] | 58 | TimeDurationType |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 59 | getTimeFromLastUpdate () const; |
Alexander Afanasyev | d94542d | 2012-03-05 08:41:46 -0800 | [diff] [blame] | 60 | |
| 61 | /** |
| 62 | * @brief Obtain a read-only copy of the digest |
| 63 | * |
| 64 | * If m_digest is 0, then it is automatically created. On every update and removal, m_digest is reset to 0 |
| 65 | */ |
| 66 | DigestConstPtr |
| 67 | getDigest (); |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 68 | |
| 69 | // from State |
| 70 | virtual void |
| 71 | update (NameInfoConstPtr info, const SeqNo &seq); |
| 72 | |
| 73 | virtual void |
| 74 | remove (NameInfoConstPtr info); |
| 75 | |
| 76 | private: |
Alexander Afanasyev | 146a51b | 2012-03-05 10:47:35 -0800 | [diff] [blame^] | 77 | TimeType m_lastUpdated; ///< @brief Time when state was updated last time |
Alexander Afanasyev | d94542d | 2012-03-05 08:41:46 -0800 | [diff] [blame] | 78 | DigestPtr m_digest; |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | |
| 82 | } // Sync |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 83 | |
| 84 | #endif // SYNC_STATE_H |