A Discrete-Event Network Simulator
API
data-rate.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 //
3 // Copyright (c) 2006 Georgia Tech Research Corporation
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: Rajib Bhattacharjea<raj.b@gatech.edu>
19 //
20 
21 #ifndef DATA_RATE_H
22 #define DATA_RATE_H
23 
24 #include <string>
25 #include <iostream>
26 #include <stdint.h>
27 #include "ns3/nstime.h"
28 #include "ns3/attribute.h"
29 #include "ns3/attribute-helper.h"
30 
31 namespace ns3 {
32 
87 class DataRate
88 {
89 public:
90  DataRate ();
99  DataRate (uint64_t bps);
118  DataRate (std::string rate);
119 
125  bool operator < (const DataRate& rhs) const;
126 
132  bool operator <= (const DataRate& rhs) const;
133 
139  bool operator > (const DataRate& rhs) const;
140 
146  bool operator >= (const DataRate& rhs) const;
147 
153  bool operator == (const DataRate& rhs) const;
154 
160  bool operator != (const DataRate& rhs) const;
161 
169  double CalculateTxTime (uint32_t bytes) const;
170 
175  uint64_t GetBitRate () const;
176 
177 private:
178 
193  static bool DoParse (const std::string s, uint64_t *v);
194 
195  // Uses DoParse
196  friend std::istream &operator >> (std::istream &is, DataRate &rate);
197 
198  uint64_t m_bps;
199 };
200 
208 std::ostream &operator << (std::ostream &os, const DataRate &rate);
209 
217 std::istream &operator >> (std::istream &is, DataRate &rate);
218 
220 
221 
230 double operator* (const DataRate& lhs, const Time& rhs);
239 double operator* (const Time& lhs, const DataRate& rhs);
240 
241 
242 } // namespace ns3
243 
244 #endif /* DATA_RATE_H */
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
bool operator<(const DataRate &rhs) const
Definition: data-rate.cc:199
bool operator>(const DataRate &rhs) const
Definition: data-rate.cc:209
uint64_t m_bps
data rate [bps]
Definition: data-rate.h:198
static bool DoParse(const std::string s, uint64_t *v)
Parse a string representing a DataRate into an uint64_t.
Definition: data-rate.cc:34
Class for representing data rates.
Definition: data-rate.h:87
double CalculateTxTime(uint32_t bytes) const
Calculate transmission time.
Definition: data-rate.cc:229
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
Definition: int64x64.h:102
Ptr< SampleEmitter > s
friend std::istream & operator>>(std::istream &is, DataRate &rate)
Stream extraction operator.
Definition: data-rate.cc:258
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:235
bool operator<=(const DataRate &rhs) const
Definition: data-rate.cc:204
bool operator>=(const DataRate &rhs) const
Definition: data-rate.cc:214
bool operator!=(const DataRate &rhs) const
Definition: data-rate.cc:224
bool operator==(const DataRate &rhs) const
Definition: data-rate.cc:219
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type.