// file : odb/sqlite/connection.hxx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_SQLITE_CONNECTION_HXX #define ODB_SQLITE_CONNECTION_HXX #include #include #include // std::auto_ptr #include #include #include #include #include #include #include #include #include #include namespace odb { namespace sqlite { class statement; class statement_cache; class connection; typedef details::shared_ptr connection_ptr; class LIBODB_SQLITE_EXPORT connection: public odb::connection { public: typedef sqlite::statement_cache statement_cache_type; typedef sqlite::database database_type; virtual ~connection (); connection (database_type&, int extra_flags = 0); connection (database_type&, sqlite3* handle); database_type& database () { return db_; } public: virtual transaction_impl* begin (); transaction_impl* begin_immediate (); transaction_impl* begin_exclusive (); public: using odb::connection::execute; virtual unsigned long long execute (const char* statement, std::size_t length); public: sqlite3* handle () { return handle_; } statement_cache_type& statement_cache () { return *statement_cache_; } // Wait for the locks to be released via unlock notification. Can // be called after getting SQLITE_LOCKED_SHAREDCACHE. // void wait (); public: // Reset active and finalize uncached statements. // void clear (); private: connection (const connection&); connection& operator= (const connection&); private: void init (); private: database_type& db_; auto_handle handle_; // Keep statement_cache_ after handle_ so that it is destroyed before // the connection is closed. // std::auto_ptr statement_cache_; // Unlock notification machinery. // private: bool unlocked_; details::mutex unlock_mutex_; details::condition unlock_cond_; friend void connection_unlock_callback (void**, int); // Linked list of active and uncached statements currently associated // with this connection. // private: friend class statement; statement* statements_; }; } } #include #endif // ODB_SQLITE_CONNECTION_HXX