00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "AuditLine.hh"
00027
00028 #include "certi.hh"
00029
00030 #include <string>
00031 #include <time.h>
00032
00033 using std::ofstream ;
00034 using std::endl ;
00035 using std::string ;
00036
00037 namespace certi {
00038
00039
00041
00043 AuditLine::AuditLine()
00044 : federation(0), federate(0), type(0), level(0), status(0),
00045 modified(false), date(0)
00046 {
00047 }
00048
00049
00051
00053 AuditLine::AuditLine(unsigned short event_type, unsigned short event_level,
00054 unsigned short event_status, std::string reason)
00055 : federation(0), federate(0),
00056 type(event_type), level(event_level), status(event_status),
00057 modified(false), date(0), comment(reason)
00058 {
00059 }
00060
00061
00063 AuditLine::~AuditLine()
00064 {
00065 }
00066
00067
00069 void
00070 AuditLine::addComment(const std::string &str)
00071 {
00072 comment += str ;
00073 modified = true ;
00074 }
00075
00076
00078 void
00079 AuditLine::end(unsigned short event_status, const std::string reason)
00080 {
00081 status = event_status ;
00082 addComment(reason);
00083 }
00084
00085
00087
00097 void
00098 AuditLine::write(std::ofstream &audit_file)
00099 {
00100 audit_file << date << ' ' << federation << ' ' << federate << ' '
00101 << type << ' ' << level << ' ' << status << ' '
00102 << comment << endl ;
00103
00104 audit_file.flush();
00105 }
00106
00107 void
00108 AuditLine::setFederation(Handle h)
00109 {
00110 federation = h ;
00111 modified = true ;
00112 }
00113
00114 void
00115 AuditLine::setFederate(FederateHandle h)
00116 {
00117 federate = h ;
00118 modified = true ;
00119 }
00120
00121 void
00122 AuditLine::setLevel(unsigned short l)
00123 {
00124 level = l ;
00125 modified = true ;
00126 }
00127
00128 }
00129
00130
00131