AuditLine.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CERTI - HLA RunTime Infrastructure
00003 // Copyright (C) 2002, 2003  ONERA
00004 //
00005 // This file is part of CERTI-libCERTI
00006 //
00007 // CERTI-libCERTI is free software ; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License
00009 // as published by the Free Software Foundation ; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // CERTI-libCERTI is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY ; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015 // Lesser General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU Lesser General Public
00018 // License along with this program ; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020 // USA
00021 //
00022 // $Id: AuditLine.cc,v 3.11 2007/07/06 09:25:17 erk Exp $
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 } // namespace certi
00129 
00130 // $Id: AuditLine.cc,v 3.11 2007/07/06 09:25:17 erk Exp $
00131 

Generated on Thu Apr 30 15:53:48 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5