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 00036 #if !defined( _OESS_1__DB__STORAGE__IMPL__STREAM_STORAGE_DIR_HPP_ ) 00037 #define _OESS_1__DB__STORAGE__IMPL__STREAM_STORAGE_DIR_HPP_ 00038 00039 #include <map> 00040 #include <set> 00041 00042 #include <oess_1/defs/h/types.hpp> 00043 00044 #include <oess_1/stdsn/h/serializable.hpp> 00045 #include <oess_1/stdsn/h/macro.hpp> 00046 00047 #include <oess_1/db/storage/h/chain_id.hpp> 00048 00049 namespace oess_1 { 00050 00051 namespace db { 00052 00053 namespace storage { 00054 00055 namespace impl { 00056 00057 // 00058 // stream_storage_dir_item_t 00059 // 00060 00065 class stream_storage_dir_item_t 00066 : public oess_1::stdsn::serializable_t 00067 { 00068 typedef oess_1::stdsn::serializable_t base_type_t; 00069 OESS_SERIALIZER( stream_storage_dir_item_t ) 00070 00071 public : 00073 stream_storage_dir_item_t(); 00075 stream_storage_dir_item_t( 00077 const oess_1::uint_t & id, 00079 const chain_id_t & description_chain ); 00081 stream_storage_dir_item_t( 00082 const stream_storage_dir_item_t & o ); 00083 virtual ~stream_storage_dir_item_t(); 00084 00086 stream_storage_dir_item_t & 00087 operator=( 00088 const stream_storage_dir_item_t & o ); 00089 00091 oess_1::uint_t 00092 id() const; 00093 00095 const chain_id_t & 00096 description_chain() const; 00097 00098 private : 00100 oess_1::uint_t m_id; 00102 chain_id_t m_description_chain; 00103 }; 00104 00105 // 00106 // stream_storage_dir_t 00107 // 00108 00113 class stream_storage_dir_t 00114 : public oess_1::stdsn::serializable_t 00115 { 00116 typedef oess_1::stdsn::serializable_t base_type_t; 00117 OESS_SERIALIZER( stream_storage_dir_t ) 00118 00119 public : 00121 stream_storage_dir_t(); 00123 stream_storage_dir_t( 00124 const stream_storage_dir_t & o ); 00125 virtual ~stream_storage_dir_t(); 00126 00128 stream_storage_dir_t & 00129 operator=( 00130 const stream_storage_dir_t & o ); 00131 00133 oess_1::uint_t 00134 allocate_id(); 00135 00137 00141 void 00142 add( 00144 const std::string & name, 00146 const oess_1::uint_t & id, 00149 const chain_id_t & description_chain ); 00150 00152 00156 void 00157 destroy( 00159 const std::string & name ); 00160 00162 00166 oess_1::uint_t 00167 find_id( 00168 const std::string & name ) const; 00169 00171 00174 bool 00175 is_exists( 00176 const std::string & name ) const; 00177 00179 std::set< std::string > 00180 names() const; 00181 00184 00188 const stream_storage_dir_item_t & 00189 item( 00190 const std::string & name ) const; 00191 00192 private : 00194 typedef std::map< std::string, 00195 stream_storage_dir_item_t > 00196 dir_t; 00197 00199 dir_t m_dir; 00200 00202 00205 oess_1::uint_t m_id; 00206 00211 dir_t::iterator 00212 locate_existent_item( 00213 const std::string & name ); 00214 dir_t::const_iterator 00215 locate_existent_item( 00216 const std::string & name ) const; 00218 }; 00219 00220 } /* namespace impl */ 00221 00222 } /* namespace storage */ 00223 00224 } /* namespace db */ 00225 00226 } /* namespace oess_1 */ 00227 00228 #endif