ROOT logo
// $Id: GTime.h 2256 2009-11-21 23:24:25Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

#ifndef GledCore_GTime_H
#define GledCore_GTime_H

#include <Rtypes.h>

class GTime
{
public:
  enum Init_e { I_Now };

protected:
  Long_t	mSec;	// X{GS}
  Long_t	mMuSec;	// X{GS}

public:
  GTime(Long_t s=0, Long_t mu=0) : mSec(s), mMuSec(mu) {}
  virtual ~GTime() {}
  GTime(Init_e /*i*/) { SetNow(); }
  GTime(const GTime& t) : mSec(t.mSec), mMuSec(t.mMuSec) {}
  static GTime Now() { return GTime(I_Now); }

  void  SetNow();
  GTime TimeUntilNow();

  GTime& operator=(Long_t mus);
  GTime& operator=(ULong_t mus);
  GTime& operator=(Double_t sec);

  GTime& operator+=(const GTime& t);
  GTime& operator-=(const GTime& t);

  GTime& operator+=(Long_t mus);
  GTime& operator-=(Long_t mus);

  GTime& operator+=(ULong_t mus);
  GTime& operator-=(ULong_t mus);

  GTime& operator+=(Double_t sec);
  GTime& operator-=(Double_t sec);

  GTime operator+(const GTime& t) const;
  GTime operator-(const GTime& t) const;

  bool  operator<(const GTime& t) const;
  bool  operator>(const GTime& t) const;
  bool  operator<=(const GTime& t) const;
  bool  operator>=(const GTime& t) const;
  bool  operator==(const GTime& t) const;

  Double_t ToDouble()  { return mSec + 1e-6*mMuSec; }
  ULong_t  ToMiliSec() { return mSec*1000 + mMuSec/1000; }
  ULong_t  ToMiliSec(Long_t max) { return mSec >= max ? max*1000 : mSec*1000 + mMuSec/1000; }

  void Sleep();

  static void SleepMiliSec(UInt_t ms);

#include "GTime.h7"
  ClassDefNV(GTime, 1);
}; // endclass GTime

#endif
 GTime.h:1
 GTime.h:2
 GTime.h:3
 GTime.h:4
 GTime.h:5
 GTime.h:6
 GTime.h:7
 GTime.h:8
 GTime.h:9
 GTime.h:10
 GTime.h:11
 GTime.h:12
 GTime.h:13
 GTime.h:14
 GTime.h:15
 GTime.h:16
 GTime.h:17
 GTime.h:18
 GTime.h:19
 GTime.h:20
 GTime.h:21
 GTime.h:22
 GTime.h:23
 GTime.h:24
 GTime.h:25
 GTime.h:26
 GTime.h:27
 GTime.h:28
 GTime.h:29
 GTime.h:30
 GTime.h:31
 GTime.h:32
 GTime.h:33
 GTime.h:34
 GTime.h:35
 GTime.h:36
 GTime.h:37
 GTime.h:38
 GTime.h:39
 GTime.h:40
 GTime.h:41
 GTime.h:42
 GTime.h:43
 GTime.h:44
 GTime.h:45
 GTime.h:46
 GTime.h:47
 GTime.h:48
 GTime.h:49
 GTime.h:50
 GTime.h:51
 GTime.h:52
 GTime.h:53
 GTime.h:54
 GTime.h:55
 GTime.h:56
 GTime.h:57
 GTime.h:58
 GTime.h:59
 GTime.h:60
 GTime.h:61
 GTime.h:62
 GTime.h:63
 GTime.h:64
 GTime.h:65
 GTime.h:66
 GTime.h:67
 GTime.h:68