|
|
| 99 |
NS = 3, //!< nanosecond |
99 |
NS = 3, //!< nanosecond |
| 100 |
PS = 4, //!< picosecond |
100 |
PS = 4, //!< picosecond |
| 101 |
FS = 5, //!< femtosecond |
101 |
FS = 5, //!< femtosecond |
| 102 |
LAST = 6 |
102 |
MIN = 6, //!< minute |
|
|
103 |
H = 7, //!< hour |
| 104 |
D = 8, //!< day |
| 105 |
WK = 9, //!< week |
| 106 |
A = 10, //!< year |
| 107 |
LAST = 11 |
| 103 |
}; |
108 |
}; |
| 104 |
|
109 |
|
| 105 |
inline Time &operator = (const Time &o) |
110 |
inline Time &operator = (const Time &o) |
|
|
| 194 |
* - `ns` (nanoseconds) |
199 |
* - `ns` (nanoseconds) |
| 195 |
* - `ps` (picoseconds) |
200 |
* - `ps` (picoseconds) |
| 196 |
* - `fs` (femtoseconds) |
201 |
* - `fs` (femtoseconds) |
|
|
202 |
* - `min` (minutes) |
| 203 |
* - `h` (hours) |
| 204 |
* - `d` (days) |
| 205 |
* - `wk` (weeks) |
| 206 |
* - `a` (years) |
| 197 |
* |
207 |
* |
| 198 |
* There can be no white space between the numerical portion |
208 |
* There can be no white space between the numerical portion |
| 199 |
* and the units. Any otherwise malformed string causes a fatal error to |
209 |
* and the units. Any otherwise malformed string causes a fatal error to |
|
|
| 305 |
{ |
315 |
{ |
| 306 |
return ToInteger (Time::FS); |
316 |
return ToInteger (Time::FS); |
| 307 |
} |
317 |
} |
|
|
318 |
|
| 319 |
/** |
| 320 |
* \returns an approximation in minutes of the time stored in this |
| 321 |
* instance. |
| 322 |
*/ |
| 323 |
inline double GetMinutes (void) const |
| 324 |
{ |
| 325 |
return ToDouble (Time::MIN); |
| 326 |
} |
| 327 |
/** |
| 328 |
* \returns an approximation in hours of the time stored in this |
| 329 |
* instance. |
| 330 |
*/ |
| 331 |
inline double GetHours (void) const |
| 332 |
{ |
| 333 |
return ToDouble (Time::H); |
| 334 |
} |
| 335 |
/** |
| 336 |
* \returns an approximation in days of the time stored in this |
| 337 |
* instance. |
| 338 |
*/ |
| 339 |
inline double GetDays (void) const |
| 340 |
{ |
| 341 |
return ToDouble (Time::D); |
| 342 |
} |
| 343 |
/** |
| 344 |
* \returns an approximation in weeks of the time stored in this |
| 345 |
* instance. |
| 346 |
*/ |
| 347 |
inline double GetWeeks (void) const |
| 348 |
{ |
| 349 |
return ToDouble (Time::WK); |
| 350 |
} |
| 351 |
/** |
| 352 |
* \returns an approximation in years of the time stored in this |
| 353 |
* instance. |
| 354 |
*/ |
| 355 |
inline double GetYears (void) const |
| 356 |
{ |
| 357 |
return ToDouble (Time::A); |
| 358 |
} |
| 359 |
|
| 308 |
/** |
360 |
/** |
| 309 |
* \returns the raw time value, in the current units |
361 |
* \returns the raw time value, in the current units |
| 310 |
*/ |
362 |
*/ |
|
|
| 678 |
return Time::FromDouble (seconds, Time::S); |
730 |
return Time::FromDouble (seconds, Time::S); |
| 679 |
} |
731 |
} |
| 680 |
|
732 |
|
|
|
733 |
inline Time Seconds (float seconds) |
| 734 |
{ |
| 735 |
return Time::FromDouble (seconds, Time::S); |
| 736 |
} |
| 737 |
|
| 738 |
inline Time Seconds (uint64_t seconds) |
| 739 |
{ |
| 740 |
return Time::FromInteger (seconds, Time::S); |
| 741 |
} |
| 742 |
|
| 743 |
inline Time Seconds (int64_t seconds) |
| 744 |
{ |
| 745 |
return Time::FromInteger (seconds, Time::S); |
| 746 |
} |
| 747 |
|
| 748 |
inline Time Seconds (uint32_t seconds) |
| 749 |
{ |
| 750 |
return Time::FromInteger (seconds, Time::S); |
| 751 |
} |
| 752 |
|
| 753 |
inline Time Seconds (int32_t seconds) |
| 754 |
{ |
| 755 |
return Time::FromInteger (seconds, Time::S); |
| 756 |
} |
| 757 |
|
| 681 |
/** |
758 |
/** |
| 682 |
* \brief create ns3::Time instances in units of milliseconds. |
759 |
* \brief create ns3::Time instances in units of milliseconds. |
| 683 |
* |
760 |
* |
|
|
| 689 |
* \param ms milliseconds value |
766 |
* \param ms milliseconds value |
| 690 |
* \relates ns3::Time |
767 |
* \relates ns3::Time |
| 691 |
*/ |
768 |
*/ |
|
|
769 |
inline Time MilliSeconds (double ms) |
| 770 |
{ |
| 771 |
return Time::FromDouble (ms, Time::MS); |
| 772 |
} |
| 773 |
|
| 774 |
inline Time MilliSeconds (float ms) |
| 775 |
{ |
| 776 |
return Time::FromDouble (ms, Time::MS); |
| 777 |
} |
| 778 |
|
| 692 |
inline Time MilliSeconds (uint64_t ms) |
779 |
inline Time MilliSeconds (uint64_t ms) |
| 693 |
{ |
780 |
{ |
| 694 |
return Time::FromInteger (ms, Time::MS); |
781 |
return Time::FromInteger (ms, Time::MS); |
| 695 |
} |
782 |
} |
|
|
783 |
|
| 784 |
inline Time MilliSeconds (int64_t ms) |
| 785 |
{ |
| 786 |
return Time::FromInteger (ms, Time::MS); |
| 787 |
} |
| 788 |
|
| 789 |
inline Time MilliSeconds (uint32_t ms) |
| 790 |
{ |
| 791 |
return Time::FromInteger (ms, Time::MS); |
| 792 |
} |
| 793 |
|
| 794 |
inline Time MilliSeconds (int32_t ms) |
| 795 |
{ |
| 796 |
return Time::FromInteger (ms, Time::MS); |
| 797 |
} |
| 798 |
|
| 696 |
/** |
799 |
/** |
| 697 |
* \brief create ns3::Time instances in units of microseconds. |
800 |
* \brief create ns3::Time instances in units of microseconds. |
| 698 |
* |
801 |
* |
|
|
| 704 |
* \param us microseconds value |
807 |
* \param us microseconds value |
| 705 |
* \relates ns3::Time |
808 |
* \relates ns3::Time |
| 706 |
*/ |
809 |
*/ |
|
|
810 |
inline Time MicroSeconds (double us) |
| 811 |
{ |
| 812 |
return Time::FromDouble (us, Time::US); |
| 813 |
} |
| 814 |
|
| 815 |
inline Time MicroSeconds (float us) |
| 816 |
{ |
| 817 |
return Time::FromDouble (us, Time::US); |
| 818 |
} |
| 819 |
|
| 707 |
inline Time MicroSeconds (uint64_t us) |
820 |
inline Time MicroSeconds (uint64_t us) |
| 708 |
{ |
821 |
{ |
| 709 |
return Time::FromInteger (us, Time::US); |
822 |
return Time::FromInteger (us, Time::US); |
| 710 |
} |
823 |
} |
|
|
824 |
|
| 825 |
inline Time MicroSeconds (int64_t us) |
| 826 |
{ |
| 827 |
return Time::FromInteger (us, Time::US); |
| 828 |
} |
| 829 |
|
| 830 |
inline Time MicroSeconds (uint32_t us) |
| 831 |
{ |
| 832 |
return Time::FromInteger (us, Time::US); |
| 833 |
} |
| 834 |
|
| 835 |
inline Time MicroSeconds (int32_t us) |
| 836 |
{ |
| 837 |
return Time::FromInteger (us, Time::US); |
| 838 |
} |
| 839 |
|
| 711 |
/** |
840 |
/** |
| 712 |
* \brief create ns3::Time instances in units of nanoseconds. |
841 |
* \brief create ns3::Time instances in units of nanoseconds. |
| 713 |
* |
842 |
* |
|
|
| 719 |
* \param ns nanoseconds value |
848 |
* \param ns nanoseconds value |
| 720 |
* \relates ns3::Time |
849 |
* \relates ns3::Time |
| 721 |
*/ |
850 |
*/ |
|
|
851 |
inline Time NanoSeconds (double ns) |
| 852 |
{ |
| 853 |
return Time::FromDouble (ns, Time::NS); |
| 854 |
} |
| 855 |
|
| 856 |
inline Time NanoSeconds (float ns) |
| 857 |
{ |
| 858 |
return Time::FromDouble (ns, Time::NS); |
| 859 |
} |
| 860 |
|
| 722 |
inline Time NanoSeconds (uint64_t ns) |
861 |
inline Time NanoSeconds (uint64_t ns) |
| 723 |
{ |
862 |
{ |
| 724 |
return Time::FromInteger (ns, Time::NS); |
863 |
return Time::FromInteger (ns, Time::NS); |
| 725 |
} |
864 |
} |
|
|
865 |
|
| 866 |
inline Time NanoSeconds (int64_t ns) |
| 867 |
{ |
| 868 |
return Time::FromInteger (ns, Time::NS); |
| 869 |
} |
| 870 |
|
| 871 |
inline Time NanoSeconds (uint32_t ns) |
| 872 |
{ |
| 873 |
return Time::FromInteger (ns, Time::NS); |
| 874 |
} |
| 875 |
|
| 876 |
inline Time NanoSeconds (int32_t ns) |
| 877 |
{ |
| 878 |
return Time::FromInteger (ns, Time::NS); |
| 879 |
} |
| 880 |
|
| 726 |
/** |
881 |
/** |
| 727 |
* \brief create ns3::Time instances in units of picoseconds. |
882 |
* \brief create ns3::Time instances in units of picoseconds. |
| 728 |
* |
883 |
* |
|
|
| 734 |
* \param ps picoseconds value |
889 |
* \param ps picoseconds value |
| 735 |
* \relates ns3::Time |
890 |
* \relates ns3::Time |
| 736 |
*/ |
891 |
*/ |
|
|
892 |
inline Time PicoSeconds (double ps) |
| 893 |
{ |
| 894 |
return Time::FromDouble (ps, Time::PS); |
| 895 |
} |
| 896 |
|
| 897 |
inline Time PicoSeconds (float ps) |
| 898 |
{ |
| 899 |
return Time::FromDouble (ps, Time::PS); |
| 900 |
} |
| 901 |
|
| 737 |
inline Time PicoSeconds (uint64_t ps) |
902 |
inline Time PicoSeconds (uint64_t ps) |
| 738 |
{ |
903 |
{ |
| 739 |
return Time::FromInteger (ps, Time::PS); |
904 |
return Time::FromInteger (ps, Time::PS); |
| 740 |
} |
905 |
} |
|
|
906 |
|
| 907 |
inline Time PicoSeconds (int64_t ps) |
| 908 |
{ |
| 909 |
return Time::FromInteger (ps, Time::PS); |
| 910 |
} |
| 911 |
|
| 912 |
inline Time PicoSeconds (uint32_t ps) |
| 913 |
{ |
| 914 |
return Time::FromInteger (ps, Time::PS); |
| 915 |
} |
| 916 |
|
| 917 |
inline Time PicoSeconds (int32_t ps) |
| 918 |
{ |
| 919 |
return Time::FromInteger (ps, Time::PS); |
| 920 |
} |
| 921 |
|
| 741 |
/** |
922 |
/** |
| 742 |
* \brief create ns3::Time instances in units of femtoseconds. |
923 |
* \brief create ns3::Time instances in units of femtoseconds. |
| 743 |
* |
924 |
* |
|
|
| 749 |
* \param fs femtoseconds value |
930 |
* \param fs femtoseconds value |
| 750 |
* \relates ns3::Time |
931 |
* \relates ns3::Time |
| 751 |
*/ |
932 |
*/ |
|
|
933 |
inline Time FemtoSeconds (double fs) |
| 934 |
{ |
| 935 |
return Time::FromDouble (fs, Time::FS); |
| 936 |
} |
| 937 |
|
| 938 |
inline Time FemtoSeconds (float fs) |
| 939 |
{ |
| 940 |
return Time::FromDouble (fs, Time::FS); |
| 941 |
} |
| 942 |
|
| 752 |
inline Time FemtoSeconds (uint64_t fs) |
943 |
inline Time FemtoSeconds (uint64_t fs) |
| 753 |
{ |
944 |
{ |
| 754 |
return Time::FromInteger (fs, Time::FS); |
945 |
return Time::FromInteger (fs, Time::FS); |
| 755 |
} |
946 |
} |
| 756 |
|
947 |
|
|
|
948 |
inline Time FemtoSeconds (int64_t fs) |
| 949 |
{ |
| 950 |
return Time::FromInteger (fs, Time::FS); |
| 951 |
} |
| 952 |
|
| 953 |
inline Time FemtoSeconds (uint32_t fs) |
| 954 |
{ |
| 955 |
return Time::FromInteger (fs, Time::FS); |
| 956 |
} |
| 957 |
|
| 958 |
inline Time FemtoSeconds (int32_t fs) |
| 959 |
{ |
| 960 |
return Time::FromInteger (fs, Time::FS); |
| 961 |
} |
| 962 |
|
| 963 |
/** |
| 964 |
* \brief create ns3::Time instances in units of minutes. |
| 965 |
* |
| 966 |
* For example: |
| 967 |
* \code |
| 968 |
* Time t = Minutes (2.0); |
| 969 |
* Simulator::Schedule (Minutes (5.0), ...); |
| 970 |
* \endcode |
| 971 |
* \param minutes mintues value |
| 972 |
* \relates ns3::Time |
| 973 |
*/ |
| 974 |
inline Time Minutes (double minutes) |
| 975 |
{ |
| 976 |
return Time::FromDouble (minutes, Time::MIN); |
| 977 |
} |
| 978 |
|
| 979 |
inline Time Minutes (float minutes) |
| 980 |
{ |
| 981 |
return Time::FromDouble (minutes, Time::MIN); |
| 982 |
} |
| 983 |
|
| 984 |
inline Time Minutes (uint64_t minutes) |
| 985 |
{ |
| 986 |
return Time::FromInteger (minutes, Time::MIN); |
| 987 |
} |
| 988 |
|
| 989 |
inline Time Minutes (int64_t minutes) |
| 990 |
{ |
| 991 |
return Time::FromInteger (minutes, Time::MIN); |
| 992 |
} |
| 993 |
|
| 994 |
inline Time Minutes (uint32_t minutes) |
| 995 |
{ |
| 996 |
return Time::FromInteger (minutes, Time::MIN); |
| 997 |
} |
| 998 |
|
| 999 |
inline Time Minutes (int32_t minutes) |
| 1000 |
{ |
| 1001 |
return Time::FromInteger (minutes, Time::MIN); |
| 1002 |
} |
| 1003 |
|
| 1004 |
/** |
| 1005 |
* \brief create ns3::Time instances in units of hours. |
| 1006 |
* |
| 1007 |
* For example: |
| 1008 |
* \code |
| 1009 |
* Time t = Hours (2.0); |
| 1010 |
* Simulator::Schedule (Hours (5.0), ...); |
| 1011 |
* \endcode |
| 1012 |
* \param hours hours value |
| 1013 |
* \relates ns3::Time |
| 1014 |
*/ |
| 1015 |
inline Time Hours (double hours) |
| 1016 |
{ |
| 1017 |
return Time::FromDouble (hours, Time::H); |
| 1018 |
} |
| 1019 |
|
| 1020 |
inline Time Hours (float hours) |
| 1021 |
{ |
| 1022 |
return Time::FromDouble (hours, Time::H); |
| 1023 |
} |
| 1024 |
|
| 1025 |
inline Time Hours (uint64_t hours) |
| 1026 |
{ |
| 1027 |
return Time::FromInteger (hours, Time::H); |
| 1028 |
} |
| 1029 |
|
| 1030 |
inline Time Hours (int64_t hours) |
| 1031 |
{ |
| 1032 |
return Time::FromInteger (hours, Time::H); |
| 1033 |
} |
| 1034 |
|
| 1035 |
inline Time Hours (uint32_t hours) |
| 1036 |
{ |
| 1037 |
return Time::FromInteger (hours, Time::H); |
| 1038 |
} |
| 1039 |
|
| 1040 |
inline Time Hours (int32_t hours) |
| 1041 |
{ |
| 1042 |
return Time::FromInteger (hours, Time::H); |
| 1043 |
} |
| 1044 |
|
| 1045 |
/** |
| 1046 |
* \brief create ns3::Time instances in units of days. |
| 1047 |
* |
| 1048 |
* For example: |
| 1049 |
* \code |
| 1050 |
* Time t = Days (2.0); |
| 1051 |
* Simulator::Schedule (Days (5.0), ...); |
| 1052 |
* \endcode |
| 1053 |
* \param days days value |
| 1054 |
* \relates ns3::Time |
| 1055 |
*/ |
| 1056 |
inline Time Days (double days) |
| 1057 |
{ |
| 1058 |
return Time::FromDouble (days, Time::D); |
| 1059 |
} |
| 1060 |
|
| 1061 |
inline Time Days (float days) |
| 1062 |
{ |
| 1063 |
return Time::FromDouble (days, Time::D); |
| 1064 |
} |
| 1065 |
|
| 1066 |
inline Time Days (uint64_t days) |
| 1067 |
{ |
| 1068 |
return Time::FromInteger (days, Time::D); |
| 1069 |
} |
| 1070 |
|
| 1071 |
inline Time Days (int64_t days) |
| 1072 |
{ |
| 1073 |
return Time::FromInteger (days, Time::D); |
| 1074 |
} |
| 1075 |
|
| 1076 |
inline Time Days (uint32_t days) |
| 1077 |
{ |
| 1078 |
return Time::FromInteger (days, Time::D); |
| 1079 |
} |
| 1080 |
|
| 1081 |
inline Time Days (int32_t days) |
| 1082 |
{ |
| 1083 |
return Time::FromInteger (days, Time::D); |
| 1084 |
} |
| 1085 |
|
| 1086 |
/** |
| 1087 |
* \brief create ns3::Time instances in units of weeks. |
| 1088 |
* |
| 1089 |
* For example: |
| 1090 |
* \code |
| 1091 |
* Time t = Weeks (2.0); |
| 1092 |
* Simulator::Schedule (Weeks (5.0), ...); |
| 1093 |
* \endcode |
| 1094 |
* \param weeks weeks value |
| 1095 |
* \relates ns3::Time |
| 1096 |
*/ |
| 1097 |
inline Time Weeks (double weeks) |
| 1098 |
{ |
| 1099 |
return Time::FromDouble (weeks, Time::WK); |
| 1100 |
} |
| 1101 |
|
| 1102 |
inline Time Weeks (float weeks) |
| 1103 |
{ |
| 1104 |
return Time::FromDouble (weeks, Time::WK); |
| 1105 |
} |
| 1106 |
|
| 1107 |
inline Time Weeks (uint64_t weeks) |
| 1108 |
{ |
| 1109 |
return Time::FromInteger (weeks, Time::WK); |
| 1110 |
} |
| 1111 |
|
| 1112 |
inline Time Weeks (int64_t weeks) |
| 1113 |
{ |
| 1114 |
return Time::FromInteger (weeks, Time::WK); |
| 1115 |
} |
| 1116 |
|
| 1117 |
inline Time Weeks (uint32_t weeks) |
| 1118 |
{ |
| 1119 |
return Time::FromInteger (weeks, Time::WK); |
| 1120 |
} |
| 1121 |
|
| 1122 |
inline Time Weeks (int32_t weeks) |
| 1123 |
{ |
| 1124 |
return Time::FromInteger (weeks, Time::WK); |
| 1125 |
} |
| 1126 |
|
| 1127 |
/** |
| 1128 |
* \brief create ns3::Time instances in units of years. |
| 1129 |
* |
| 1130 |
* For example: |
| 1131 |
* \code |
| 1132 |
* Time t = Years (2.0); |
| 1133 |
* Simulator::Schedule (Years (5.0), ...); |
| 1134 |
* \endcode |
| 1135 |
* \param years years value |
| 1136 |
* \relates ns3::Time |
| 1137 |
*/ |
| 1138 |
inline Time Years (double years) |
| 1139 |
{ |
| 1140 |
return Time::FromDouble (years, Time::A); |
| 1141 |
} |
| 1142 |
|
| 1143 |
inline Time Years (float years) |
| 1144 |
{ |
| 1145 |
return Time::FromDouble (years, Time::A); |
| 1146 |
} |
| 1147 |
|
| 1148 |
inline Time Years (uint64_t years) |
| 1149 |
{ |
| 1150 |
return Time::FromInteger (years, Time::A); |
| 1151 |
} |
| 1152 |
|
| 1153 |
inline Time Years (int64_t years) |
| 1154 |
{ |
| 1155 |
return Time::FromInteger (years, Time::A); |
| 1156 |
} |
| 1157 |
|
| 1158 |
inline Time Years (uint32_t years) |
| 1159 |
{ |
| 1160 |
return Time::FromInteger (years, Time::A); |
| 1161 |
} |
| 1162 |
|
| 1163 |
inline Time Years (int32_t years) |
| 1164 |
{ |
| 1165 |
return Time::FromInteger (years, Time::A); |
| 1166 |
} |
| 757 |
|
1167 |
|
| 758 |
/** |
1168 |
/** |
| 759 |
* \see Seconds(double) |
1169 |
* \see Seconds(double) |
|
|
| 803 |
{ |
1213 |
{ |
| 804 |
return Time::From (fs, Time::FS); |
1214 |
return Time::From (fs, Time::FS); |
| 805 |
} |
1215 |
} |
|
|
1216 |
/** |
| 1217 |
* \see Minutes(uint64_t) |
| 1218 |
* \relates ns3::Time |
| 1219 |
*/ |
| 1220 |
inline Time Minutes (int64x64_t minutes) |
| 1221 |
{ |
| 1222 |
return Time::From (minutes, Time::MIN); |
| 1223 |
} |
| 1224 |
/** |
| 1225 |
* \see Minutes(uint64_t) |
| 1226 |
* \relates ns3::Time |
| 1227 |
*/ |
| 1228 |
inline Time Hours (int64x64_t hours) |
| 1229 |
{ |
| 1230 |
return Time::From (hours, Time::H); |
| 1231 |
} |
| 1232 |
/** |
| 1233 |
* \see Minutes(uint64_t) |
| 1234 |
* \relates ns3::Time |
| 1235 |
*/ |
| 1236 |
inline Time Days (int64x64_t days) |
| 1237 |
{ |
| 1238 |
return Time::From (days, Time::D); |
| 1239 |
} |
| 1240 |
/** |
| 1241 |
* \see Minutes(uint64_t) |
| 1242 |
* \relates ns3::Time |
| 1243 |
*/ |
| 1244 |
inline Time Weeks (int64x64_t weeks) |
| 1245 |
{ |
| 1246 |
return Time::From (weeks, Time::WK); |
| 1247 |
} |
| 1248 |
/** |
| 1249 |
* \see Minutes(uint64_t) |
| 1250 |
* \relates ns3::Time |
| 1251 |
*/ |
| 1252 |
inline Time Years (int64x64_t years) |
| 1253 |
{ |
| 1254 |
return Time::From (years, Time::A); |
| 1255 |
} |
| 806 |
|
1256 |
|
| 807 |
// internal function not publicly documented |
1257 |
// internal function not publicly documented |
| 808 |
inline Time TimeStep (uint64_t ts) |
1258 |
inline Time TimeStep (uint64_t ts) |