00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef DBASQLOSTREAM_H
00010 #define DBASQLOSTREAM_H
00011
00012 #include "dba/ostream.h"
00013 #include "dba/sql.h"
00014
00015 namespace dba {
00016
00017 class SQLIdFetcher;
00018
00023 class dbaDLLEXPORT SQLOStream : public OStream {
00024 friend class SQLArchive;
00025 friend class Transaction;
00026 public:
00030 SQLOStream(const SQLOStream& pStream);
00034 SQLOStream& operator=(const SQLOStream&);
00039 virtual void open(const char* pMainTable = NULL);
00040 virtual void begin();
00041 virtual void commit();
00042 virtual void rollback();
00043 virtual bool isOpen() const;
00044 virtual void close();
00045 virtual void destroy();
00050 int sendUpdate(const SQL& pQuery);
00055 const ConvSpec& getConversionSpecs() const;
00056 virtual ~SQLOStream();
00057 protected:
00059 DbConnection* mConn;
00061 SQLIdFetcher* mFetcher;
00063 FilterMapper* mFilterMapper;
00064 private:
00065 virtual void assignId(Storeable* pObject) throw (Exception);
00066 SQLOStream(DbConnection* pConn, SQLIdFetcher* pFetcher, FilterMapper* pMapper);
00067 std::string createInsert(int id,const Storeable& pObject,mt_class* pTable);
00068 std::string createUpdate(const Storeable& pObject,mt_class* pTable);
00069 std::string applyFilter(StoreableFilterBase& pFilter, Database::StoreType pType);
00070
00071 virtual std::vector<id> loadRefData(const char* pTable, const char* pFkName, id pCollId, id pId);
00072 virtual bool deleteRefData(const std::vector<id>& pIds, const char* pTableName);
00073 virtual bool isCollectionFilterSupported() const { return true; };
00074 virtual bool erase(Storeable* pObject);
00075 virtual bool update(Storeable* pObject);
00076 virtual bool store(Storeable* pObject);
00077
00078 std::string mCurrentTable;
00079 };
00080
00081 };
00082
00083
00084 #endif