blob: bce3d96117c4f5e0cd74889a2f2395013d48992a [file] [log] [blame]
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011,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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
Alexander Afanasyev0c395372014-12-20 15:54:02 -080021#include "batches.hpp"
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080022
23namespace ns3 {
24
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080025ATTRIBUTE_HELPER_CPP(Batches);
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080026
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080027std::ostream&
28operator<<(std::ostream& os, const Batches& batch)
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080029{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080030 for (Batches::const_iterator i = batch.begin(); i != batch.end(); i++)
Mickey Sweatt89046c12014-11-16 20:32:27 -080031 os << std::get<0>(*i) << " " << std::get<1>(*i) << " ";
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080032
33 return os;
34}
35
36/**
37 * \brief Read components from input and add them to components. Will read input stream till eof
38 * Substrings separated by slashes will become separate components
39 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040std::istream&
41operator>>(std::istream& is, Batches& batch)
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080042{
43 Time time;
44 uint32_t amount;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 while (!is.eof()) {
46 is >> time >> amount;
47 batch.Add(time, amount);
48 // std::cout << time << ", " << amount << ". \n";
49 }
50
51 is.clear();
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080052 return is;
53}
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080054}