// file : odb/pgsql/statement-cache.hxx // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_PGSQL_STATEMENT_CACHE_HXX #define ODB_PGSQL_STATEMENT_CACHE_HXX #include #include #include #include #include #include #include #include #include #include #include namespace odb { namespace pgsql { class connection; class LIBODB_PGSQL_EXPORT statement_cache { public: statement_cache (connection& conn) : conn_ (conn) { } template typename object_statements_selector::type& find_object () { typedef typename object_statements_selector::type object_statements; map::iterator i (map_.find (&typeid (T))); if (i != map_.end ()) return static_cast (*i->second); details::shared_ptr p ( new (details::shared) object_statements (conn_)); map_.insert (map::value_type (&typeid (T), p)); return *p; } template view_statements& find_view () { map::iterator i (map_.find (&typeid (T))); if (i != map_.end ()) return static_cast&> (*i->second); details::shared_ptr > p ( new (details::shared) view_statements (conn_)); map_.insert (map::value_type (&typeid (T), p)); return *p; } private: typedef std::map, details::type_info_comparator> map; connection& conn_; map map_; }; } } #include #endif // ODB_PGSQL_STATEMENT_CACHE_HXX