13 #include <itksys/SystemTools.hxx> 14 #include <itkFastMutexLock.h> 15 #include <itkMutexLockHolder.h> 25 : m_DebugEnabled(false)
26 , m_ShowImagesInDebug(false)
27 , m_ShowImagesTimeOut(false)
28 , m_Mutex(
itk::FastMutexLock::New())
29 , m_DebugImagesOutputDirectory(
"")
34 std::set<std::string> m_FilesToDebug;
35 std::set<std::string> m_SymbolsToDebug;
37 bool m_ShowImagesInDebug;
38 size_t m_ShowImagesTimeOut;
39 std::ofstream m_Stream;
40 itk::FastMutexLock::Pointer m_Mutex;
41 std::string m_DebugImagesOutputDirectory;
45 : d ( new EndoDebugData )
52 if(d->m_Stream.is_open())
70 while( filename.empty() || itksys::SystemTools::FileExists( (dir+
"/"+filename).c_str() ) )
74 filename = prefix + s.str() +
"." + ext;
78 filename = dir+
"/"+filename;
85 return itksys::SystemTools::GetFilenameWithoutExtension( s );
92 std::pair<std::set<std::string>::iterator,
bool> res = d->m_FilesToDebug.insert( s );
101 d->m_FilesToDebug = filesToDebug;
109 return d->m_FilesToDebug;
117 std::pair<std::set<std::string>::iterator,
bool> res = d->m_SymbolsToDebug.insert( symbolToDebug );
126 d->m_SymbolsToDebug = symbolsToDebug;
134 return d->m_SymbolsToDebug;
142 return d->m_SymbolsToDebug.find(s)
143 != d->m_SymbolsToDebug.end();
153 return d->m_FilesToDebug.find(filename)
154 != d->m_FilesToDebug.end();
163 bool debugEnabled =
false;
164 size_t filesSize = 0;
165 size_t symbolsSize = 0;
166 bool symbolFound =
false;
169 debugEnabled = d->m_DebugEnabled;
170 filesSize = d->m_FilesToDebug.size();
171 symbolsSize = d->m_SymbolsToDebug.size();
172 symbolFound = d->m_SymbolsToDebug.find(symbol) != d->m_SymbolsToDebug.end();
183 if( symbolsSize > 0 )
190 if( !symbol.empty() )
203 d->m_DebugEnabled = _DebugEnabled;
211 d->m_DebugImagesOutputDirectory = _DebugImagesOutputDirectory;
220 return d->m_DebugEnabled;
228 d->m_ShowImagesInDebug = _ShowImagesInDebug;
236 return d->m_ShowImagesInDebug;
244 d->m_ShowImagesTimeOut = _ShowImagesTimeOut;
252 return d->m_DebugImagesOutputDirectory;
260 return d->m_ShowImagesTimeOut;
268 d->m_Stream.open ( file.c_str(), std::ios::out | std::ios::app);
276 if(d->m_Stream.is_open())
282 newtime = localtime(&aclock);
283 timestr = asctime(newtime);
285 d->m_Stream << timestr <<
", " << message;
288 std::cout << message << std::flush;
bool AddSymbolToDebug(const std::string &symbolToDebug)
static EndoDebug & GetInstance()
void SetSymbolsToDebug(const std::set< std::string > &symbolsToDebug)
void SetShowImagesInDebug(bool _ShowImagesInDebug)
DataCollection - Class to facilitate loading/accessing structured data.
bool DebugSymbol(const std::string &symbolToDebug)
std::string GetFilenameWithoutExtension(const std::string &s)
void SetDebugEnabled(bool _DebugEnabled)
std::string GetDebugImagesOutputDirectory() const
void SetShowImagesTimeOut(vcl_size_t _ShowImagesTimeOut)
bool AddFileToDebug(const std::string &fileToDebug)
void SetLogFile(const std::string &file)
void ShowMessage(const std::string &message)
std::set< std::string > GetFilesToDebug()
bool GetShowImagesInDebug()
std::set< std::string > GetSymbolsToDebug()
void SetFilesToDebug(const std::set< std::string > &filesToDebug)
void SetDebugImagesOutputDirectory(const std::string &_DebugImagesOutputDirectory)
bool Debug(const std::string &fileToDebug, const std::string &symbol="")
vcl_size_t GetShowImagesTimeOut()
static std::string GetUniqueFileName(const std::string &dir, const std::string &ext="jpg", const std::string &prefix="")
bool DebugFile(const std::string &fileToDebug)