//===========================================================================// // File: time.cc // // Project: MUNGA Brick: Time Manager // // Contents: Implementation details of the Time Manager // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- ---------------------------------------------------------- // // 10/19/94 JMA Initial coding. // // 10/24/94 JMA Added Lester's IBM RTC code in as SystemClock class // // 10/28/94 JMA Made compatible with SGI CC // // 11/03/94 ECH Made compatible with BC4.0 // //---------------------------------------------------------------------------// // Copyright (C) 1994-1995, Virtual World Entertainment, Inc. // // PROPRIETARY AND CONFIDENTIAL // //===========================================================================// #include #pragma hdrstop #if !defined(TIME_HPP) #include #endif //############################################################################# //########################### System Clock ############################## //############################################################################# //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void SystemClock::TogglePause() { // //-------------------------------------------------------------------- // If the clock is currently paused, figure out how long it was paused // and add that to the pause delay //-------------------------------------------------------------------- // if (timer.pauseStart) { timer.pauseTime += GetRTC() - timer.pauseStart; timer.pauseStart = 0L; } // //-------------------------------------------------------- // Otherwise, start pausing by marking what time it is now //-------------------------------------------------------- // else { timer.pauseStart = GetRTC(); } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // volatile Time& Now() { static Time result; // //------------------------------------------------- // If we are in pause mode, return the paused clock //------------------------------------------------- // if (SystemClock::timer.pauseStart) { result = SystemClock::timer.pauseStart; } // //---------------------------------------------------------------- // Otherwise, return the timer minus the amount of pause time lost //---------------------------------------------------------------- // else { result = SystemClock::GetRTC() - SystemClock::timer.pauseTime; } return result; } //############################################################################# //############################### Time ################################## //############################################################################# Time Time::Null(SystemClock::timer); #if defined(USE_SIGNATURE) int Is_Signature_Bad(const volatile Time *) { return False; } #endif // //############################################################################# //############################################################################# // Logical Time::TestInstance() const volatile { return True; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Time functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // //############################################################################# //############################################################################# // void Convert_From_Ascii( const char *str, Time *time ) { Check_Pointer(str); Check_Signature(time); Scalar seconds; seconds = atof(str); *time = seconds; Check(time); } #if defined(TEST_CLASS) # include "time.tcp" #endif