/usr/include/LWH/TreeFactory.h is in librivet-dev 1.8.3-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | // -*- C++ -*-
#ifndef LWH_TreeFactory_H
#define LWH_TreeFactory_H
//
// This is the declaration of the TreeFactory class.
//
#include "AITreeFactory.h"
#include <string>
#include <stdexcept>
#include "Tree.h"
namespace LWH {
using namespace AIDA;
/**
* The creator of trees.
*/
class TreeFactory: public ITreeFactory {
public:
/// Destructor.
virtual ~TreeFactory() {
clear();
}
/**
* Creates a new tree that is not associated with a store.
*/
ITree * create() {
Tree * tree = new Tree;
trees.insert(tree);
return tree;
}
/**
* Creates a new Tree and associates it with a store.
* The store is assumed to be write-only.
* The store will be created.
* @param storeName The name of the store, if empty (""), the tree is
* created in memory and therefore will not be associated
* with a file.
*/
Tree * createTree(const std::string & storeName) {
return new Tree(storeName);
}
/**
* Creates a new Tree and associates it with a store.
* The store is assumed to be write-only.
* The store will be created.
* @param storeName The name of the store, if empty (""), the tree is
* created in memory and therefore will not be associated
* with a file.
* @param storeType must be "xml".
* @param readOnly must be false since we cannot read in trees.
* @param createNew must be true indicating that the file will be created
*/
ITree * create(const std::string & storeName,
const std::string & storeType = "",
bool readOnly = false, bool createNew = false,
const std::string & = "") {
#ifndef HAVE_ROOT
if ( storeType != "xml" && storeType != "" && storeType != "flat" )
throw std::runtime_error("Can only store trees in flat and xml format.");
#endif
#ifdef HAVE_ROOT
if ( storeType != "xml" && storeType != "" && storeType != "flat" && storeType !="root")
throw std::runtime_error("Can only store trees in flat, xml or root format.");
#endif
if ( readOnly || !createNew )
throw std::runtime_error("Cannot read in trees.");
fileformat fchoice=xml;
if (storeType=="flat") fchoice=flat;
#ifdef HAVE_ROOT
else if (storeType=="root") fchoice=root;
#endif
//return new Tree(storeName, storeType != "flat");
return new Tree(storeName, fchoice);
}
private:
/** Delete all trees. */
void clear() {
for ( std::set<Tree *>::iterator it = trees.begin();
it != trees.end(); ++it ) delete *it;
trees.clear();
}
/** The created trees. */
std::set<Tree *> trees;
};
}
#endif /* LWH_TreeFactory_H */
|