NIREP
|
00001 /*============================================================================ 00002 00003 Program: Non Rigid Image Registration Evalution Project 00004 Module: $RCSfile: NIREPResourceDatabase.h,v $ 00005 Language: C++ 00006 Date: $Date: 2010/02/22 19:56:33 $ 00007 Version: $Revision: 1.6 $ 00008 00009 Author: James Harris 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notices for more information. 00014 00015 ============================================================================*/ 00018 #include "vtkNIREPXMLParser.h" 00019 #include "vtkOutputWindow.h" 00020 #include "vtkObjectFactory.h" 00021 00022 //#include <stdio.h> 00023 //#include <stdlib.h> 00024 #include <iostream> 00025 #include <vector> 00026 #include <string> 00027 #include <map> 00028 00029 using namespace std; 00030 00031 #pragma once 00032 00033 class Dataset 00034 { 00035 public: 00036 std::vector< std::map< std::string, std::string> > entry; 00037 std::map<std::string, std::string> attribute; 00038 }; 00039 00040 class Resource 00041 { 00042 public: 00043 std::vector<Dataset> dataset; 00044 std::map<std::string, std::string> attribute; 00045 std::string id; 00046 std::map<std::string, std::string>::iterator getAttribute() 00047 { 00048 return this->attribute.begin(); 00049 }; 00050 }; 00051 00052 class NIREPResourceDatabase : public vtkNIREPXMLParser 00053 { 00054 public: 00055 static NIREPResourceDatabase* New(); 00056 vtkTypeMacro(NIREPResourceDatabase, vtkNIREPXMLParser); 00057 void PrintSelf(ostream& os, vtkIndent indent) {}; 00058 00059 std::string QueryFilename(std::string str); 00060 std::map<std::string, std::string> QueryList(std::string str); 00061 std::vector<std::string> GetTags(); 00062 std::vector<std::string> GetTypeList(); 00063 std::vector<Resource> GetResource() { return resource; }; 00064 protected: 00065 NIREPResourceDatabase(); 00066 ~NIREPResourceDatabase(); 00068 virtual void StartElement(const char* name, const char** atts); 00070 virtual void EndElement(const char* name); 00072 virtual void CharacterDataHandler(const char* data=NULL, int length=0); 00073 public: 00074 std::string current; 00075 std::string previous; 00076 std::vector<std::string> history; 00077 short cron; 00078 00079 std::vector<std::string> typelist; 00080 std::vector<std::string> tag; 00081 std::vector<Resource> resource; 00082 00083 bool IsDefinedType(std::string type); 00084 00085 enum { 00086 LEFT = 0, 00087 RIGHT 00088 }; 00089 std::string ParseThisString(std::string str, const char* delimiter, short partition = LEFT); 00090 Resource& SearchResource(std::string str, bool& empty); 00091 Dataset& SearchDataset(std::string str, Resource& resource, bool& empty); 00092 std::map<std::string, std::string>& SearchEntry(std::string str, Dataset& dataset, bool& empty); 00093 00094 };