Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 669cafd | 2012-11-06 10:17:33 -0800 | [diff] [blame] | 21 | #include "batches.h" |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 22 | |
| 23 | namespace ns3 { |
| 24 | |
| 25 | ATTRIBUTE_HELPER_CPP (Batches); |
| 26 | |
| 27 | std::ostream & |
| 28 | operator << (std::ostream &os, const Batches &batch) |
| 29 | { |
| 30 | for (Batches::const_iterator i = batch.begin (); i != batch.end (); i++) |
| 31 | os << i->get<0> () << " " << i->get<1> () << " "; |
| 32 | |
| 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 | */ |
| 40 | std::istream & |
| 41 | operator >> (std::istream &is, Batches &batch) |
| 42 | { |
| 43 | Time time; |
| 44 | uint32_t amount; |
| 45 | while (!is.eof ()) |
| 46 | { |
| 47 | is >> time >> amount; |
| 48 | batch.Add (time, amount); |
| 49 | // std::cout << time << ", " << amount << ". \n"; |
| 50 | } |
| 51 | |
| 52 | is.clear (); |
| 53 | return is; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | } |