194 * occur. |
238 * occur. |
195 * \param s The string to parse into a Time |
239 * \param s The string to parse into a Time |
196 */ |
240 */ |
197 explicit Time (const std::string & s); |
241 explicit Time (const std::string & s); |
198 |
242 |
199 /** |
243 /** Minimum representable Time */ |
200 * \brief Minimum representable Time |
|
201 */ |
|
202 static Time Min () |
244 static Time Min () |
203 { |
245 { |
204 return Time (std::numeric_limits<int64_t>::min ()); |
246 return Time (std::numeric_limits<int64_t>::min ()); |
205 } |
247 } |
206 /** |
248 /** Maximum representable Time */ |
207 * \brief Maximum representable Time |
|
208 */ |
|
209 static Time Max () |
249 static Time Max () |
210 { |
250 { |
211 return Time (std::numeric_limits<int64_t>::max ()); |
251 return Time (std::numeric_limits<int64_t>::max ()); |
212 } |
252 } |
213 |
253 |
214 /** |
254 /** Destructor */ |
215 * Destructor |
|
216 */ |
|
217 ~Time () |
255 ~Time () |
218 { |
256 { |
219 if (g_markingTimes) |
257 if (g_markingTimes) |
220 { |
258 { |
221 Clear (this); |
259 Clear (this); |
222 } |
260 } |
223 } |
261 } |
224 |
262 |
225 /** |
263 /** \return true if the time is zero, false otherwise. */ |
226 * \return true if the time is zero, false otherwise. |
|
227 */ |
|
228 inline bool IsZero (void) const |
264 inline bool IsZero (void) const |
229 { |
265 { |
230 return m_data == 0; |
266 return m_data == 0; |
231 } |
267 } |
232 /** |
268 /** \return true if the time is negative or zero, false otherwise. */ |
233 * \return true if the time is negative or zero, false otherwise. |
|
234 */ |
|
235 inline bool IsNegative (void) const |
269 inline bool IsNegative (void) const |
236 { |
270 { |
237 return m_data <= 0; |
271 return m_data <= 0; |
238 } |
272 } |
239 /** |
273 /** \return true if the time is positive or zero, false otherwise. */ |
240 * \return true if the time is positive or zero, false otherwise. |
|
241 */ |
|
242 inline bool IsPositive (void) const |
274 inline bool IsPositive (void) const |
243 { |
275 { |
244 return m_data >= 0; |
276 return m_data >= 0; |
245 } |
277 } |
246 /** |
278 /** \return true if the time is strictly negative, false otherwise. */ |
247 * \return true if the time is strictly negative, false otherwise. |
|
248 */ |
|
249 inline bool IsStrictlyNegative (void) const |
279 inline bool IsStrictlyNegative (void) const |
250 { |
280 { |
251 return m_data < 0; |
281 return m_data < 0; |
252 } |
282 } |
253 /** |
283 /** \return true if the time is strictly positive, false otherwise. */ |
254 * \return true if the time is strictly positive, false otherwise. |
|
255 */ |
|
256 inline bool IsStrictlyPositive (void) const |
284 inline bool IsStrictlyPositive (void) const |
257 { |
285 { |
258 return m_data > 0; |
286 return m_data > 0; |
259 } |
287 } |
260 /** |
288 /** |
|
289 * Compare \p this to another Time |
|
290 * |
|
291 * \param [in] o The other Time |
261 * \return -1,0,+1 if `this < o`, `this == o`, or `this > o` |
292 * \return -1,0,+1 if `this < o`, `this == o`, or `this > o` |
262 */ |
293 */ |
263 inline int Compare (const Time & o) const |
294 inline int Compare (const Time & o) const |
264 { |
295 { |
265 return (m_data < o.m_data) ? -1 : (m_data == o.m_data) ? 0 : 1; |
296 return (m_data < o.m_data) ? -1 : (m_data == o.m_data) ? 0 : 1; |
266 } |
297 } |
267 |
298 |
268 /** |
299 /** |
269 * \returns an approximation in seconds of the time stored in this |
300 * Get an approximation of the time stored in this instance |
270 * instance. |
301 * in the indicated unit. |
271 */ |
302 * |
|
303 * \return An approximate value in the indicated unit. |
|
304 * @{ |
|
305 */ |
|
306 inline double GetYears (void) const |
|
307 { |
|
308 return ToDouble (Time::Y); |
|
309 } |
|
310 inline double GetDays (void) const |
|
311 { |
|
312 return ToDouble (Time::D); |
|
313 } |
|
314 inline double GetHours (void) const |
|
315 { |
|
316 return ToDouble (Time::H); |
|
317 } |
|
318 inline double GetMinutes (void) const |
|
319 { |
|
320 return ToDouble (Time::MIN); |
|
321 } |
272 inline double GetSeconds (void) const |
322 inline double GetSeconds (void) const |
273 { |
323 { |
274 return ToDouble (Time::S); |
324 return ToDouble (Time::S); |
275 } |
325 } |
276 |
|
277 /** |
|
278 * \returns an approximation in milliseconds of the time stored in this |
|
279 * instance. |
|
280 */ |
|
281 inline int64_t GetMilliSeconds (void) const |
326 inline int64_t GetMilliSeconds (void) const |
282 { |
327 { |
283 return ToInteger (Time::MS); |
328 return ToInteger (Time::MS); |
284 } |
329 } |
285 /** |
|
286 * \returns an approximation in microseconds of the time stored in this |
|
287 * instance. |
|
288 */ |
|
289 inline int64_t GetMicroSeconds (void) const |
330 inline int64_t GetMicroSeconds (void) const |
290 { |
331 { |
291 return ToInteger (Time::US); |
332 return ToInteger (Time::US); |
292 } |
333 } |
293 /** |
|
294 * \returns an approximation in nanoseconds of the time stored in this |
|
295 * instance. |
|
296 */ |
|
297 inline int64_t GetNanoSeconds (void) const |
334 inline int64_t GetNanoSeconds (void) const |
298 { |
335 { |
299 return ToInteger (Time::NS); |
336 return ToInteger (Time::NS); |
300 } |
337 } |
301 /** |
|
302 * \returns an approximation in picoseconds of the time stored in this |
|
303 * instance. |
|
304 */ |
|
305 inline int64_t GetPicoSeconds (void) const |
338 inline int64_t GetPicoSeconds (void) const |
306 { |
339 { |
307 return ToInteger (Time::PS); |
340 return ToInteger (Time::PS); |
308 } |
341 } |
309 /** |
|
310 * \returns an approximation in femtoseconds of the time stored in this |
|
311 * instance. |
|
312 */ |
|
313 inline int64_t GetFemtoSeconds (void) const |
342 inline int64_t GetFemtoSeconds (void) const |
314 { |
343 { |
315 return ToInteger (Time::FS); |
344 return ToInteger (Time::FS); |
316 } |
345 } |
317 |
346 /**@}*/ |
318 /** |
347 |
319 * \returns an approximation in minutes of the time stored in this |
348 /** |
320 * instance. |
349 * \returns the raw time value, in the current unit |
321 */ |
350 * @{ |
322 inline double GetMinutes (void) const |
|
323 { |
|
324 return ToDouble (Time::MIN); |
|
325 } |
|
326 /** |
|
327 * \returns an approximation in hours of the time stored in this |
|
328 * instance. |
|
329 */ |
|
330 inline double GetHours (void) const |
|
331 { |
|
332 return ToDouble (Time::H); |
|
333 } |
|
334 /** |
|
335 * \returns an approximation in days of the time stored in this |
|
336 * instance. |
|
337 */ |
|
338 inline double GetDays (void) const |
|
339 { |
|
340 return ToDouble (Time::D); |
|
341 } |
|
342 /** |
|
343 * \returns an approximation in years of the time stored in this |
|
344 * instance. |
|
345 */ |
|
346 inline double GetYears (void) const |
|
347 { |
|
348 return ToDouble (Time::Y); |
|
349 } |
|
350 |
|
351 /** |
|
352 * \returns the raw time value, in the current units |
|
353 */ |
351 */ |
354 inline int64_t GetTimeStep (void) const |
352 inline int64_t GetTimeStep (void) const |
355 { |
353 { |
356 return m_data; |
354 return m_data; |
357 } |
355 } |
375 static void SetResolution (enum Unit resolution); |
374 static void SetResolution (enum Unit resolution); |
376 /** |
375 /** |
377 * \returns the current global resolution. |
376 * \returns the current global resolution. |
378 */ |
377 */ |
379 static enum Unit GetResolution (void); |
378 static enum Unit GetResolution (void); |
380 /** |
379 |
381 * \param value to convert into a Time object |
380 |
382 * \param timeUnit the unit of the value to convert |
381 /** |
383 * \return a new Time object |
382 * Create a Time in the current unit. |
384 * |
383 * |
385 * This method interprets the input value according to the input |
384 * \param [in] value The value of the new Time. |
386 * unit and constructs a matching Time object. |
385 * \return A Time with \p value in the current time unit. |
387 * |
386 */ |
388 * \sa FromDouble, ToDouble, ToInteger |
387 inline static Time From (const int64x64_t & value) |
389 */ |
388 { |
390 inline static Time FromInteger (uint64_t value, enum Unit timeUnit) |
389 return Time (value); |
391 { |
390 } |
392 struct Information *info = PeekInformation (timeUnit); |
391 /** |
|
392 * Create a Time equal to \p value in unit \c unit |
|
393 * |
|
394 * \param [in] value The new Time value, expressed in \c unit |
|
395 * \param [in] unit The unit of \p value |
|
396 * \return The Time representing \p value in \c unit |
|
397 * @{ |
|
398 */ |
|
399 inline static Time FromInteger (uint64_t value, enum Unit unit) |
|
400 { |
|
401 struct Information *info = PeekInformation (unit); |
393 if (info->fromMul) |
402 if (info->fromMul) |
394 { |
403 { |
395 value *= info->factor; |
404 value *= info->factor; |
396 } |
405 } |
397 else |
406 else |
398 { |
407 { |
399 value /= info->factor; |
408 value /= info->factor; |
400 } |
409 } |
401 return Time (value); |
410 return Time (value); |
402 } |
411 } |
403 /** |
412 inline static Time FromDouble (double value, enum Unit unit) |
404 * \param timeUnit the unit of the value to return |
413 { |
405 * \return int64_t time value |
414 return From (int64x64_t (value), unit); |
406 * |
415 } |
407 * Convert the input time into an integer value according to the requested |
416 inline static Time From (const int64x64_t & value, enum Unit unit) |
408 * time unit. |
417 { |
409 */ |
418 struct Information *info = PeekInformation (unit); |
410 inline int64_t ToInteger (enum Unit timeUnit) const |
419 // DO NOT REMOVE this temporary variable. It's here |
411 { |
420 // to work around a compiler bug in gcc 3.4 |
412 struct Information *info = PeekInformation (timeUnit); |
421 int64x64_t retval = value; |
|
422 if (info->fromMul) |
|
423 { |
|
424 retval *= info->timeFrom; |
|
425 } |
|
426 else |
|
427 { |
|
428 retval.MulByInvert (info->timeFrom); |
|
429 } |
|
430 return Time (retval); |
|
431 } |
|
432 /**@}*/ |
|
433 |
|
434 |
|
435 /** |
|
436 * Get the Time value expressed in a particular unit. |
|
437 * |
|
438 * \param [in] unit The desired unit |
|
439 * \return The Time expressed in \p unit |
|
440 * @{ |
|
441 */ |
|
442 inline int64_t ToInteger (enum Unit unit) const |
|
443 { |
|
444 struct Information *info = PeekInformation (unit); |
413 int64_t v = m_data; |
445 int64_t v = m_data; |
414 if (info->toMul) |
446 if (info->toMul) |
415 { |
447 { |
416 v *= info->factor; |
448 v *= info->factor; |
417 } |
449 } |
499 * std::cout << t.As (Time::MS) << std::endl; |
490 * std::cout << t.As (Time::MS) << std::endl; |
500 * \endcode |
491 * \endcode |
501 * will print ``+3140.0ms`` |
492 * will print ``+3140.0ms`` |
502 * |
493 * |
503 * \param unit [in] The unit to use. |
494 * \param unit [in] The unit to use. |
|
495 * \return The Time with embedded unit. |
504 */ |
496 */ |
505 TimeWithUnit As (const enum Unit unit) const; |
497 TimeWithUnit As (const enum Unit unit) const; |
506 |
498 |
507 private: |
499 private: |
508 /** |
500 /** How to convert between other units and the current unit. */ |
509 * How to convert between other units and the current unit |
|
510 */ |
|
511 struct Information |
501 struct Information |
512 { |
502 { |
513 bool toMul; //!< Multiply when converting To, otherwise divide |
503 bool toMul; //!< Multiply when converting To, otherwise divide |
514 bool fromMul; //!< Multiple when converting From, otherwise divide |
504 bool fromMul; //!< Multiple when converting From, otherwise divide |
515 int64_t factor; //!< Ratio of this unit / current unit |
505 int64_t factor; //!< Ratio of this unit / current unit |
516 int64x64_t timeTo; //!< Multiplier to convert to this unit |
506 int64x64_t timeTo; //!< Multiplier to convert to this unit |
517 int64x64_t timeFrom; //!< Multiplier to convert from this unit |
507 int64x64_t timeFrom; //!< Multiplier to convert from this unit |
518 }; |
508 }; |
519 /** |
509 /** Current time unit, and conversion info. */ |
520 * Current time unit, and conversion info. |
|
521 */ |
|
522 struct Resolution |
510 struct Resolution |
523 { |
511 { |
524 struct Information info[LAST]; //!< Conversion info from current unit |
512 struct Information info[LAST]; //!< Conversion info from current unit |
525 enum Time::Unit unit; //!< Current time unit |
513 enum Time::Unit unit; //!< Current time unit |
526 }; |
514 }; |
527 |
515 |
|
516 /** |
|
517 * Get the current Resolution |
|
518 * |
|
519 * \return A pointer to the current Resolution |
|
520 */ |
528 static inline struct Resolution *PeekResolution (void) |
521 static inline struct Resolution *PeekResolution (void) |
529 { |
522 { |
530 static struct Time::Resolution resolution = SetDefaultNsResolution (); |
523 static struct Time::Resolution resolution = SetDefaultNsResolution (); |
531 return & resolution; |
524 return & resolution; |
532 } |
525 } |
|
526 /** |
|
527 * Get the Information record for \p timeUnit for the current Resolution |
|
528 * |
|
529 * \param [in] timeUnit The Unit to get Information for |
|
530 * \return the Information for \p timeUnit |
|
531 */ |
533 static inline struct Information *PeekInformation (enum Unit timeUnit) |
532 static inline struct Information *PeekInformation (enum Unit timeUnit) |
534 { |
533 { |
535 return & (PeekResolution ()->info[timeUnit]); |
534 return & (PeekResolution ()->info[timeUnit]); |
536 } |
535 } |
537 |
536 |
|
537 /** |
|
538 * Set the default resolution |
|
539 * |
|
540 * \return The Resolution object for the default resolution. |
|
541 */ |
538 static struct Resolution SetDefaultNsResolution (void); |
542 static struct Resolution SetDefaultNsResolution (void); |
|
543 /** |
|
544 * Set the current Resolution. |
|
545 * |
|
546 * \param [in] unit The unit to use as the new resolution. |
|
547 * \param [in,out] resolution The Resolution record to update. |
|
548 * \param [in] convert Whether to convert existing Time objects to the new resolution. |
|
549 */ |
539 static void SetResolution (enum Unit unit, struct Resolution *resolution, |
550 static void SetResolution (enum Unit unit, struct Resolution *resolution, |
540 const bool convert = true); |
551 const bool convert = true); |
541 |
552 |
542 /** |
553 /** |
543 * Record all instances of Time, so we can rescale them when |
554 * Record all instances of Time, so we can rescale them when |
706 { |
747 { |
707 lhs.m_data -= rhs.m_data; |
748 lhs.m_data -= rhs.m_data; |
708 return lhs; |
749 return lhs; |
709 } |
750 } |
710 |
751 |
711 /** |
752 |
712 * Max function for Time. |
753 inline Time Abs (const Time & time) |
713 * \param ta the first value |
754 { |
714 * \param tb the seconds value |
755 return Time ((time.m_data < 0) ? -time.m_data : time.m_data); |
715 * \returns the max of the two input values. |
756 } |
716 */ |
|
717 inline Time Max (const Time & ta, const Time & tb) |
757 inline Time Max (const Time & ta, const Time & tb) |
718 { |
758 { |
719 return Time ((ta.m_data < tb.m_data) ? tb : ta); |
759 return Time ((ta.m_data < tb.m_data) ? tb : ta); |
720 } |
760 } |
721 /** |
|
722 * Min function for Time. |
|
723 * \param ta the first value |
|
724 * \param tb the seconds value |
|
725 * \returns the min of the two input values. |
|
726 */ |
|
727 inline Time Min (const Time & ta, const Time & tb) |
761 inline Time Min (const Time & ta, const Time & tb) |
728 { |
762 { |
729 return Time ((ta.m_data > tb.m_data) ? tb : ta); |
763 return Time ((ta.m_data > tb.m_data) ? tb : ta); |
730 } |
764 } |
731 |
765 |
732 /** |
766 /** |
733 * Absolute value function for Time |
767 * \ingroup time |
734 * \param time the input value |
|
735 * \returns the absolute value of the input value. |
|
736 */ |
|
737 inline Time Abs (const Time & time) |
|
738 { |
|
739 return Time ((time.m_data < 0) ? -time.m_data : time.m_data); |
|
740 } |
|
741 |
|
742 /** |
|
743 * \brief Time output streamer. |
768 * \brief Time output streamer. |
744 * |
769 * |
745 * Generates output such as "3.96ns". Times are printed with the |
770 * Generates output such as "3.96ns". Times are printed with the |
746 * following format flags (independent of the stream flags): |
771 * following format flags (independent of the stream flags): |
747 * - `showpos` |
772 * - `showpos` |
748 * - `fixed` |
773 * - `fixed` |
749 * - `left` |
774 * - `left` |
750 * The stream `width` and `precision` are ignored; Time output always |
775 * The stream `width` and `precision` are ignored; Time output always |
751 * includes ".0". |
776 * includes ".0". |
752 * \relates Time |
777 * |
753 */ |
778 * \param [in] os The output stream. |
754 std::ostream & operator<< (std::ostream & os, const Time & time); |
779 * \param [in] time The Time to put on the stream. |
755 /** |
780 * \return The stream. |
|
781 */ |
|
782 std::ostream & operator << (std::ostream & os, const Time & time); |
|
783 /** |
|
784 * \ingroup time |
756 * \brief Time input streamer |
785 * \brief Time input streamer |
757 * |
786 * |
758 * Uses the Time::Time (const std::string &) constructor |
787 * Uses the Time::Time (const std::string &) constructor |
759 * \relates Time |
788 * |
760 */ |
789 * \param [in] is The input stream. |
761 std::istream & operator>> (std::istream & is, Time & time); |
790 * \param [out] time The Time variable to set from the stream data. |
762 |
791 * \return The stream. |
763 /** |
792 */ |
764 * \brief create ns3::Time instances in units of seconds. |
793 std::istream & operator >> (std::istream & is, Time & time); |
|
794 |
|
795 /** |
|
796 * \ingroup time |
|
797 * \defgroup timecivil Standard time units. |
|
798 * \brief Convenience constructors in standard units. |
765 * |
799 * |
766 * For example: |
800 * For example: |
767 * \code |
801 * \code |
768 * Time t = Seconds (2.0); |
802 * Time t = Seconds (2.0); |
769 * Simulator::Schedule (Seconds (5.0), ...); |
803 * Simulator::Schedule (Seconds (5.0), ...); |
770 * \endcode |
804 * \endcode |
771 * \param seconds seconds value |
805 */ |
772 * \relates Time |
806 /** |
773 */ |
807 * \ingroup timecivil |
774 inline Time Seconds (double seconds) |
808 * Construct a Time in the indicated unit. |
775 { |
809 * \param value The value |
776 return Time::FromDouble (seconds, Time::S); |
810 * \return The Time |
777 } |
811 * @{ |
778 |
812 */ |
779 /** |
813 inline Time Years (double value) |
780 * \brief create ns3::Time instances in units of milliseconds. |
814 { |
781 * |
815 return Time::FromDouble (value, Time::Y); |
782 * For example: |
816 } |
783 * \code |
817 inline Time Years (int64x64_t value) |
784 * Time t = MilliSeconds (2); |
818 { |
785 * Simulator::Schedule (MilliSeconds (5), ...); |
819 return Time::From (value, Time::Y); |
786 * \endcode |
820 } |
787 * \param ms milliseconds value |
821 inline Time Days (double value) |
788 * \relates Time |
822 { |
789 */ |
823 return Time::FromDouble (value, Time::D); |
790 inline Time MilliSeconds (uint64_t ms) |
824 } |
791 { |
825 inline Time Days (int64x64_t value) |
792 return Time::FromInteger (ms, Time::MS); |
826 { |
793 } |
827 return Time::From (value, Time::D); |
794 /** |
828 } |
795 * \brief create ns3::Time instances in units of microseconds. |
829 inline Time Hours (double value) |
796 * |
830 { |
797 * For example: |
831 return Time::FromDouble (value, Time::H); |
798 * \code |
832 } |
799 * Time t = MicroSeconds (2); |
833 inline Time Hours (int64x64_t value) |
800 * Simulator::Schedule (MicroSeconds (5), ...); |
834 { |
801 * \endcode |
835 return Time::From (value, Time::H); |
802 * \param us microseconds value |
836 } |
803 * \relates Time |
837 inline Time Minutes (double value) |
804 */ |
838 { |
805 inline Time MicroSeconds (uint64_t us) |
839 return Time::FromDouble (value, Time::MIN); |
806 { |
840 } |
807 return Time::FromInteger (us, Time::US); |
841 inline Time Minutes (int64x64_t value) |
808 } |
842 { |
809 /** |
843 return Time::From (value, Time::MIN); |
810 * \brief create ns3::Time instances in units of nanoseconds. |
844 } |
811 * |
845 inline Time Seconds (double value) |
812 * For example: |
846 { |
813 * \code |
847 return Time::FromDouble (value, Time::S); |
814 * Time t = NanoSeconds (2); |
848 } |
815 * Simulator::Schedule (NanoSeconds (5), ...); |
849 inline Time Seconds (int64x64_t value) |
816 * \endcode |
850 { |
817 * \param ns nanoseconds value |
851 return Time::From (value, Time::S); |
818 * \relates Time |
852 } |
819 */ |
853 inline Time MilliSeconds (uint64_t value) |
820 inline Time NanoSeconds (uint64_t ns) |
854 { |
821 { |
855 return Time::FromInteger (value, Time::MS); |
822 return Time::FromInteger (ns, Time::NS); |
856 } |
823 } |
857 inline Time MilliSeconds (int64x64_t value) |
824 /** |
858 { |
825 * \brief create ns3::Time instances in units of picoseconds. |
859 return Time::From (value, Time::MS); |
826 * |
860 } |
827 * For example: |
861 inline Time MicroSeconds (uint64_t value) |
828 * \code |
862 { |
829 * Time t = PicoSeconds (2); |
863 return Time::FromInteger (value, Time::US); |
830 * Simulator::Schedule (PicoSeconds (5), ...); |
864 } |
831 * \endcode |
865 inline Time MicroSeconds (int64x64_t value) |
832 * \param ps picoseconds value |
866 { |
833 * \relates Time |
867 return Time::From (value, Time::US); |
834 */ |
868 } |
835 inline Time PicoSeconds (uint64_t ps) |
869 inline Time NanoSeconds (uint64_t value) |
836 { |
870 { |
837 return Time::FromInteger (ps, Time::PS); |
871 return Time::FromInteger (value, Time::NS); |
838 } |
872 } |
839 /** |
873 inline Time NanoSeconds (int64x64_t value) |
840 * \brief create ns3::Time instances in units of femtoseconds. |
874 { |
841 * |
875 return Time::From (value, Time::NS); |
842 * For example: |
876 } |
843 * \code |
877 inline Time PicoSeconds (uint64_t value) |
844 * Time t = FemtoSeconds (2); |
878 { |
845 * Simulator::Schedule (FemtoSeconds (5), ...); |
879 return Time::FromInteger (value, Time::PS); |
846 * \endcode |
880 } |
847 * \param fs femtoseconds value |
881 inline Time PicoSeconds (int64x64_t value) |
848 * \relates Time |
882 { |
849 */ |
883 return Time::From (value, Time::PS); |
850 inline Time FemtoSeconds (uint64_t fs) |
884 } |
851 { |
885 inline Time FemtoSeconds (uint64_t value) |
852 return Time::FromInteger (fs, Time::FS); |
886 { |
853 } |
887 return Time::FromInteger (value, Time::FS); |
854 /** |
888 } |
855 * \brief create ns3::Time instances in units of minutes (equal to 60 seconds). |
889 inline Time FemtoSeconds (int64x64_t value) |
856 * |
890 { |
857 * For example: |
891 return Time::From (value, Time::FS); |
858 * \code |
892 } |
859 * Time t = Minutes (2.0); |
893 /**@}*/ |
860 * Simulator::Schedule (Minutes (5.0), ...); |
894 |
861 * \endcode |
895 |
862 * \param minutes mintues value |
896 /** |
863 * \relates Time |
897 * \ingroup time |
864 */ |
898 * \internal Scheduler interface |
865 inline Time Minutes (double minutes) |
899 * \param [in] ts The time value, in the current unit. |
866 { |
900 * \return A Time. |
867 return Time::FromDouble (minutes, Time::MIN); |
901 */ |
868 } |
|
869 /** |
|
870 * \brief create ns3::Time instances in units of hours (equal to 60 minutes). |
|
871 * |
|
872 * For example: |
|
873 * \code |
|
874 * Time t = Hours (2.0); |
|
875 * Simulator::Schedule (Hours (5.0), ...); |
|
876 * \endcode |
|
877 * \param hours hours value |
|
878 * \relates Time |
|
879 */ |
|
880 inline Time Hours (double hours) |
|
881 { |
|
882 return Time::FromDouble (hours, Time::H); |
|
883 } |
|
884 /** |
|
885 * \brief create ns3::Time instances in units of days (equal to 24 hours). |
|
886 * |
|
887 * For example: |
|
888 * \code |
|
889 * Time t = Days (2.0); |
|
890 * Simulator::Schedule (Days (5.0), ...); |
|
891 * \endcode |
|
892 * \param days days value |
|
893 * \relates Time |
|
894 */ |
|
895 inline Time Days (double days) |
|
896 { |
|
897 return Time::FromDouble (days, Time::D); |
|
898 } |
|
899 /** |
|
900 * \brief create ns3::Time instances in units of years (equal to 365 days). |
|
901 * |
|
902 * For example: |
|
903 * \code |
|
904 * Time t = Years (2.0); |
|
905 * Simulator::Schedule (Years (5.0), ...); |
|
906 * \endcode |
|
907 * \param years years value |
|
908 * \relates Time |
|
909 */ |
|
910 inline Time Years (double years) |
|
911 { |
|
912 return Time::FromDouble (years, Time::Y); |
|
913 } |
|
914 |
|
915 /** |
|
916 * \see Seconds(double) |
|
917 * \relates Time |
|
918 */ |
|
919 inline Time Seconds (int64x64_t seconds) |
|
920 { |
|
921 return Time::From (seconds, Time::S); |
|
922 } |
|
923 /** |
|
924 * \see MilliSeconds(uint64_t) |
|
925 * \relates Time |
|
926 */ |
|
927 inline Time MilliSeconds (int64x64_t ms) |
|
928 { |
|
929 return Time::From (ms, Time::MS); |
|
930 } |
|
931 /** |
|
932 * \see MicroSeconds(uint64_t) |
|
933 * \relates Time |
|
934 */ |
|
935 inline Time MicroSeconds (int64x64_t us) |
|
936 { |
|
937 return Time::From (us, Time::US); |
|
938 } |
|
939 /** |
|
940 * \see NanoSeconds(uint64_t) |
|
941 * \relates Time |
|
942 */ |
|
943 inline Time NanoSeconds (int64x64_t ns) |
|
944 { |
|
945 return Time::From (ns, Time::NS); |
|
946 } |
|
947 /** |
|
948 * \see PicoSeconds(uint64_t) |
|
949 * \relates Time |
|
950 */ |
|
951 inline Time PicoSeconds (int64x64_t ps) |
|
952 { |
|
953 return Time::From (ps, Time::PS); |
|
954 } |
|
955 /** |
|
956 * \see FemtoSeconds(uint64_t) |
|
957 * \relates Time |
|
958 */ |
|
959 inline Time FemtoSeconds (int64x64_t fs) |
|
960 { |
|
961 return Time::From (fs, Time::FS); |
|
962 } |
|
963 /** |
|
964 * \see Minutes(uint64_t) |
|
965 * \relates Time |
|
966 */ |
|
967 inline Time Minutes (int64x64_t minutes) |
|
968 { |
|
969 return Time::From (minutes, Time::MIN); |
|
970 } |
|
971 /** |
|
972 * \see Minutes(uint64_t) |
|
973 * \relates Time |
|
974 */ |
|
975 inline Time Hours (int64x64_t hours) |
|
976 { |
|
977 return Time::From (hours, Time::H); |
|
978 } |
|
979 /** |
|
980 * \see Minutes(uint64_t) |
|
981 * \relates Time |
|
982 */ |
|
983 inline Time Days (int64x64_t days) |
|
984 { |
|
985 return Time::From (days, Time::D); |
|
986 } |
|
987 /** |
|
988 * \see Minutes(uint64_t) |
|
989 * \relates Time |
|
990 */ |
|
991 inline Time Years (int64x64_t years) |
|
992 { |
|
993 return Time::From (years, Time::Y); |
|
994 } |
|
995 |
|
996 // internal function not publicly documented |
|
997 inline Time TimeStep (uint64_t ts) |
902 inline Time TimeStep (uint64_t ts) |
998 { |
903 { |
999 return Time (ts); |
904 return Time (ts); |
1000 } |
905 } |
1001 |
906 |
1002 /** |
907 /** |
|
908 * \ingroup time |
1003 * \class ns3::TimeValue |
909 * \class ns3::TimeValue |
1004 * \brief hold objects of type ns3::Time |
910 * \brief Attribute for objects of type ns3::Time |
1005 */ |
911 */ |
1006 |
|
1007 |
|
1008 ATTRIBUTE_VALUE_DEFINE (Time); |
912 ATTRIBUTE_VALUE_DEFINE (Time); |
|
913 |
|
914 /** |
|
915 * Attribute accessor function for Time |
|
916 * @{ |
|
917 */ |
1009 ATTRIBUTE_ACCESSOR_DEFINE (Time); |
918 ATTRIBUTE_ACCESSOR_DEFINE (Time); |
1010 |
919 /**@}*/ |
1011 /** |
920 |
1012 * \brief Helper to make a Time checker with bounded range. |
921 /** |
1013 * Both limits are inclusive |
922 * \ingroup time |
1014 * |
923 * \brief Helper to make a Time checker with bounded range. |
1015 * \return the AttributeChecker |
924 * Both limits are inclusive |
|
925 * |
|
926 * \param [in] min Minimum allowed value. |
|
927 * \param [in] max Maximum allowed value. |
|
928 * \return the AttributeChecker |
1016 */ |
929 */ |
1017 Ptr<const AttributeChecker> MakeTimeChecker (const Time min, const Time max); |
930 Ptr<const AttributeChecker> MakeTimeChecker (const Time min, const Time max); |
1018 |
931 |
1019 /** |
932 /** |
|
933 * \ingroup time |
1020 * \brief Helper to make an unbounded Time checker. |
934 * \brief Helper to make an unbounded Time checker. |
1021 * |
935 * |
1022 * \return the AttributeChecker |
936 * \return the AttributeChecker |
1023 */ |
937 */ |
1024 inline |
938 inline |