00001 #ifndef _QUERY_INTERFACE_H
00002 #define _QUERY_INTERFACE_H
00003
00004 #include "BinaryLogObject.h"
00005 #include "mvector.h"
00006
00007 class QueryInterface;
00008
00009 class OutputIterator {
00010 public:
00011 virtual std::string getNext() = 0;
00012 virtual ~OutputIterator() { }
00013 };
00014
00015 typedef OutputIterator* (*QueryHandler)(QueryInterface& q, const std::string& args);
00016
00017 class Mdb;
00018
00019 class BinaryLogIter {
00020 friend class Mdb;
00021
00022 protected:
00023 int index;
00024 mace::vector<uint64_t>* indexList;
00025 mace::BinaryLogObject* obj;
00026 std::string logType;
00027 std::ifstream* in;
00028
00029
00030 BinaryLogIter();
00031 BinaryLogIter(const std::string& type, std::ifstream* ifs);
00032
00033 public:
00034 virtual ~BinaryLogIter() {}
00035 virtual mace::BinaryLogObject* getNext();
00036 mace::BinaryLogObject* getObj() {
00037 return obj;
00038 }
00039 virtual void reset();
00040 };
00041
00042 class QueryInterface {
00043
00044 public:
00045 virtual ~QueryInterface() { }
00046 virtual void registerQuery(const std::string& name,
00047 const std::string& params,
00048 const std::string& queryBody,
00049 QueryHandler callback) = 0;
00050 virtual BinaryLogIter iterator(const std::string& logType) = 0;
00051 };
00052
00053 #endif // _QUERY_INTERFACE_H