Initial commit of files
This commit is contained in:
79
include/libnet++/Clock.h
Normal file
79
include/libnet++/Clock.h
Normal file
@ -0,0 +1,79 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Clock__
|
||||
#define __Clock__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Clock {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
struct timespec Time;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Clock();
|
||||
Clock( time_t tic );
|
||||
|
||||
// destructor
|
||||
virtual ~Clock();
|
||||
|
||||
Clock( const Clock& );
|
||||
const Clock& operator=( const Clock& );
|
||||
|
||||
// public methods
|
||||
time_t GetUtc( void ) { return Time.tv_sec; };
|
||||
struct timespec GetTimeSpec() { return Time; };
|
||||
|
||||
int Format( char *buf, int max );
|
||||
struct timespec Parse( const char *buf );
|
||||
|
||||
void SetTime( void );
|
||||
void SetTime( time_t sec, suseconds_t usec=0L );
|
||||
void SetTime( const struct timespec &tv ) { Time = tv; };
|
||||
|
||||
// microsecond time stamp
|
||||
unsigned long long GetTimeStamp();
|
||||
void SetTimeStamp( unsigned long long ts );
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
static int Format( const struct timespec &tv, char **buf, int *max );
|
||||
|
||||
// private methods
|
||||
private:
|
||||
|
||||
// signal catchers (do not override)
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user