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

ac_log.H

00001 /************************************************
00002  *
00003  *  ac_log.H - include file for ArchC log types
00004  *
00005  * Author: Sandro Rigo
00006  * Date  : 02/04/2002  
00007  ************************************************/
00008 #ifndef _AC_LOG_H
00009 #define _AC_LOG_H
00010 
00011 #include <list>
00012 #include <iostream>
00013 #include <fstream>
00014 #include <iomanip>
00015 #include "ac_parms.H"
00016 
00017 using std::list;
00018 using std::setw;
00019 using std::ostream;
00020 using std::fstream;
00021 using std::hex;
00022 using std::dec;
00023 
00025 
00027 
00028 class change_log{
00029 public:
00030 
00031   unsigned addr;        
00032   ac_Sword value;            
00033   double time;          
00034 
00035 
00036 
00038   change_log(): addr(0), value(0), time(0.0){}
00039 
00040   change_log( int a, ac_word  v, double t): addr(a), value(v), time(t){}
00041 
00043   friend bool operator== (const change_log  & cl1,
00044                           const change_log  & cl2){
00045     bool flag = true;
00046     
00047     flag = flag && (cl1.addr == cl2.addr);
00048     flag = flag && (cl1.time == cl2.time);
00049     flag = flag && (cl1.value == cl2.value);
00050     
00051     return flag;
00052   }
00053 
00055   friend bool operator< (const change_log  & cl1,
00056                          const change_log  & cl2){
00057     
00058     if( cl1.time != cl2.time )
00059       return (cl1.time < cl2.time);
00060     else
00061       return (cl1.addr < cl2.addr);
00062     
00063   }
00064 
00066   friend ostream& operator<< (ostream &os,
00067                         const change_log &cl){
00068 
00069                 os.fill(' ');
00070     os << "  " << setw(10) << hex << cl.addr 
00071                          << "    " << setw(10) << (int)cl.value 
00072                          << "    " << setw(12) << dec << cl.time;
00073     return os;
00074   }
00075   
00076 
00078         void save( fstream &of ){
00079 
00080                 char *buffer;
00081                 int size = sizeof(ac_Sword) + sizeof(unsigned) + sizeof(double);
00082                 buffer = new char[size];
00083 
00084                 //Storing fields into the buffer
00085                 *((int *)buffer) = addr; 
00086                 *((ac_Sword *)(buffer+sizeof(unsigned))) = value; 
00087                 *((double *)(buffer+sizeof(ac_Sword)+sizeof(unsigned))) = time; 
00088 
00089                 of.write(buffer, size);
00090         }
00091 
00092 };
00093 
00095 typedef list<change_log> log_list;
00096 
00097 #endif //_AC_LOG_H
00098 

Generated on Thu Jun 24 08:30:05 2004 for ArchC by doxygen 1.3.4