1 /*========================================================================= 2 * 3 * Copyright Insight Software Consortium 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0.txt 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 *=========================================================================*/ 18 #ifndef itkRealTimeClock_h 19 #define itkRealTimeClock_h 20 21 #include "itkMacro.h" 22 #include "itkObject.h" 23 #include "itkObjectFactory.h" 24 #include "itkRealTimeStamp.h" 25 26 namespace itk 27 { 28 /** \class RealTimeClock 29 * \brief Provides a timestamp from a real-time clock. 30 * 31 * This class represents a real-time clock object 32 * and provides a timestamp in platform-independent format. 33 * 34 * \author Hee-Su Kim, Compute Science Dept. Kyungpook National University, 35 * ISIS Center, Georgetown University. 36 * \ingroup ITKCommon 37 */ 38 39 class ITKCommon_EXPORT RealTimeClock:public Object 40 { 41 public: 42 using Self = RealTimeClock; 43 using Superclass = Object; 44 using Pointer = SmartPointer< Self >; 45 using ConstPointer = SmartPointer< const Self >; 46 47 /** Method for defining the name of the class */ 48 itkTypeMacro(RealTimeClock, Object); 49 50 /** Method for creation through the object factory */ 51 itkNewMacro(Self); 52 53 /** Define the type for the timestap */ 54 using TimeStampType = double; 55 56 /** Define the type for the frequency of the clock */ 57 using FrequencyType = double; 58 59 /** Returns a timestamp in seconds, e.g. 52.341243 seconds */ 60 TimeStampType GetTimeInSeconds() const; 61 62 /** Returns the frequency of a clock */ 63 itkGetConstMacro(Frequency, FrequencyType); 64 65 /** Get the time as a RealTimeStamp type. */ 66 RealTimeStamp GetRealTimeStamp() const; 67 68 protected: 69 70 /** Constructor. */ 71 RealTimeClock(); 72 73 /** Destructor. */ 74 ~RealTimeClock() override; 75 76 void PrintSelf(std::ostream & os, Indent indent) const override; 77 78 private: 79 FrequencyType m_Frequency{1}; 80 TimeStampType m_Difference; 81 TimeStampType m_Origin; 82 83 // Returns a timestamp in a TimeStamp data structure. 84 // We hide this method in the private section, because it returns the 85 // modified time of the itk::Object. That modified time is ambiguous with 86 // the role of the RealTimeStamp. 87 const TimeStamp & GetTimeStamp() const override; 88 }; 89 } // end of namespace itk 90 91 #endif // itkRealTimeClock_h 92