00001
00002
00003 #ifndef DEV_W3_ORG__2001_BLINDFOLD_SRC_XSBPOOL_H
00004 #define DEV_W3_ORG__2001_BLINDFOLD_SRC_XSBPOOL_H
00005
00006 #include "config.h"
00007 #include "XSBAgent.h"
00008 #include "DeductivePool.h"
00009
00024 class XSBPool : public DeductivePool {
00025
00026 public:
00027
00028
00029 XSBPool(XSBAgent& agent, VariableScope* scope = 0);
00030 XSBPool(const XSBPool& other);
00031 const XSBPool& operator=(const XSBPool& other);
00032 bool operator==(const XSBPool& other) const;
00033 bool operator<(const XSBPool& other) const;
00034 size_t hash() const;
00035 friend std::ostream& operator<<(std::ostream& s, const XSBPool& me);
00036 std::ostream& print_to(std::ostream& stream) const;
00037 ~XSBPool();
00038
00039
00040
00041 void add(Triple t) { cache.add(t); maybeChanged = true;}
00042
00043 Triple fetch(Triple simplePattern, LoopState &loopState,
00044 unsigned long max_results=0) const {
00045 return cache.fetch(simplePattern, loopState, max_results);
00046 }
00047
00048 Query* query(const TripleSource &pattern) {
00049 return new XSBQuery(agent, *this, pattern);
00050 }
00051
00052 void remove(Triple t) {
00053 maybeChanged = true;
00054 cache.remove(t);
00055 }
00056
00057 void replace(Symbol old, Symbol replacement) {
00058 maybeChanged = true;
00059 cache.replace(old, replacement);
00060 }
00061
00062 VariableScope* getScope() const { return cache.getScope(); }
00063
00064
00065
00066
00067 void sync();
00068
00069 private:
00070 XSBAgent& agent;
00071 char* fileName;
00072 std::ostream* file;
00073 friend class XSBQuery;
00074 std::string predicate;
00075 InMemoryPool cache;
00076 bool maybeChanged;
00077 };
00078
00079 STANDARD_EXTERNAL(XSBPool)
00080
00081 #endif