00001 /*========================================================================= 00002 00003 Program: F.R.E.E. - flexible registration evaluation engine 00004 Version: v.1.0.0 00005 Date: $Date: 2006/09/01 12:00:00 $ 00006 Module: $RCSfile: freTimeStampedObject.h,v $ 00007 Language: C++ 00008 00009 00010 Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics, 00011 Institute for Medical Biometry and Informatics, University of Heidelberg, 00012 Germany). All rights reserved. 00013 See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm 00014 for details. 00015 00016 This software is distributed WITHOUT ANY WARRANTY; without even 00017 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00018 PURPOSE. See the above copyright notices for more information. 00019 00020 =========================================================================*/ 00021 #ifndef __freTimeStampedObject_h 00022 #define __freTimeStampedObject_h 00023 00024 #include "freElementals.h" 00025 #include "freXMLStreamObject.h" 00026 #include "freExceptions.h" 00027 #include "freConvert.h" 00028 00029 #include <time.h> 00030 00031 namespace FREE 00032 { 00033 00034 /* Type represents the duration of a time span (e.g. registration step) in tenth seconds*/ 00035 typedef long DurationType; 00036 typedef long TimeStampType; //will be scaled in tenth seconds; 00037 00038 freXMLTagMacro(TimeStamp, "freStat:TimeStamp"); 00039 freXMLTagMacro(TimeStampCreate, "freStat:TSCreate"); 00040 freXMLTagMacro(TimeStampClose, "freStat:TSClose"); 00041 00049 class TimeStampedObject: public XMLStreamObject 00050 { 00051 public: 00055 DurationType GetDurationTo(const TimeStampedObject& object) const; 00061 DurationType GetInterimDurationTo(const TimeStampedObject& object) const; 00064 DurationType GetDuration() const; 00065 00067 TimeStampedObject& operator = (const TimeStampedObject& object); 00068 00069 TimeStampedObject(clock_t& stampOffset, const std::string& sXMLTag = XMLTags::TimeStamp); 00070 00072 TimeStampedObject(const TimeStampedObject& object); 00073 00074 virtual ~TimeStampedObject(); 00075 00077 const TimeStampType& GetCreationTimeStamp() const; 00079 const TimeStampType& GetClosingTimeStamp() const; 00080 00082 inline void SetCreationTimeStamp() 00083 { 00084 Stamp(m_CreationTimeStamp,m_StampOffset); 00085 }; 00087 inline void SetCreationTimeStamp(const TimeStampType& timeStamp) 00088 { 00089 m_CreationTimeStamp = timeStamp; 00090 }; 00091 00093 inline void SetClosingTimeStamp() 00094 { 00095 Stamp(m_ClosingTimeStamp,m_StampOffset); 00096 }; 00098 inline void SetClosingTimeStamp(const TimeStampType& timeStamp) 00099 { 00100 m_ClosingTimeStamp = timeStamp; 00101 }; 00102 00103 /* Checks if the time stamp is already closed.*/ 00104 const bool IsClosed() const; 00105 /* Checks if there is already a creation time stamp.*/ 00106 const bool IsCreated() const; 00107 00109 virtual void Reset(); 00110 00111 protected: 00113 virtual void AttributesLoadProcessing(const AttributesType& rAttributes); 00114 00116 virtual void SaveAttributes(AttributesSaveListType& rAttributes) const; 00117 00118 clock_t& GetStampOffset() const; 00119 00120 private: 00121 /* Functions sets the passed stamp*/ 00122 static void Stamp(TimeStampType& rTimeStamp, clock_t& stampOffset); 00123 00125 TimeStampType m_CreationTimeStamp; 00126 00128 TimeStampType m_ClosingTimeStamp; 00129 00131 clock_t& m_StampOffset; 00132 }; 00133 00134 00135 } //end of namespace FREE 00136 00137 #endif
1.5.3 written by Dimitri van Heesch,
© 1997-2000