00001
00002
00003 #ifndef DEV_W3_ORG__2001_BLINDFOLD_SRC_XSBAGENT_H
00004 #define DEV_W3_ORG__2001_BLINDFOLD_SRC_XSBAGENT_H
00005
00006 #include "config.h"
00007 #include "Agent.h"
00008 #include "InMemoryPool.h"
00009 #include "ByteSink.h"
00010 #include "ByteFIFO.h"
00011 #include "XSBQuery.h"
00012 #include <list>
00013
00017 class XSBAgent : public Agent, public ByteSink {
00018
00019 public:
00020
00021
00022 XSBAgent();
00023 XSBAgent(const XSBAgent& other);
00024 const XSBAgent& operator=(const XSBAgent& other);
00025 bool operator==(const XSBAgent& other) const;
00026 bool operator<(const XSBAgent& other) const;
00027 size_t hash() const;
00028 friend std::ostream& operator<<(std::ostream& s, const XSBAgent& me);
00029 std::ostream& print_to(std::ostream& stream) const;
00030 ~XSBAgent();
00031
00032
00033 virtual void write(const void* byteBuffer, size_t numBytes);
00034 virtual QueryablePool* newQueryablePool(VariableScope* scope = 0);
00035
00036
00037 virtual void shutdown();
00038
00039 private:
00040
00041 friend class XSBQuery;
00042 friend class XSBPool;
00043 std::ostream* getFile(char** fileNameBuffer);
00044 std::string getNewPredicate();
00045 std::ostream* out;
00046
00047
00048 int predicateCounter;
00049
00050 ByteFIFO buffer;
00051
00052 XSBQuery* currentQuery;
00053 std::list<XSBPool*> pools;
00054
00055 void sync();
00056 bool waitingForAck;
00057
00058 };
00059
00060 STANDARD_EXTERNAL(XSBAgent)
00061
00062 #endif