blob: b8a9e69b7f0d87dfdb6d9cc44224a9c2e6c27cb2 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080019
Alexander Afanasyev0c395372014-12-20 15:54:02 -080020#include "batches.hpp"
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080021
22namespace ns3 {
23
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080024ATTRIBUTE_HELPER_CPP(Batches);
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080025
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080026std::ostream&
27operator<<(std::ostream& os, const Batches& batch)
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080028{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080029 for (Batches::const_iterator i = batch.begin(); i != batch.end(); i++)
Mickey Sweatt89046c12014-11-16 20:32:27 -080030 os << std::get<0>(*i) << " " << std::get<1>(*i) << " ";
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080031
32 return os;
33}
34
35/**
36 * \brief Read components from input and add them to components. Will read input stream till eof
37 * Substrings separated by slashes will become separate components
38 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080039std::istream&
40operator>>(std::istream& is, Batches& batch)
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080041{
42 Time time;
43 uint32_t amount;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080044 while (!is.eof()) {
45 is >> time >> amount;
46 batch.Add(time, amount);
47 // std::cout << time << ", " << amount << ". \n";
48 }
49
50 is.clear();
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080051 return is;
52}
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080053}