Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Lijing Wang | e84adea | 2015-05-31 16:25:16 -0700 | [diff] [blame] | 3 | * Copyright (c) 2013-2017, Regents of the University of California. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 5 | * This file is part of ChronoShare, a decentralized file sharing application over NDN. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 7 | * ChronoShare is free software: you can redistribute it and/or modify it under the terms |
| 8 | * of the GNU General Public License as published by the Free Software Foundation, either |
| 9 | * version 3 of the License, or (at your option) any later version. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 11 | * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 14 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 15 | * You should have received copies of the GNU General Public License along with |
| 16 | * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * See AUTHORS.md for complete list of ChronoShare authors and contributors. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
Lijing Wang | e84adea | 2015-05-31 16:25:16 -0700 | [diff] [blame] | 21 | #ifndef CHRONOSHARE_SRC_SYNC_STATE_HELPER_HPP |
| 22 | #define CHRONOSHARE_SRC_SYNC_STATE_HELPER_HPP |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 23 | |
Lijing Wang | e84adea | 2015-05-31 16:25:16 -0700 | [diff] [blame] | 24 | #include "core/chronoshare-common.hpp" |
| 25 | |
| 26 | #include "sync-state.pb.h" |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace chronoshare { |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 30 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 31 | inline std::ostream& |
| 32 | operator<<(std::ostream& os, const SyncStateMsgPtr& msg) |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 33 | { |
| 34 | os << " ===== start Msg ======" << std::endl; |
| 35 | |
| 36 | int size = msg->state_size(); |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 37 | if (size > 0) { |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 38 | int index = 0; |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 39 | while (index < size) { |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 40 | SyncState state = msg->state(index); |
Lijing Wang | e84adea | 2015-05-31 16:25:16 -0700 | [diff] [blame] | 41 | std::string strName = state.name(); |
| 42 | std::string strLocator = state.locator(); |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 43 | sqlite3_int64 seq = state.seq(); |
| 44 | |
Lijing Wang | e84adea | 2015-05-31 16:25:16 -0700 | [diff] [blame] | 45 | os << "Name: " << Name(Block((const unsigned char*)strName.c_str(), strName.size())).toUri() |
| 46 | << ", Locator: " << Name(Block((const unsigned char*)strLocator.c_str(), strLocator.size())) |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 47 | << ", seq: " << seq << std::endl; |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 48 | index++; |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 49 | } |
| 50 | } |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 51 | else { |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 52 | os << "Msg size 0" << std::endl; |
| 53 | } |
| 54 | os << " ++++++++ end Msg ++++++++ " << std::endl; |
| 55 | |
| 56 | return os; |
| 57 | } |
| 58 | |
Lijing Wang | e84adea | 2015-05-31 16:25:16 -0700 | [diff] [blame] | 59 | } // namespace chronoshare |
| 60 | } // namespace ndn |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 61 | |
Lijing Wang | e84adea | 2015-05-31 16:25:16 -0700 | [diff] [blame] | 62 | #endif // CHRONOSHARE_SRC_SYNC_STATE_HELPER_HPP |