std_db_content.hpp

См. документацию.
00001 /*
00002 
00003 Copyright (c) 2002-2005, Yauheni Akhotnikau
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009 - Redistributions of source code must retain the above copyright notice, this
00010 list of conditions and the following disclaimer.
00011 
00012 - Redistributions in binary form must reproduce the above copyright notice, this
00013 list of conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.
00015 
00016 - The name of the author may not be used to endorse or promote products derived
00017 from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028 OF SUCH DAMAGE.
00029 
00030 */
00031 
00032 /*
00033   ObjESSty-1
00034 */
00035 
00041 #if !defined( _OESS_1__DB__IMPL__DB_CONTENT__STD_DB_CONTENT_HPP_ )
00042 #define _OESS_1__DB__IMPL__DB_CONTENT__STD_DB_CONTENT_HPP_
00043 
00044 #include <auto_ptr_3/h/obj_ptr.hpp>
00045 
00046 #include <oess_1/db/storage/h/stream_storage.hpp>
00047 
00048 #include <oess_1/db/impl/db_content/h/db_content.hpp>
00049 #include <oess_1/db/impl/db_content/h/client_map.hpp>
00050 
00051 namespace oess_1
00052 {
00053 
00054 namespace db
00055 {
00056 
00057 namespace impl
00058 {
00059 
00060 namespace db_content
00061 {
00062 
00063 //
00064 // trans_owner_info_t
00065 //
00066 
00071 class trans_owner_info_t
00072 {
00073 public :
00074   trans_owner_info_t();
00075   ~trans_owner_info_t();
00076 
00078 
00079   void
00080   begin(
00081     const std::string & client_id );
00082 
00084   void
00085   commit();
00086 
00088   void
00089   rollback();
00090 
00093 
00095   void
00096   must_be_owner(
00097     const std::string & client_id ) const;
00098 
00100 
00102   bool
00103   is_owner(
00104     const std::string & client_id ) const;
00105 
00107   inline bool
00108   is_started() const
00109   {
00110     return !m_owner.empty();
00111   }
00112 
00114   inline void
00115   cleanup()
00116   {
00117     m_owner = "";
00118   }
00119 
00120 private :
00122 
00124   std::string m_owner;
00125 };
00126 
00127 //
00128 // std_db_content_t
00129 //
00130 
00134 class std_db_content_t :
00135   public db_content_t
00136 {
00137   public :
00138     std_db_content_t();
00139     virtual ~std_db_content_t();
00140 
00143     virtual void
00144     open(
00145       const std::string & name,
00146       const oess_1::db::storage::config_t & config,
00147       bool is_read_only,
00148       bool is_auto_repair_enabled );
00149 
00150     virtual void
00151     client_attach(
00152       const std::string & client_id );
00153 
00154     virtual void
00155     client_detach(
00156       const std::string & client_id );
00157 
00158     virtual oess_1::uint_t
00159     client_count() const;
00160 
00161     virtual void
00162     slice_create(
00163       const std::string & client_id,
00164       const std::string & name );
00165 
00166     virtual void
00167     slice_destroy(
00168       const std::string & client_id,
00169       const std::string & name );
00170 
00171     virtual bool
00172     slice_is_exists(
00173       const std::string & client_id,
00174       const std::string & name );
00175 
00176     virtual std::set< std::string >
00177     slice_names(
00178       const std::string & client_id );
00179 
00180     virtual oess_1::ent_id_t
00181     ent_create(
00182       const std::string & client_id,
00183       const std::string & slice_name,
00184       oess_1::io::istream_t & ent_value,
00185       oess_1::uint_t ent_size );
00186 
00187     virtual void
00188     ent_destroy(
00189       const std::string & client_id,
00190       const oess_1::ent_id_t & ent_id );
00191 
00192     virtual void
00193     ent_destroy_all(
00194       const std::string & client_id,
00195       const std::string & slice_name );
00196 
00197     virtual void
00198     ent_load(
00199       const std::string & client_id,
00200       const oess_1::ent_id_t & ent_id,
00201       oess_1::io::ostream_t & ent_value );
00202 
00203     virtual void
00204     ent_update(
00205       const std::string & client_id,
00206       const oess_1::ent_id_t & ent_id,
00207       oess_1::io::istream_t & ent_value,
00208       oess_1::uint_t ent_size );
00209 
00210     virtual oess_1::ent_id_t
00211     ent_find_next(
00212       const std::string & client_id,
00213       const std::string & slice_name,
00214       const oess_1::ent_id_t & ent_id );
00215 
00216     virtual void
00217     transaction_begin(
00218       const std::string & client_id );
00219 
00220     virtual void
00221     transaction_commit(
00222       const std::string & client_id );
00223 
00224     virtual void
00225     transaction_rollback(
00226       const std::string & client_id );
00228 
00229   private :
00231 
00234     auto_ptr_3::obj_ptr_t< oess_1::db::storage::stream_storage_t >
00235         m_storage;
00236 
00238     enum
00239     {
00241       connection_only = 0,
00243       must_be_transaction_owner = 1
00244     };
00245 
00247     bool  m_is_open;
00248 
00250     std::auto_ptr< client_map_t > m_client_map_ptr;
00251 
00253 
00254     trans_owner_info_t  m_transaction_owner;
00255 
00257 
00261     unsigned int  m_trans_deep;
00262 
00264 
00267     void
00268     sys_trans_start();
00269 
00271 
00277     void
00278     sys_trans_finish();
00279 
00281 
00292     void
00293     careful_sys_trans_rollback();
00294 
00296     void
00297     cleanup();
00298 
00300     void
00301     must_be_open() const;
00302 
00305 
00315     void
00316     check_for_client(
00318       const std::string & client_id,
00321       unsigned int actions ) const;
00322 
00324 
00331     oess_1::db::storage::entity_stream_t &
00332     slice_for_entity_search(
00333       const std::string & slice_name,
00334       const oess_1::ent_id_t & ent_id );
00335 };
00336 
00337 } /* namespace db_content */
00338 
00339 } /* namespace impl */
00340 
00341 } /* namespace db */
00342 
00343 } /* namespace oess_1 */
00344 
00345 #endif

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:35 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz