// $Source: /usr/local/SimSoft/SoftShop/Basics/Timing/Clock.h,v $
// $Revision: 1.20 $
// $Author: baum $
// $Date: 2001/11/29 15:52:23 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-20 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: Clock.h,v $
// Revision 1.20  2001/11/29 15:52:23  baum
// -In Kalender.cpp und Kalender.h Handsteuerung eingebaut
//

#ifndef _CLOCK_H
#define _CLOCK_H  1

#include <iostream.h>

#ifdef WIN32
#include <windows.h>
#include <winbase.h>
#include <time.h>

#elif defined (__OS2__)
#include <os2.h>
#include <time.h>

#else
#include <time.h>
#include <sys/times.h>
#endif

#ifdef _CLOCK_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_BASICS_DLL
#  undef _impexp
#  define _impexp __declspec(dllexport)
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

#if defined __GNUG__ || defined __hpux
#  undef _impexp
#  define _impexp
#endif

//==================================================================
//		Class-Header
//		for class Clock
//==================================================================

//##ModelId=3FBCBCC70251
class _impexp Clock {
  public:
    //contructor
	//##ModelId=3FBCBCC70261
    Clock (unsigned start = 1);

    //destructor
	//##ModelId=3FBCBCC70263
    ~Clock ();

    // actions 
	//##ModelId=3FBCBCC70264
    void start ();

    // getting runtime in sec
	//##ModelId=3FBCBCC70265
    double stop ();

    // resetting the Clock
	//##ModelId=3FBCBCC70271
    double reset ();

    // getting the elapsed time in sec
	//##ModelId=3FBCBCC70272
    const double& operator () () const;
	//##ModelId=3FBCBCC70274
    const double& Elapsed () const;

    // Clock-output to a stream
	//##ModelId=3FBCBCC70276
    ostream& print (ostream&);

  private:
    // copy constructor declared, but not defined
	//##ModelId=3FBCBCC70281
    Clock (const Clock&);

    // assignment operator declared, but not defined
	//##ModelId=3FBCBCC70283
    Clock& operator = (const Clock&);

#ifdef WIN32
    DWORD ObjStart, ObjStop;
	//##ModelId=3FBCBCC70290
    friend WINBASEAPI DWORD WINAPI GetTickCount ();
#elif defined (__OS2__)
    ULONG ObjStart, ObjStop;
    friend void DosQuerySysInfo (enum, enum, ULONG *, int);
#else
    struct tms ObjBuf;
    time_t ObjStart, ObjStop;
//    friend clock_t times(struct tms *);
#endif

	//##ModelId=3FBCBCC70285
    double ObjElapsed;

}; // class Clock

inline ostream& operator << (ostream& ostrm, Clock& c) {
  return c.print (ostrm);
}

//##ModelId=3FBCBCC7029F
class _impexp AutoClock : private Clock {
  public:
    // constructors
	//##ModelId=3FBCBCC702A1
    AutoClock (char* name, ostream& ostrm);

    // destructor
	//##ModelId=3FBCBCC702B1
    ~AutoClock ();

  private:
	//##ModelId=3FBCBCC702B2
    AutoClock ();
	//##ModelId=3FBCBCC702B3
    AutoClock (const AutoClock&);
	//##ModelId=3FBCBCC702BF
    const AutoClock& operator = (const AutoClock&);

    // data members
	//##ModelId=3FBCBCC702C2
    ostream& ObjStream;
	//##ModelId=3FBCBCC702C6
    char* ObjName;

}; // class AutoClock



#endif  // !_CLOCK_H

