A Discrete-Event Network Simulator
API
data-rate.h
Go to the documentation of this file.
1//
2// Copyright (c) 2006 Georgia Tech Research Corporation
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License version 2 as
6// published by the Free Software Foundation;
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// Author: Rajib Bhattacharjea<raj.b@gatech.edu>
18//
19
20#ifndef DATA_RATE_H
21#define DATA_RATE_H
22
23#include "ns3/attribute-helper.h"
24#include "ns3/attribute.h"
25#include "ns3/deprecated.h"
26#include "ns3/nstime.h"
27
28#include <iostream>
29#include <stdint.h>
30#include <string>
31
32namespace ns3
33{
34
90{
91 public:
92 DataRate();
101 DataRate(uint64_t bps);
120 DataRate(std::string rate);
121
128
135
142
149
159 DataRate operator*(double rhs);
160
170 DataRate& operator*=(double rhs);
171
179 DataRate operator*(uint64_t rhs);
180
188 DataRate& operator*=(uint64_t rhs);
189
195 bool operator<(const DataRate& rhs) const;
196
202 bool operator<=(const DataRate& rhs) const;
203
209 bool operator>(const DataRate& rhs) const;
210
216 bool operator>=(const DataRate& rhs) const;
217
223 bool operator==(const DataRate& rhs) const;
224
230 bool operator!=(const DataRate& rhs) const;
231
240
249
254 uint64_t GetBitRate() const;
255
256 private:
271 static bool DoParse(const std::string s, uint64_t* v);
272
273 // Uses DoParse
274 friend std::istream& operator>>(std::istream& is, DataRate& rate);
275
276 uint64_t m_bps;
277};
278
286std::ostream& operator<<(std::ostream& os, const DataRate& rate);
287
295std::istream& operator>>(std::istream& is, DataRate& rate);
296
298
307double operator*(const DataRate& lhs, const Time& rhs);
316double operator*(const Time& lhs, const DataRate& rhs);
317
318namespace TracedValueCallback
319{
320
328typedef void (*DataRate)(DataRate oldValue, DataRate newValue);
329
330} // namespace TracedValueCallback
331
332} // namespace ns3
333
334#endif /* DATA_RATE_H */
Class for representing data rates.
Definition: data-rate.h:90
DataRate & operator*=(double rhs)
Scales the DataRate.
Definition: data-rate.cc:235
bool operator==(const DataRate &rhs) const
Definition: data-rate.cc:279
bool operator<(const DataRate &rhs) const
Definition: data-rate.cc:255
bool operator>(const DataRate &rhs) const
Definition: data-rate.cc:267
bool operator!=(const DataRate &rhs) const
Definition: data-rate.cc:285
bool operator>=(const DataRate &rhs) const
Definition: data-rate.cc:273
Time CalculateBitsTxTime(uint32_t bits) const
Calculate transmission time.
Definition: data-rate.cc:298
static bool DoParse(const std::string s, uint64_t *v)
Parse a string representing a DataRate into an uint64_t.
Definition: data-rate.cc:35
uint64_t m_bps
data rate [bps]
Definition: data-rate.h:276
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:305
bool operator<=(const DataRate &rhs) const
Definition: data-rate.cc:261
DataRate operator-(DataRate rhs)
Definition: data-rate.cc:214
DataRate operator*(double rhs)
Scales the DataRate.
Definition: data-rate.cc:229
DataRate operator+(DataRate rhs)
Definition: data-rate.cc:201
DataRate & operator+=(DataRate rhs)
Definition: data-rate.cc:207
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
Definition: data-rate.cc:291
DataRate & operator-=(DataRate rhs)
Definition: data-rate.cc:221
friend std::istream & operator>>(std::istream &is, DataRate &rate)
Stream extraction operator.
Definition: data-rate.cc:331
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
Definition: int64x64.h:118
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ATTRIBUTE_HELPER_HEADER(ValueClassTest)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:153