00001 00002 // exotkTrace_File.cxx 00004 // Copyright (C) 2001 Stephane Routelous 00005 // 00006 // This file is part of exoTK. 00007 // 00008 // exoTK is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // exoTK is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with exoTK; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00029 #include <exotkTrace_File.hxx> 00030 #ifndef _OSD_Directory_HeaderFile 00031 #include <OSD_Directory.hxx> 00032 #endif 00033 #ifndef _Quantity_Date_HeaderFile 00034 #include <Quantity_Date.hxx> 00035 #endif 00036 #ifndef _OSD_Process_HeaderFile 00037 #include <OSD_Process.hxx> 00038 #endif 00039 #ifndef _exotkUtils_HeaderFile 00040 #include <exotkUtils.hxx> 00041 #endif 00042 #ifndef _OSD_File_HeaderFile 00043 #include <OSD_File.hxx> 00044 #endif 00045 #ifndef _OSD_Protection_HeaderFile 00046 #include <OSD_Protection.hxx> 00047 #endif 00048 #ifndef _TCollection_AsciiString_HeaderFile 00049 #include <TCollection_AsciiString.hxx> 00050 #endif 00051 #ifndef _exotkTrace_HeaderFile 00052 #include <exotkTrace.hxx> 00053 #endif 00054 00055 // 00056 IMPLEMENT_STANDARD_HANDLE(exotkTrace_File, exotkTrace_Root) 00057 IMPLEMENT_STANDARD_RTTI(exotkTrace_File, exotkTrace_Root) 00058 // 00059 // Foreach ancestors, we add a IMPLEMENT_STANDARD_SUPERTYPE and 00060 // a IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY macro. 00061 // We must respect the order: from the direct ancestor class 00062 // to the base class. 00063 // 00064 00065 IMPLEMENT_STANDARD_TYPE(exotkTrace_File) 00066 IMPLEMENT_STANDARD_SUPERTYPE(exotkTrace_Root) 00067 IMPLEMENT_STANDARD_SUPERTYPE(MMgt_TShared) 00068 IMPLEMENT_STANDARD_SUPERTYPE(Standard_Transient) 00069 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY() 00070 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(exotkTrace_Root) 00071 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(MMgt_TShared) 00072 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(Standard_Transient) 00073 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END() 00074 IMPLEMENT_STANDARD_TYPE_END(exotkTrace_File) 00075 00076 00077 //================================================================================== 00078 // Function name : exotkTrace_File::exotkTrace_File 00079 //================================================================================== 00080 // Written by : Stephane Routelous - 2001-12-29 00:48:03 00081 // Description : 00082 // Return type : 00083 //================================================================================== 00084 exotkTrace_File::exotkTrace_File() 00085 { 00086 } 00087 00088 00089 //================================================================================== 00090 // Function name : exotkTrace_File::~exotkTrace_File 00091 //================================================================================== 00092 // Written by : Stephane Routelous - 2001-12-29 00:48:05 00093 // Description : 00094 // Return type : 00095 //================================================================================== 00096 exotkTrace_File::~exotkTrace_File() 00097 { 00098 } 00099 00100 //================================================================================== 00101 // Function name : exotkTrace_File::Print 00102 //================================================================================== 00103 // Written by : Stephane Routelous - 2001-12-29 00:48:06 00104 // Description : 00105 // Return type : void 00106 //================================================================================== 00107 // Argument : const enum exotkTrace_Level aLevel 00108 // Argument : const Standard_CString aString 00109 void exotkTrace_File::Print(const enum exotkTrace_Level aLevel,const Standard_CString aString) 00110 { 00111 OSD_File theFile(myFilename); 00112 theFile.Append(OSD_WriteOnly,OSD_Protection()); 00113 TCollection_AsciiString theString = exotkUtils::CurrentDateToAsciiString(exotkUtils_dfText); 00114 theString += TCollection_AsciiString(" : ") + exotkTrace::TraceLevelToAsciiString(aLevel); 00115 theString += TCollection_AsciiString(" : ") + TCollection_AsciiString(aString); 00116 theString += TCollection_AsciiString("\r\n"); 00117 theFile.Write(theString,theString.Length()); 00118 theFile.Close(); 00119 } 00120 00121 //================================================================================== 00122 // Function name : exotkTrace_File::IsValid 00123 //================================================================================== 00124 // Written by : Stephane Routelous - 2001-12-29 00:48:08 00125 // Description : 00126 // Return type : Standard_Boolean 00127 //================================================================================== 00128 Standard_Boolean exotkTrace_File::IsValid() 00129 { 00130 //todo 00131 return Standard_True; 00132 } 00133 00134 //================================================================================== 00135 // Function name : exotkTrace_File::SetFilename 00136 //================================================================================== 00137 // Written by : Stephane Routelous - 2001-12-29 00:48:09 00138 // Description : 00139 // Return type : void 00140 //================================================================================== 00141 // Argument : const OSD_Path& aFilename 00142 void exotkTrace_File::SetFilename(const OSD_Path& aFilename) 00143 { 00144 myFilename = aFilename; 00145 } 00146 00147 //================================================================================== 00148 // Function name : exotkTrace_File::GenerateFilename 00149 //================================================================================== 00150 // Written by : Stephane Routelous - 2001-12-29 00:48:11 00151 // Description : 00152 // Return type : void 00153 //================================================================================== 00154 // Argument : const Standard_CString aSeed 00155 // Argument : const OSD_Directory& aDirectory 00156 void exotkTrace_File::GenerateFilename(const Standard_CString aSeed,const OSD_Directory& aDirectory) 00157 { 00158 OSD_Directory theDir = aDirectory; 00159 if ( theDir.Exists() ) 00160 { 00161 OSD_Path theDirPath; 00162 theDir.Path(theDirPath); 00163 TCollection_AsciiString theFilename(aSeed); 00164 theFilename += TCollection_AsciiString("_Trace_"); 00165 OSD_Process theProcess; 00166 theFilename += theProcess.UserName(); 00167 theFilename += TCollection_AsciiString("_") + exotkUtils::CurrentDateToAsciiString(exotkUtils_dfFile); 00168 theDirPath.SetName(theFilename); 00169 theDirPath.SetExtension(".log"); 00170 myFilename = theDirPath; 00171 } 00172 }
1.2.12 written by Dimitri van Heesch,
© 1997-2001