(file) Return to TimeValue.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 martin 1.21 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.22 //
  3 martin 1.21 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.22 //
 10 martin 1.21 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.22 //
 17 martin 1.21 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.22 //
 20 martin 1.21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.22 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.22 //
 28 martin 1.21 //////////////////////////////////////////////////////////////////////////
 29 mike   1.8  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #ifndef Pegasus_TimeValue_h
 33             #define Pegasus_TimeValue_h
 34             
 35             #include <Pegasus/Common/Config.h>
 36             #include <Pegasus/Common/System.h>
 37 kumpf  1.11 #include <Pegasus/Common/Linkage.h>
 38 mike   1.8  
 39             PEGASUS_NAMESPACE_BEGIN
 40             
 41             /** The TimeValue class represents time expressed in seconds plus microseconds.
 42             */
 43             class PEGASUS_COMMON_LINKAGE TimeValue
 44             {
 45             public:
 46             
 47                 TimeValue() : _seconds(0), _microseconds(0)
 48                 {
 49                 }
 50             
 51 kumpf  1.17     TimeValue(Uint32 seconds, Uint32 microseconds)
 52                     : _seconds(seconds), _microseconds(microseconds)
 53 mike   1.8      {
 54                 }
 55             
 56 kumpf  1.17     Uint32 getSeconds() const
 57 mike   1.8      {
 58 kumpf  1.17         return _seconds;
 59 mike   1.8      }
 60             
 61                 void setSeconds(Uint32 seconds)
 62                 {
 63 kumpf  1.17         _seconds = seconds;
 64 mike   1.8      }
 65             
 66 kumpf  1.17     Uint32 getMicroseconds() const
 67 mike   1.8      {
 68 kumpf  1.17         return _microseconds;
 69 mike   1.8      }
 70             
 71 kumpf  1.17     Uint64 toMicroseconds() const
 72 jim.wunderlich 1.15     {
 73 kumpf          1.17         return (Uint64(_seconds) * Uint64(1000000)) + Uint64(_microseconds);
 74 jim.wunderlich 1.15     }
 75                     
 76 mike           1.8      void setMicroseconds(Uint32 microseconds)
 77                         {
 78 kumpf          1.17         _microseconds = microseconds;
 79 mike           1.8      }
 80                     
 81 kumpf          1.20     void fromMilliseconds(Uint64 milliseconds)
 82 mike           1.8      {
 83 kumpf          1.20         _seconds = Uint32(milliseconds / 1000);
 84                             _microseconds = Uint32(milliseconds % 1000) * 1000;
 85 mike           1.8      }
 86                     
 87 kumpf          1.20     Uint64 toMilliseconds() const
 88 mike           1.8      {
 89 kumpf          1.20         return Uint64(_seconds) * Uint64(1000) +
 90                                 Uint64(_microseconds) / Uint64(1000);
 91 mike           1.8      }
 92                     
 93                         static TimeValue getCurrentTime()
 94                         {
 95 kumpf          1.17         Uint32 seconds;
 96                             Uint32 microseconds;
 97                             System::getCurrentTimeUsec(seconds, microseconds);
 98                             return TimeValue(seconds, microseconds);
 99 mike           1.8      }
100                     
101                     private:
102                         Uint32 _seconds;
103                         Uint32 _microseconds;
104                     };
105                     
106                     PEGASUS_NAMESPACE_END
107                     
108                     #endif /* Pegasus_TimeValue_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2