18 #include <itksys/SystemTools.hxx>
25 struct EndoDebugFromXmlFileData
27 const std::string* m_FileName;
30 EndoDebug* m_EndoDebug;
31 long int m_FileModifiedTime;
34 EndoDebugFromXmlFile::EndoDebugFromXmlFile(
35 const std::string* _FileName,
EndoDebug* _EndoDebug )
36 : d( new EndoDebugFromXmlFileData )
38 d->m_FileName = _FileName;
39 d->m_EndoDebug = _EndoDebug;
40 d->m_FileModifiedTime = 0;
50 found = str.find_first_of(separator);
51 while(found != string::npos){
53 results->insert(str.substr(0,found));
55 str = str.substr(found+1);
56 found = str.find_first_of(separator);
64 # pragma warning(push)
65 # pragma warning(disable:4390)
72 std::string _FileName = *d->m_FileName;
73 if( !itksys::SystemTools::FileExists( _FileName.c_str() ) )
75 endodebug(_FileName <<
" does not exist");
79 long int _FileModifiedTime
80 = itksys::SystemTools::ModifiedTime( _FileName.c_str() );
82 if( d->m_FileModifiedTime >= _FileModifiedTime )
84 endodebug(
"File not changed. No Update necessary.");
90 TiXmlDocument doc( _FileName );
92 TiXmlHandle docHandle( &doc );
93 TiXmlElement* elem = docHandle.FirstChildElement().FirstChildElement(
"EndoDebug" ).ToElement();
101 int _DebugEnabled = d->m_EndoDebug->GetDebugEnabled();
102 if( elem->QueryIntAttribute(
"DebugEnabled",&_DebugEnabled) != TIXML_SUCCESS )
103 endodebug(
"DebugEnabled attribute not found");
105 int _ShowImagesInDebug = d->m_EndoDebug->GetShowImagesInDebug();
106 if( elem->QueryIntAttribute(
"ShowImagesInDebug",&_ShowImagesInDebug) != TIXML_SUCCESS )
107 endodebug(
"ShowImagesInDebug attribute not found");
109 int _ShowImagesTimeOut =
static_cast<int>(d->m_EndoDebug->GetShowImagesTimeOut());
110 if( elem->QueryIntAttribute(
"ShowImagesTimeOut",&_ShowImagesTimeOut) != TIXML_SUCCESS )
111 endodebug(
"ShowImagesTimeOut attribute not found");
113 std::string _DebugImagesOutputDirectory = d->m_EndoDebug->GetDebugImagesOutputDirectory();
114 if( elem->QueryStringAttribute(
"DebugImagesOutputDirectory",&_DebugImagesOutputDirectory) != TIXML_SUCCESS )
115 endodebug(
"DebugImagesOutputDirectory attribute not found");
117 std::set<std::string> _FilesToDebug;
118 std::string _FilesToDebugString;
119 if( elem->QueryStringAttribute(
"FilesToDebug",&_FilesToDebugString) != TIXML_SUCCESS )
121 endodebug(
"FilesToDebug attribute not found");
128 std::set<std::string> _SymbolsToDebug;
129 std::string _SymbolsToDebugString;
130 if( elem->QueryStringAttribute(
"SymbolsToDebug",&_SymbolsToDebugString) != TIXML_SUCCESS )
132 endodebug(
"SymbolsToDebug attribute not found");
136 StringExplode( _SymbolsToDebugString,
";", &_SymbolsToDebug );
148 d->m_FileModifiedTime = _FileModifiedTime;
152 # 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)