Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

Measurement.h

Go to the documentation of this file.
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         // ! \brief Integer type(and effective default) constructor.
00013         Measurement(int arg = 0) {Set(arg);};
00014         // ! \brief Double type constructor.
00015         Measurement(double arg) {Set(arg);};
00016         // ! \brief Float type constructor.
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         // ! \brief Set measurement time using seconds and microseconds.
00024         void SetTime(long sec, long usec) {
00025                         tStamp.tv_sec = sec;
00026                         tStamp.tv_usec = usec;
00027                 };
00028         // ! \brief Get measurement time.
00029         void GetTime(long &sec, long &usec) {
00030                 sec = tStamp.tv_sec;
00031                 usec = tStamp.tv_usec;
00032         };
00033         // ! \brief Get measurement time
00034                 void GetTime(struct timeval &t) { t = tStamp; };
00035         // ! \brief Set as an integer.
00036         void Set(int arg) {data = malloc(sizeof(int)); *(int *)data = arg;};
00037         // ! \brief Set as a double.
00038         void Set(double arg) {data = malloc(sizeof(double)); *(double *)data = arg;};
00039         // ! \brief Set as a float.
00040         void Set(float arg) {data = malloc(sizeof(float)); *(float*)data = arg;};
00041         // ! \brief Get as an integer.
00042         int GetAsInt() {return *((int *)data);};
00043         // ! \brief Get as a double.
00044         double GetAsDouble() {return *((double *)data);};
00045         // ! \brief Get as a float.
00046         float GetAsFloat() {return *((float *)data);};
00047         
00048                 private:
00049         void *data;
00050         struct timeval tStamp;
00051                         
00052 };
00053 
00054 #endif

Generated on Wed Sep 5 12:54:22 2007 for DSACSS Operational Code by  doxygen 1.3.9.1