blob: aa3b366053723e611552a99eacc7b17f091c775b [file] [log] [blame]
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Lijing Wange84adea2015-05-31 16:25:16 -07003 * Copyright (c) 2013-2017, Regents of the University of California.
Alexander Afanasyev49a30d02013-01-21 21:38:48 -08004 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08005 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
Alexander Afanasyev49a30d02013-01-21 21:38:48 -08006 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08007 * 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 Afanasyev49a30d02013-01-21 21:38:48 -080010 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080011 * 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 Afanasyev49a30d02013-01-21 21:38:48 -080014 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080015 * 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 Afanasyev49a30d02013-01-21 21:38:48 -080019 */
20
Lijing Wange84adea2015-05-31 16:25:16 -070021#ifndef CHRONOSHARE_SRC_SYNC_STATE_HELPER_HPP
22#define CHRONOSHARE_SRC_SYNC_STATE_HELPER_HPP
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080023
Lijing Wange84adea2015-05-31 16:25:16 -070024#include "core/chronoshare-common.hpp"
25
26#include "sync-state.pb.h"
27
28namespace ndn {
29namespace chronoshare {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080030
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080031inline std::ostream&
32operator<<(std::ostream& os, const SyncStateMsgPtr& msg)
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080033{
34 os << " ===== start Msg ======" << std::endl;
35
36 int size = msg->state_size();
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080037 if (size > 0) {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080038 int index = 0;
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080039 while (index < size) {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080040 SyncState state = msg->state(index);
Lijing Wange84adea2015-05-31 16:25:16 -070041 std::string strName = state.name();
42 std::string strLocator = state.locator();
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080043 sqlite3_int64 seq = state.seq();
44
Lijing Wange84adea2015-05-31 16:25:16 -070045 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 Afanasyev49a30d02013-01-21 21:38:48 -080047 << ", seq: " << seq << std::endl;
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080048 index++;
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080049 }
50 }
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080051 else {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080052 os << "Msg size 0" << std::endl;
53 }
54 os << " ++++++++ end Msg ++++++++ " << std::endl;
55
56 return os;
57}
58
Lijing Wange84adea2015-05-31 16:25:16 -070059} // namespace chronoshare
60} // namespace ndn
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080061
Lijing Wange84adea2015-05-31 16:25:16 -070062#endif // CHRONOSHARE_SRC_SYNC_STATE_HELPER_HPP