00001
00002 #ifndef __MINIXML_STORE_H__
00003 #define __MINIXML_STORE_H__
00004
00005 #include "store.h"
00006 #include <miniXml/miniXml.h>
00007
00008 namespace Spm
00009 {
00010 namespace Core
00011 {
00012 class MiniXmlStore : public Store
00013 {
00014 private:
00015 typedef struct
00016 {
00017 std::string elementSource;
00018 std::string branchSource;
00019 std::string elementLinked;
00020 std::string branchLinked;
00021 }link_st;
00022
00023 friend class PackageSystem;
00024 miniXml::Document elementDoc;
00025 miniXml::Document categoryDoc;
00026
00027 void readCategoryList (PackageSystem * pSystem);
00028 void readElementList (PackageSystem * pSystem);
00029
00030 void writeCategoryList (PackageSystem * pSystem);
00031 void writeElementList (PackageSystem * pSystem);
00032
00033 void _add (Element * element);
00034 void _add (Branch * branch);
00035 void _add (Category * category);
00036 void _modify (Element * element,
00037 miniXml::Element * xmlElement);
00038 void _modify (Branch * branch,
00039 miniXml::Element * xmlElement);
00040 void _modify (Category * category,
00041 miniXml::Element * xmlElement);
00042
00043 Category * categoryFromXml (const miniXml::Element * element,
00044 const std::string & user);
00045 Element * elementFromXml (const miniXml::Element * element,
00046 PackageSystem * pSystem,
00047 std::list<link_st> & links);
00048 miniXml::Element * categoryToXml (const Category * category);
00049 miniXml::Element * elementToXml (const Element * _element);
00050 Branch * branchFromXml (const miniXml::Element * element,
00051 const Element * branchElement);
00052 miniXml::Element * branchToXml (const Branch * branch);
00053 void linkElement(std::list<link_st> & linkToDo,
00054 PackageSystem * pSystem);
00055 miniXml::Element * getBranchXml (const Branch * branch);
00056 miniXml::Element * getElementXml (const Element * element);
00057 miniXml::Element * getCategoryXml (const Category * category);
00058 public:
00059 void store (PackageSystem * pSystem);
00060 void store (Element * element);
00061 void store (Branch * branch);
00062 void store (Category * category);
00063 void remove (Element * element);
00064 void remove (Branch * branch);
00065 void remove (Category * category);
00066 void init (PackageSystem * pSystem);
00067 };
00068 }
00069 }
00070
00071 #endif