00001 #include <iostream>
00002 #include <sys/time.h>
00003
00004 using namespace std;
00005
00006 #ifndef __SSSL_MEASUREMENT_H__
00007 #define __SSSL_MEASUREMENT_H__
00008
00009 class Measurement {
00010
00011 public:
00012
00013 Measurement(int arg = 0) {Set(arg);};
00014
00015 Measurement(double arg) {Set(arg);};
00016
00017 Measurement(float arg) {Set(arg);};
00018 Measurement(long sec, long usec) {
00019 tStamp.tv_sec = sec;
00020 tStamp.tv_usec = usec;
00021 };
00022 virtual ~Measurement() {};
00023
00024 void SetTime(long sec, long usec) {
00025 tStamp.tv_sec = sec;
00026 tStamp.tv_usec = usec;
00027 };
00028
00029 void GetTime(long &sec, long &usec) {
00030 sec = tStamp.tv_sec;
00031 usec = tStamp.tv_usec;
00032 };
00033
00034 void GetTime(struct timeval &t) { t = tStamp; };
00035
00036 void Set(int arg) {data = malloc(sizeof(int)); *(int *)data = arg;};
00037
00038 void Set(double arg) {data = malloc(sizeof(double)); *(double *)data = arg;};
00039
00040 void Set(float arg) {data = malloc(sizeof(float)); *(float*)data = arg;};
00041
00042 int GetAsInt() {return *((int *)data);};
00043
00044 double GetAsDouble() {return *((double *)data);};
00045
00046 float GetAsFloat() {return *((float *)data);};
00047
00048 private:
00049 void *data;
00050 struct timeval tStamp;
00051
00052 };
00053
00054 #endif