Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:42

0001 // Created on: 1993-01-04
0002 // Created by: J.P. BOUDIER - J.P. TIRAULT
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Quantity_Period_HeaderFile
0018 #define _Quantity_Period_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Boolean.hxx>
0025 
0026 //! Manages date intervals. For example, a Period object
0027 //! gives the interval between two dates.
0028 //! A period is expressed in seconds and microseconds.
0029 class Quantity_Period 
0030 {
0031 public:
0032 
0033   DEFINE_STANDARD_ALLOC
0034 
0035   //! Creates a Period
0036   //! With:      0 <= dd
0037   //! 0 <= hh
0038   //! 0 <= mn
0039   //! 0 <= ss
0040   //! 0 <= mis
0041   //! 0 <= mics
0042   Standard_EXPORT Quantity_Period(const Standard_Integer dd, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0);
0043   
0044   //! Creates a Period with a number of seconds and microseconds.
0045   //! Exceptions
0046   //! Quantity_PeriodDefinitionError:
0047   //! -   if the number of seconds expressed either by:
0048   //! -   dd days, hh hours, mn minutes and ss seconds, or
0049   //! -   Ss
0050   //! is less than 0.
0051   //! -   if the number of microseconds expressed either by:
0052   //! -   mis milliseconds and mics microseconds, or
0053   //! -   Mics
0054   //! is less than 0.
0055   Standard_EXPORT Quantity_Period(const Standard_Integer ss, const Standard_Integer mics = 0);
0056   
0057   //! Decomposes this period into a number of days,hours,
0058   //! minutes,seconds,milliseconds and microseconds
0059   //! Example of return values:
0060   //! 2 days, 15 hours, 0 minute , 0 second
0061   //! 0 millisecond and 0 microsecond
0062   Standard_EXPORT void Values (Standard_Integer& dd, Standard_Integer& hh, Standard_Integer& mn, Standard_Integer& ss, Standard_Integer& mis, Standard_Integer& mics) const;
0063   
0064   //! Returns the number of seconds in Ss and the
0065   //! number of remainding microseconds in Mics of this period.
0066   //! Example of return values: 3600 seconds and 0 microseconds
0067   Standard_EXPORT void Values (Standard_Integer& ss, Standard_Integer& mics) const;
0068   
0069   //! Assigns to this period the time interval defined
0070   //! -   with dd days, hh hours, mn minutes, ss
0071   //! seconds, mis (defaulted to 0) milliseconds and
0072   //! mics (defaulted to 0) microseconds; or
0073   Standard_EXPORT void SetValues (const Standard_Integer dd, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0);
0074   
0075   //! Assigns to this period the time interval defined
0076   //! -   with Ss seconds and Mics (defaulted to 0) microseconds.
0077   //! Exceptions
0078   //! Quantity_PeriodDefinitionError:
0079   //! -   if the number of seconds expressed either by:
0080   //! -   dd days, hh hours, mn minutes and ss seconds, or
0081   //! -   Ss
0082   //! is less than 0.
0083   //! -   if the number of microseconds expressed either by:
0084   //! -   mis milliseconds and mics microseconds, or
0085   //! -   Mics
0086   //! is less than 0.
0087   Standard_EXPORT void SetValues (const Standard_Integer ss, const Standard_Integer mics = 0);
0088   
0089   //! Subtracts one Period from another and returns the difference.
0090   Standard_EXPORT Quantity_Period Subtract (const Quantity_Period& anOther) const;
0091 Quantity_Period operator - (const Quantity_Period& anOther) const
0092 {
0093   return Subtract(anOther);
0094 }
0095   
0096   //! Adds one Period to another one.
0097   Standard_EXPORT Quantity_Period Add (const Quantity_Period& anOther) const;
0098 Quantity_Period operator + (const Quantity_Period& anOther) const
0099 {
0100   return Add(anOther);
0101 }
0102   
0103   //! Returns TRUE if both <me> and <other> are equal.
0104   Standard_EXPORT Standard_Boolean IsEqual (const Quantity_Period& anOther) const;
0105 Standard_Boolean operator == (const Quantity_Period& anOther) const
0106 {
0107   return IsEqual(anOther);
0108 }
0109   
0110   //! Returns TRUE if <me> is shorter than <other>.
0111   Standard_EXPORT Standard_Boolean IsShorter (const Quantity_Period& anOther) const;
0112 Standard_Boolean operator < (const Quantity_Period& anOther) const
0113 {
0114   return IsShorter(anOther);
0115 }
0116   
0117   //! Returns TRUE if <me> is longer then <other>.
0118   Standard_EXPORT Standard_Boolean IsLonger (const Quantity_Period& anOther) const;
0119 Standard_Boolean operator > (const Quantity_Period& anOther) const
0120 {
0121   return IsLonger(anOther);
0122 }
0123   
0124   //! Checks the validity of a Period in form (dd,hh,mn,ss,mil,mic)
0125   //! With:      0 <= dd
0126   //! 0 <= hh
0127   //! 0 <= mn
0128   //! 0 <= ss
0129   //! 0 <= mis
0130   //! 0 <= mics
0131   Standard_EXPORT static Standard_Boolean IsValid (const Standard_Integer dd, const Standard_Integer hh, const Standard_Integer mn, const Standard_Integer ss, const Standard_Integer mis = 0, const Standard_Integer mics = 0);
0132   
0133   //! Checks the validity of a Period in form (ss,mic)
0134   //! With:      0 <= ss
0135   //! 0 <= mics
0136   Standard_EXPORT static Standard_Boolean IsValid (const Standard_Integer ss, const Standard_Integer mics = 0);
0137 
0138 private:
0139 
0140   Standard_Integer mySec;
0141   Standard_Integer myUSec;
0142 
0143 };
0144 
0145 #endif // _Quantity_Period_HeaderFile