14 #include <itksys/SystemTools.hxx> 21 struct EndoDebugFromXmlFileData
23 const std::string* m_FileName;
26 EndoDebug* m_EndoDebug;
27 long int m_FileModifiedTime;
30 EndoDebugFromXmlFile::EndoDebugFromXmlFile(
31 const std::string* _FileName,
EndoDebug* _EndoDebug )
32 : d( new EndoDebugFromXmlFileData )
34 d->m_FileName = _FileName;
35 d->m_EndoDebug = _EndoDebug;
36 d->m_FileModifiedTime = 0;
46 found = str.find_first_of(separator);
47 while(found != string::npos){
49 results->insert(str.substr(0,found));
51 str = str.substr(found+1);
52 found = str.find_first_of(separator);
60 # pragma warning(push) 61 # pragma warning(disable:4390) 68 std::string _FileName = *d->m_FileName;
69 if( !itksys::SystemTools::FileExists( _FileName.c_str() ) )
71 endodebug(_FileName <<
" does not exist");
75 long int _FileModifiedTime
76 = itksys::SystemTools::ModifiedTime( _FileName.c_str() );
78 if( d->m_FileModifiedTime >= _FileModifiedTime )
80 endodebug(
"File not changed. No Update necessary.");
86 TiXmlDocument doc( _FileName );
88 TiXmlHandle docHandle( &doc );
89 TiXmlElement* elem = docHandle.FirstChildElement().FirstChildElement(
"EndoDebug" ).ToElement();
97 int _DebugEnabled = d->m_EndoDebug->GetDebugEnabled();
98 if( elem->QueryIntAttribute(
"DebugEnabled",&_DebugEnabled) != TIXML_SUCCESS )
100 endodebug(
"DebugEnabled attribute not found");
103 int _ShowImagesInDebug = d->m_EndoDebug->GetShowImagesInDebug();
104 if( elem->QueryIntAttribute(
"ShowImagesInDebug",&_ShowImagesInDebug) != TIXML_SUCCESS )
106 endodebug(
"ShowImagesInDebug attribute not found");
109 int _ShowImagesTimeOut =
static_cast<int>(d->m_EndoDebug->GetShowImagesTimeOut());
110 if( elem->QueryIntAttribute(
"ShowImagesTimeOut",&_ShowImagesTimeOut) != TIXML_SUCCESS )
112 endodebug(
"ShowImagesTimeOut attribute not found");
115 std::string _DebugImagesOutputDirectory = d->m_EndoDebug->GetDebugImagesOutputDirectory();
116 if( elem->QueryStringAttribute(
"DebugImagesOutputDirectory",&_DebugImagesOutputDirectory) != TIXML_SUCCESS )
118 endodebug(
"DebugImagesOutputDirectory attribute not found");
121 std::set<std::string> _FilesToDebug;
122 std::string _FilesToDebugString;
123 if( elem->QueryStringAttribute(
"FilesToDebug",&_FilesToDebugString) != TIXML_SUCCESS )
125 endodebug(
"FilesToDebug attribute not found");
132 std::set<std::string> _SymbolsToDebug;
133 std::string _SymbolsToDebugString;
134 if( elem->QueryStringAttribute(
"SymbolsToDebug",&_SymbolsToDebugString) != TIXML_SUCCESS )
136 endodebug(
"SymbolsToDebug attribute not found");
140 StringExplode( _SymbolsToDebugString,
";", &_SymbolsToDebug );
152 d->m_FileModifiedTime = _FileModifiedTime;
156 # pragma warning(pop) virtual ~EndoDebugFromXmlFile()
static EndoDebug & GetInstance()
void SetSymbolsToDebug(const std::set< std::string > &symbolsToDebug)
void SetShowImagesInDebug(bool _ShowImagesInDebug)
DataCollection - Class to facilitate loading/accessing structured data.
void SetDebugEnabled(bool _DebugEnabled)
void SetShowImagesTimeOut(vcl_size_t _ShowImagesTimeOut)
void StringExplode(string str, string separator, set< string > *results)
void SetFilesToDebug(const std::set< std::string > &filesToDebug)
void SetDebugImagesOutputDirectory(const std::string &_DebugImagesOutputDirectory)
#define endodebugvar(var)