File indexing completed on 2026-08-06 09:38:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LWH_TreeFactory_H
0010 #define LWH_TreeFactory_H
0011
0012
0013
0014
0015 #include "AITreeFactory.h"
0016 #include <string>
0017 #include <stdexcept>
0018 #include "Tree.h"
0019
0020 namespace LWH {
0021
0022 using namespace AIDA;
0023
0024
0025
0026
0027 class TreeFactory: public ITreeFactory {
0028
0029 public:
0030
0031
0032 virtual ~TreeFactory() {
0033 clear();
0034 }
0035
0036
0037
0038
0039 ITree * create() {
0040 Tree * tree = new Tree;
0041 trees.insert(tree);
0042 return tree;
0043 }
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 Tree * createTree(const std::string & storeName) {
0054 return new Tree(storeName);
0055 }
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 ITree * create(const std::string & storeName,
0069 const std::string & storeType = "",
0070 bool readOnly = false, bool createNew = false,
0071 const std::string & = "") {
0072 if ( storeType != "xml" && storeType != "" && storeType != "flat" )
0073 throw std::runtime_error("Can only store trees in xml or flat format.");
0074 if ( readOnly || !createNew )
0075 throw std::runtime_error("Cannot read in trees.");
0076 return new Tree(storeName, storeType != "flat");
0077 }
0078
0079 private:
0080
0081
0082 void clear() {
0083 for ( std::set<Tree *>::iterator it = trees.begin();
0084 it != trees.end(); ++it ) delete *it;
0085 trees.clear();
0086 }
0087
0088
0089 std::set<Tree *> trees;
0090
0091 };
0092
0093 }
0094
0095 #endif