00001
00002
00003
00004 #ifndef DEV_W3_ORG__2001_BLINDFOLD_SRC_INMEMORYPOOL_H
00005 #define DEV_W3_ORG__2001_BLINDFOLD_SRC_INMEMORYPOOL_H
00006 #include "config.h"
00007
00008
00009 #include "Pool.h"
00010 #include "SimpleVariableScope.h"
00011
00012 #include <hash_set>
00013
00034 class InMemoryPool : public Pool
00035 {
00036
00037 public:
00038
00039
00040
00041 InMemoryPool(VariableScope* scope = 0);
00042 InMemoryPool(const TripleSource& other);
00043
00044 const InMemoryPool& operator=(const InMemoryPool& other);
00045 bool operator==(const InMemoryPool& other) const;
00046 bool operator<(const InMemoryPool& other) const;
00047 size_t hash() const;
00048 friend std::ostream& operator<<(std::ostream& s, const InMemoryPool& me);
00049
00050 ~InMemoryPool();
00051
00052
00053 VariableScope* getScope() const {
00054 return scope;
00055 }
00056
00057
00058
00059 void add(Triple t);
00060
00061 Triple fetch(Triple simplePattern, LoopState &loopState, unsigned long max_results=0) const;
00062
00063 void remove(Triple);
00064
00065 void replace(Symbol old, Symbol replacement);
00066
00067 void addAll(const TripleSource& source);
00068
00069 int size() { return triples.size(); }
00070
00071 private:
00072
00073 std::hash_set<Triple> triples;
00074 VariableScope* scope;
00075 bool scopeOwner;
00076
00077 };
00078
00079
00080 STANDARD_EXTERNAL(InMemoryPool)
00081
00082 #endif