blob: 35f66cc6f36ac59f9ca2d743a10ef789585262b9 [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
20#ifndef _BATCHES_H_
21#define _BATCHES_H_
22
23#include "ns3/attribute.h"
24#include "ns3/attribute-helper.h"
25#include "ns3/nstime.h"
26#include <list>
Mickey Sweatt89046c12014-11-16 20:32:27 -080027#include <tuple>
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080028
29namespace ns3 {
30
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070031/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070032 * @ingroup ndn-apps
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080033 * @brief Class representing sets of (time, number) tuples with support of reading writing to
34 * streams
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070035 */
Mickey Sweatt89046c12014-11-16 20:32:27 -080036class Batches : public std::list<std::tuple<Time, uint32_t>> {
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080037public:
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070038 /**
39 * @brief Default constructor
40 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041 Batches(){};
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080042
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070043 /**
44 * @brief Add tuple
45 * @param when time for the tuple
46 * @param amount number for the tuple
47 */
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080048 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049 Add(const Time& when, uint32_t amount)
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080050 {
Mickey Sweatt89046c12014-11-16 20:32:27 -080051 push_back(std::make_tuple(when, amount));
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080052 }
53};
54
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055ATTRIBUTE_HELPER_HEADER(Batches);
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080056
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070057/**
58 * @brief Output contents of the Batches to the std::ostream
59 * @param os reference to std::ostream
60 * @param batch constant reference to Batch object
61 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080062std::ostream&
63operator<<(std::ostream& os, const Batches& batch);
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080064
65/**
66 * \brief Read components from input and add them to components. Will read input stream till eof
67 * Substrings separated by slashes will become separate components
68 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069std::istream&
70operator>>(std::istream& is, Batches& batch);
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080071
72} // namespace ns3
73
74#endif // _BATCHES_H_