home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / itime.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  3.5 KB  |  126 lines

  1.  
  2. #ifndef _ITIME_
  3. #define _ITIME_
  4. /*******************************************************************************
  5. * FILE NAME: itime.hpp                                                         *
  6. *                                                                              *
  7. * DESCRIPTION:                                                                 *
  8. *   Declaration of the classes:                                                *
  9. *     ITime                                                                    *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   IBM Open Class Library                                                     *
  13. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  14. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #include <ibase.hpp>
  20. #include <istring.hpp>
  21.  
  22. /*  The "struct blocks" must be placed before SOM enablement test  */
  23. #if ( IC_OBSOLETE <= IC_OBSOLETE_2 )
  24. #endif
  25.  
  26. struct ICnrTime {
  27.   unsigned char hours;
  28.   unsigned char minutes;
  29.   unsigned char seconds;
  30.   unsigned char ucReserved;
  31. };
  32.  
  33. #pragma pack(4)
  34.  
  35. class ostream;
  36.  
  37.  
  38.  
  39.  
  40.  
  41. class ITime : public IBase {
  42. public:
  43. /*------------------------ Constructors --------------------------------------*/
  44.   ITime       ( );
  45.  
  46.   ITime       ( long seconds );
  47.  
  48.   ITime       ( unsigned hours,
  49.                 unsigned minutes,
  50.                 unsigned seconds = 0 );
  51.  
  52.   ITime       ( const ITime &aTime );
  53.  
  54.   ITime       ( const ICnrTime &cnrTime );
  55.  
  56. /*-------------------------- Current Time ------------------------------------*/
  57. static ITime
  58.   now         ( );
  59.  
  60. /*-------------------------- Diagnostics -------------------------------------*/
  61. IString
  62.   asString    ( const char *fmt = "%X" ) const;
  63.  
  64. friend ostream
  65.  &operator << ( ostream     &aStream,
  66.                 const ITime &aTime );
  67.  
  68.  
  69. /*-------------------------- Time Queries ------------------------------------*/
  70. long
  71.   asSeconds   ( ) const;
  72.  
  73. ICnrTime
  74.   asICnrTime  ( ) const;
  75.  
  76. unsigned
  77.   hours       ( ) const,
  78.   minutes     ( ) const,
  79.   seconds     ( ) const;
  80.  
  81. /*-------------------------- Comparisons -------------------------------------*/
  82. Boolean
  83.   operator == ( const ITime &aTime ) const,
  84.   operator != ( const ITime &aTime ) const,
  85.   operator <  ( const ITime &aTime ) const,
  86.   operator <= ( const ITime &aTime ) const,
  87.   operator >  ( const ITime &aTime ) const,
  88.   operator >= ( const ITime &aTime ) const;
  89.  
  90. /*------------------------- Manipulations ------------------------------------*/
  91. ITime
  92.   operator +  ( const ITime &aTime ) const,
  93.   operator -  ( const ITime &aTime ) const;
  94.  
  95. ITime
  96.  &operator += ( const ITime &aTime ),
  97.  &operator -= ( const ITime &aTime );
  98.  
  99.  
  100. protected:
  101. /*------------------------- Initialize ---------------------------------------*/
  102. ITime
  103.  &initialize  ( long seconds );
  104.  
  105. private:
  106. /*------------------------- PRIVATE ------------------------------------------*/
  107. #if ( IC_OBSOLETE <= IC_OBSOLETE_2 )
  108. #endif
  109.  
  110. long
  111.   ticks;
  112.  
  113.  
  114.  
  115. }; // ITime
  116.  
  117.  
  118.  
  119. #pragma pack()
  120.  
  121.   #include <itime.inl>
  122.  
  123. #endif /* _ITIME_ */
  124.  
  125.  
  126.