|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
1 |
1;3402;0c/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
2 |
/* |
3 |
* Copyright (c) 2005,2006 INRIA |
3 |
* Copyright (c) 2005,2006 INRIA |
4 |
* |
4 |
* |
|
93 |
*/ |
93 |
*/ |
94 |
enum Unit |
94 |
enum Unit |
95 |
{ |
95 |
{ |
96 |
S = 0, //!< second |
96 |
A, //!< year |
97 |
MS = 1, //!< millisecond |
97 |
WK, //!< week |
98 |
US = 2, //!< microsecond |
98 |
D, //!< day |
99 |
NS = 3, //!< nanosecond |
99 |
H, //!< hour |
100 |
PS = 4, //!< picosecond |
100 |
MIN, //!< minute |
101 |
FS = 5, //!< femtosecond |
101 |
S, //!< second |
102 |
LAST = 6 |
102 |
MS, //!< millisecond |
|
|
103 |
US, //!< microsecond |
104 |
NS, //!< nanosecond |
105 |
PS, //!< picosecond |
106 |
FS, //!< femtosecond |
107 |
LAST |
103 |
}; |
108 |
}; |
104 |
|
109 |
|
105 |
inline Time &operator = (const Time &o) |
110 |
inline Time &operator = (const Time &o) |
|
188 |
* \brief Construct Time object from common time expressions like "1ms" |
193 |
* \brief Construct Time object from common time expressions like "1ms" |
189 |
* |
194 |
* |
190 |
* Supported units include: |
195 |
* Supported units include: |
|
|
196 |
* - `a` (years) |
197 |
* - `wk` (weeks) |
198 |
* - `d` (days) |
199 |
* - `h` (hours) |
200 |
* - `min` (minutes) |
191 |
* - `s` (seconds) |
201 |
* - `s` (seconds) |
192 |
* - `ms` (milliseconds) |
202 |
* - `ms` (milliseconds) |
193 |
* - `us` (microseconds) |
203 |
* - `us` (microseconds) |
|
663 |
std::istream& operator>> (std::istream& is, Time & time); |
673 |
std::istream& operator>> (std::istream& is, Time & time); |
664 |
|
674 |
|
665 |
/** |
675 |
/** |
|
|
676 |
* \brief create ns3::Time instances in units of minutes. |
677 |
* |
678 |
* For example: |
679 |
* \code |
680 |
* Time t = Minutes (2.0); |
681 |
* Simulator::Schedule (Minutes (5.0), ...); |
682 |
* \endcode |
683 |
* \param minutes mintues value |
684 |
* \relates ns3::Time |
685 |
*/ |
686 |
inline Time Minutes (double minutes) |
687 |
{ |
688 |
return Time::FromDouble (minutes, Time::MIN); |
689 |
} |
690 |
|
691 |
inline Time Minutes (float minutes) |
692 |
{ |
693 |
return Time::FromDouble (minutes, Time::MIN); |
694 |
} |
695 |
|
696 |
inline Time Minutes (uint64_t minutes) |
697 |
{ |
698 |
return Time::FromInteger (minutes, Time::MIN); |
699 |
} |
700 |
|
701 |
inline Time Minutes (int64_t minutes) |
702 |
{ |
703 |
return Time::FromInteger (minutes, Time::MIN); |
704 |
} |
705 |
|
706 |
inline Time Minutes (uint32_t minutes) |
707 |
{ |
708 |
return Time::FromInteger (minutes, Time::MIN); |
709 |
} |
710 |
|
711 |
inline Time Minutes (int32_t minutes) |
712 |
{ |
713 |
return Time::FromInteger (minutes, Time::MIN); |
714 |
} |
715 |
|
716 |
/** |
666 |
* \brief create ns3::Time instances in units of seconds. |
717 |
* \brief create ns3::Time instances in units of seconds. |
667 |
* |
718 |
* |
668 |
* For example: |
719 |
* For example: |
|
678 |
return Time::FromDouble (seconds, Time::S); |
729 |
return Time::FromDouble (seconds, Time::S); |
679 |
} |
730 |
} |
680 |
|
731 |
|
|
|
732 |
inline Time Seconds (float seconds) |
733 |
{ |
734 |
return Time::FromDouble (seconds, Time::S); |
735 |
} |
736 |
|
737 |
inline Time Seconds (uint64_t seconds) |
738 |
{ |
739 |
return Time::FromInteger (seconds, Time::S); |
740 |
} |
741 |
|
742 |
inline Time Seconds (int64_t seconds) |
743 |
{ |
744 |
return Time::FromInteger (seconds, Time::S); |
745 |
} |
746 |
|
747 |
inline Time Seconds (uint32_t seconds) |
748 |
{ |
749 |
return Time::FromInteger (seconds, Time::S); |
750 |
} |
751 |
|
752 |
inline Time Seconds (int32_t seconds) |
753 |
{ |
754 |
return Time::FromInteger (seconds, Time::S); |
755 |
} |
756 |
|
681 |
/** |
757 |
/** |
682 |
* \brief create ns3::Time instances in units of milliseconds. |
758 |
* \brief create ns3::Time instances in units of milliseconds. |
683 |
* |
759 |
* |
|
689 |
* \param ms milliseconds value |
765 |
* \param ms milliseconds value |
690 |
* \relates ns3::Time |
766 |
* \relates ns3::Time |
691 |
*/ |
767 |
*/ |
|
|
768 |
inline Time MilliSeconds (double ms) |
769 |
{ |
770 |
return Time::FromDouble (ms, Time::MS); |
771 |
} |
772 |
|
773 |
inline Time MilliSeconds (float ms) |
774 |
{ |
775 |
return Time::FromDouble (ms, Time::MS); |
776 |
} |
777 |
|
692 |
inline Time MilliSeconds (uint64_t ms) |
778 |
inline Time MilliSeconds (uint64_t ms) |
693 |
{ |
779 |
{ |
694 |
return Time::FromInteger (ms, Time::MS); |
780 |
return Time::FromInteger (ms, Time::MS); |
695 |
} |
781 |
} |
|
|
782 |
|
783 |
inline Time MilliSeconds (int64_t ms) |
784 |
{ |
785 |
return Time::FromInteger (ms, Time::MS); |
786 |
} |
787 |
|
788 |
inline Time MilliSeconds (uint32_t ms) |
789 |
{ |
790 |
return Time::FromInteger (ms, Time::MS); |
791 |
} |
792 |
|
793 |
inline Time MilliSeconds (int32_t ms) |
794 |
{ |
795 |
return Time::FromInteger (ms, Time::MS); |
796 |
} |
797 |
|
696 |
/** |
798 |
/** |
697 |
* \brief create ns3::Time instances in units of microseconds. |
799 |
* \brief create ns3::Time instances in units of microseconds. |
698 |
* |
800 |
* |
|
704 |
* \param us microseconds value |
806 |
* \param us microseconds value |
705 |
* \relates ns3::Time |
807 |
* \relates ns3::Time |
706 |
*/ |
808 |
*/ |
|
|
809 |
inline Time MicroSeconds (double us) |
810 |
{ |
811 |
return Time::FromDouble (us, Time::US); |
812 |
} |
813 |
|
814 |
inline Time MicroSeconds (float us) |
815 |
{ |
816 |
return Time::FromDouble (us, Time::US); |
817 |
} |
818 |
|
707 |
inline Time MicroSeconds (uint64_t us) |
819 |
inline Time MicroSeconds (uint64_t us) |
708 |
{ |
820 |
{ |
709 |
return Time::FromInteger (us, Time::US); |
821 |
return Time::FromInteger (us, Time::US); |
710 |
} |
822 |
} |
|
|
823 |
|
824 |
inline Time MicroSeconds (int64_t us) |
825 |
{ |
826 |
return Time::FromInteger (us, Time::US); |
827 |
} |
828 |
|
829 |
inline Time MicroSeconds (uint32_t us) |
830 |
{ |
831 |
return Time::FromInteger (us, Time::US); |
832 |
} |
833 |
|
834 |
inline Time MicroSeconds (int32_t us) |
835 |
{ |
836 |
return Time::FromInteger (us, Time::US); |
837 |
} |
838 |
|
711 |
/** |
839 |
/** |
712 |
* \brief create ns3::Time instances in units of nanoseconds. |
840 |
* \brief create ns3::Time instances in units of nanoseconds. |
713 |
* |
841 |
* |
|
719 |
* \param ns nanoseconds value |
847 |
* \param ns nanoseconds value |
720 |
* \relates ns3::Time |
848 |
* \relates ns3::Time |
721 |
*/ |
849 |
*/ |
|
|
850 |
inline Time NanoSeconds (double ns) |
851 |
{ |
852 |
return Time::FromDouble (ns, Time::NS); |
853 |
} |
854 |
|
855 |
inline Time NanoSeconds (float ns) |
856 |
{ |
857 |
return Time::FromDouble (ns, Time::NS); |
858 |
} |
859 |
|
722 |
inline Time NanoSeconds (uint64_t ns) |
860 |
inline Time NanoSeconds (uint64_t ns) |
723 |
{ |
861 |
{ |
724 |
return Time::FromInteger (ns, Time::NS); |
862 |
return Time::FromInteger (ns, Time::NS); |
725 |
} |
863 |
} |
|
|
864 |
|
865 |
inline Time NanoSeconds (int64_t ns) |
866 |
{ |
867 |
return Time::FromInteger (ns, Time::NS); |
868 |
} |
869 |
|
870 |
inline Time NanoSeconds (uint32_t ns) |
871 |
{ |
872 |
return Time::FromInteger (ns, Time::NS); |
873 |
} |
874 |
|
875 |
inline Time NanoSeconds (int32_t ns) |
876 |
{ |
877 |
return Time::FromInteger (ns, Time::NS); |
878 |
} |
879 |
|
726 |
/** |
880 |
/** |
727 |
* \brief create ns3::Time instances in units of picoseconds. |
881 |
* \brief create ns3::Time instances in units of picoseconds. |
728 |
* |
882 |
* |
|
734 |
* \param ps picoseconds value |
888 |
* \param ps picoseconds value |
735 |
* \relates ns3::Time |
889 |
* \relates ns3::Time |
736 |
*/ |
890 |
*/ |
|
|
891 |
inline Time PicoSeconds (double ps) |
892 |
{ |
893 |
return Time::FromDouble (ps, Time::PS); |
894 |
} |
895 |
|
896 |
inline Time PicoSeconds (float ps) |
897 |
{ |
898 |
return Time::FromDouble (ps, Time::PS); |
899 |
} |
900 |
|
737 |
inline Time PicoSeconds (uint64_t ps) |
901 |
inline Time PicoSeconds (uint64_t ps) |
738 |
{ |
902 |
{ |
739 |
return Time::FromInteger (ps, Time::PS); |
903 |
return Time::FromInteger (ps, Time::PS); |
740 |
} |
904 |
} |
|
|
905 |
|
906 |
inline Time PicoSeconds (int64_t ps) |
907 |
{ |
908 |
return Time::FromInteger (ps, Time::PS); |
909 |
} |
910 |
|
911 |
inline Time PicoSeconds (uint32_t ps) |
912 |
{ |
913 |
return Time::FromInteger (ps, Time::PS); |
914 |
} |
915 |
|
916 |
inline Time PicoSeconds (int32_t ps) |
917 |
{ |
918 |
return Time::FromInteger (ps, Time::PS); |
919 |
} |
920 |
|
741 |
/** |
921 |
/** |
742 |
* \brief create ns3::Time instances in units of femtoseconds. |
922 |
* \brief create ns3::Time instances in units of femtoseconds. |
743 |
* |
923 |
* |
|
749 |
* \param fs femtoseconds value |
929 |
* \param fs femtoseconds value |
750 |
* \relates ns3::Time |
930 |
* \relates ns3::Time |
751 |
*/ |
931 |
*/ |
|
|
932 |
inline Time FemtoSeconds (double fs) |
933 |
{ |
934 |
return Time::FromDouble (fs, Time::FS); |
935 |
} |
936 |
|
937 |
inline Time FemtoSeconds (float fs) |
938 |
{ |
939 |
return Time::FromDouble (fs, Time::FS); |
940 |
} |
941 |
|
752 |
inline Time FemtoSeconds (uint64_t fs) |
942 |
inline Time FemtoSeconds (uint64_t fs) |
753 |
{ |
943 |
{ |
754 |
return Time::FromInteger (fs, Time::FS); |
944 |
return Time::FromInteger (fs, Time::FS); |
755 |
} |
945 |
} |
756 |
|
946 |
|
|
|
947 |
inline Time FemtoSeconds (int64_t fs) |
948 |
{ |
949 |
return Time::FromInteger (fs, Time::FS); |
950 |
} |
951 |
|
952 |
inline Time FemtoSeconds (uint32_t fs) |
953 |
{ |
954 |
return Time::FromInteger (fs, Time::FS); |
955 |
} |
956 |
|
957 |
inline Time FemtoSeconds (int32_t fs) |
958 |
{ |
959 |
return Time::FromInteger (fs, Time::FS); |
960 |
} |
757 |
|
961 |
|
758 |
/** |
962 |
/** |
759 |
* \see Seconds(double) |
963 |
* \see Seconds(double) |