00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <fstream>
00021 #include <boost/archive/xml_iarchive.hpp>
00022 #include <boost/archive/xml_oarchive.hpp>
00023 #include <boost/lexical_cast.hpp>
00024 #include <boost/algorithm/string/predicate.hpp>
00025 #include "weMemStorage.h"
00026 #include "weiBase.h"
00027
00028 WeMemStorage::WeMemStorage( void* handle ) :
00029 iweStorage(handle)
00030 {
00031
00032 }
00033 WeMemStorage::~WeMemStorage(void)
00034 {
00035 }
00036
00037 void* WeMemStorage::GetInterface( const string& ifName )
00038 {
00039 if (iequals(ifName, "iweStorage"))
00040 {
00041 return (void*)((iweStorage*)this);
00042 }
00043 if (iequals(ifName, "WeMemStorage"))
00044 {
00045 return (void*)((WeMemStorage*)this);
00046 }
00047 return iweStorage::GetInterface(ifName);
00048 }
00049
00050 const string WeMemStorage::GetDesc()
00051 {
00052 return "In-memory storage";
00053 }
00054
00055 const string WeMemStorage::GetID()
00056 {
00057 return "{D60CDD78-83FA-47f7-9CB4-D82B31419339}";
00058 }
00059
00060 const string WeMemStorage::InterfaceName()
00061 {
00062 return "WeMemStorage";
00063 }
00064
00065 WeStringList WeMemStorage::InterfaceList()
00066 {
00067 WeStringList retval = iweStorage::InterfaceList();
00068 retval.push_back("WeMemStorage");
00069 return retval;
00070 }
00071
00072 int WeMemStorage::Query( const string& objType, Operation op, const string& xmlData )
00073 {
00075 throw runtime_error("Not implemented");
00076 return -1;
00077 }
00078
00079 int WeMemStorage::Report( const string& repType, const string& xmlData, string& result )
00080 {
00082 throw runtime_error("Not implemented");
00083 return -1;
00084 }
00085
00086 int WeMemStorage::Delete( const string& objType, const string& xmlData )
00087 {
00089 throw runtime_error("Not implemented");
00090 return -1;
00091 }
00092
00093 void WeMemStorage::Save( const string& fileName )
00094 {
00095 try {
00096 std::ofstream ofs(fileName.c_str());
00097
00098 {
00099 boost::archive::xml_oarchive oa(ofs);
00100
00101 oa << BOOST_SERIALIZATION_NVP(tasks);
00102 oa << BOOST_SERIALIZATION_NVP(dicts);
00103 oa << BOOST_SERIALIZATION_NVP(auths);
00104 oa << BOOST_SERIALIZATION_NVP(sysopts);
00105
00106 }
00107 }
00108 catch(std::exception& e)
00109 {
00110 LOG4CXX_ERROR(WeLogger::GetLogger(), "WeMemStorage::Save error: " << e.what());
00111 }
00112 return;
00113 }
00114
00115 void WeMemStorage::Load( const string& fileName )
00116 {
00117 try{
00118 std::ofstream ofs(fileName.c_str());
00119
00120
00121 {
00122 boost::archive::xml_oarchive oa(ofs);
00123
00124 oa << BOOST_SERIALIZATION_NVP(tasks);
00125 oa << BOOST_SERIALIZATION_NVP(dicts);
00126 oa << BOOST_SERIALIZATION_NVP(auths);
00127 oa << BOOST_SERIALIZATION_NVP(sysopts);
00128
00129 }
00130 }
00131 catch(std::exception& e)
00132 {
00133 LOG4CXX_ERROR(WeLogger::GetLogger(), "WeMemStorage::Load error: " << e.what());
00134 }
00135 return;
00136 }