00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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
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
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 }
00338
00339 }
00340
00341 }
00342
00343 }
00344
00345 #endif