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 
32 namespace ns3
33 {
34 
89 class DataRate
90 {
91  public:
92  DataRate();
101  DataRate(uint64_t bps);
120  DataRate(std::string rate);
121 
127  DataRate operator+(DataRate rhs) const;
128 
135 
141  DataRate operator-(DataRate rhs) const;
142 
149 
159  DataRate operator*(double rhs) const;
160 
170  DataRate& operator*=(double rhs);
171 
179  DataRate operator*(uint64_t rhs) const;
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 
239  Time CalculateBytesTxTime(uint32_t bytes) const;
240 
248  Time CalculateBitsTxTime(uint32_t bits) const;
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 
286 std::ostream& operator<<(std::ostream& os, const DataRate& rate);
287 
295 std::istream& operator>>(std::istream& is, DataRate& rate);
296 
298 
307 double operator*(const DataRate& lhs, const Time& rhs);
316 double operator*(const Time& lhs, const DataRate& rhs);
317 
318 namespace TracedValueCallback
319 {
320 
328 typedef 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
friend std::istream & operator>>(std::istream &is, DataRate &rate)
Stream extraction operator.
Definition: data-rate.cc:331
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
DataRate operator-(DataRate rhs) const
Definition: data-rate.cc:214
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:207
DataRate operator+(DataRate rhs) const
Definition: data-rate.cc:201
DataRate operator*(double rhs) const
Scales the DataRate.
Definition: data-rate.cc:229
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
Definition: data-rate.cc:291
DataRate & operator-=(DataRate rhs)
Definition: data-rate.cc:221
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::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:153
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129