LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2015 Federico Guerra | 3 * Copyright (c) 2015 Federico Guerra |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 27 matching lines...) Expand all Loading... |
38 * | 38 * |
39 */ | 39 */ |
40 class WossRandomGenerator : public woss::RandomGenerator | 40 class WossRandomGenerator : public woss::RandomGenerator |
41 { | 41 { |
42 | 42 |
43 | 43 |
44 public: | 44 public: |
45 /** | 45 /** |
46 * Default constructor used within the WOSS framework. | 46 * Default constructor used within the WOSS framework. |
47 * The seed parameter allows the WOSS framework to abstract | 47 * The seed parameter allows the WOSS framework to abstract |
48 * from the wrapped random generator model. | 48 * from the wrapped random generator model,· |
49 * It creates an new object and it calls SetStream (seed) | 49 * however in the NS3 integration framework it is |
50 * on the private m_RandVar | 50 * not used. The RandomVar is created with default random· |
| 51 * generator seed, while the stream can be assigned via AssignStreams· |
51 * | 52 * |
52 * \param seed assigned stream | 53 * \param seed assigned stream |
53 */ | 54 */ |
54 WossRandomGenerator ( int seed = 0 ); | 55 WossRandomGenerator ( int seed = 0 ); |
55 | 56 |
56 /** | 57 /** |
57 * Copy constructor. | 58 * Copy constructor. |
58 * The returned object reflects the internal status of the source underlying | 59 * The returned object reflects the internal status of the source underlying |
59 * random var object. | 60 * random var object. |
60 * initialize () should be called if it wasn't previously called on the source
object | 61 * initialize () should be called if it wasn't previously called on the source
object |
61 */ | 62 */ |
62 WossRandomGenerator ( const WossRandomGenerator& copy ); | 63 WossRandomGenerator ( const WossRandomGenerator& copy ); |
63 | 64 |
64 /** | 65 /** |
65 * Assignment operator. | 66 * Assignment operator. |
66 * The returned reference reflects the internal status of the source underlyin
g | 67 * The returned reference reflects the internal status of the source underlyin
g |
67 * random var object. | 68 * random var object. |
68 * initialize () should be called if it wasn't previously called on the source
object | 69 * initialize () should be called if it wasn't previously called on the source
object |
69 */ | 70 */ |
70 WossRandomGenerator& operator= ( const WossRandomGenerator& copy ); | 71 WossRandomGenerator& operator= ( const WossRandomGenerator& copy ); |
71 | 72 |
72 virtual ~WossRandomGenerator (); | 73 virtual ~WossRandomGenerator (); |
73 | 74 |
74 /** | 75 /** |
75 * Mandatory virtual factory method that creates a new object. | 76 * Mandatory virtual factory method that creates a new object. |
76 * It is inherited and it is used within the WOSS framework. | 77 * It is inherited and it is used within the WOSS framework. |
77 * It creates an new object and it calls SetStream (seed) | 78 * It creates an new object; the seed parameter allows the WOSS framework to a
bstract |
78 * on the private m_RandVar | 79 * from the wrapped random generator model,· |
| 80 * however in the NS3 integration framework it is |
| 81 * not used. The RandomVar is created with default random· |
| 82 * generator seed, while the stream can be assigned via AssignStreams· |
| 83 * on the private m_RandVar |
79 * \param seed assigned stream | 84 * \param seed assigned stream |
80 */ | 85 */ |
81 virtual WossRandomGenerator* create ( int seed ); | 86 virtual WossRandomGenerator* create ( int seed ); |
82 | 87 |
83 /** | 88 /** |
84 * Mandatory virtual factory method that clones the current object. | 89 * Mandatory virtual factory method that clones the current object. |
85 * It is inherited from the WOSS framework. | 90 * It is inherited from the WOSS framework. |
86 * The returned object will draw from the same sub-stream of the source object
. | 91 * The returned object will draw from the same sub-stream of the source object
. |
87 */ | 92 */ |
88 virtual WossRandomGenerator* clone () const; | 93 virtual WossRandomGenerator* clone () const; |
89 | 94 |
90 /** | 95 /** |
91 * returns a random double numer | 96 * returns a random double numer |
92 * \returns a random double number | 97 * \returns a random double number |
93 */ | 98 */ |
94 virtual double getRand () const; | 99 virtual double getRand () const; |
95 | 100 |
96 /** | 101 /** |
97 * returns a random integer numer in range [0, INT_MAX] | 102 * returns a random integer numer in range [0, INT_MAX] |
98 * \returns a random integer number | 103 * \returns a random integer number |
99 */ | 104 */ |
100 virtual int getRandInt () const; | 105 virtual int getRandInt () const; |
101 | 106 |
102 /** | 107 /** |
103 * Mandatory initialization method inherited from the WOSS framework. | 108 * Mandatory initialization method inherited from the WOSS framework. |
104 * Usually a woss::RandomGenerator is created and then initialized | 109 * Usually a woss::RandomGenerator is created and then initialized |
105 * with this function. | 110 * with this function. |
106 * In the NS3 representation the user should use AssignStreams (). | |
107 * The initialization is performed only once. | 111 * The initialization is performed only once. |
108 * \see AssignStreams | 112 * \see AssignStreams |
109 */ | 113 */ |
110 virtual void initialize (); | 114 virtual void initialize (); |
111 | 115 |
112 | 116 |
113 /** | 117 /** |
114 * In the NS3 wrapper it should be used as initialization function. | 118 * In the NS3 wrapper it should be used to change the current stream used. |
115 * It calls SetStream () on the underlying m_RandVar. | 119 * It calls SetStream () on the underlying m_RandVar. |
116 * The initialization is always performed. | |
117 */ | 120 */ |
118 virtual int64_t AssignStreams (int64_t stream); | 121 virtual int64_t AssignStreams (int64_t stream); |
119 | 122 |
120 | 123 |
121 protected: | 124 protected: |
122 /** | 125 /** |
123 * The wrapped NS3 UniformRandomVariable random generator | 126 * The wrapped NS3 UniformRandomVariable random generator |
124 */ | 127 */ |
125 Ptr<UniformRandomVariable> m_RandVar; | 128 Ptr<UniformRandomVariable> m_RandVar; |
126 | 129 |
127 }; | 130 }; |
128 | 131 |
129 } | 132 } |
130 | 133 |
131 #endif /* WOSS_RANDOM_GENERATOR_H */ | 134 #endif /* WOSS_RANDOM_GENERATOR_H */ |
132 | 135 |
133 #endif /* NS3_WOSS_SUPPORT */ | 136 #endif /* NS3_WOSS_SUPPORT */ |
134 | 137 |
LEFT | RIGHT |