Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

BankStream_AMOS.hh

Go to the documentation of this file.
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 #ifndef __BankStream_AMOS_HH 00011 #define __BankStream_AMOS_HH 1 00012 00013 #include "Bank_AMOS.hh" 00014 #include <vector> 00015 00016 00017 00018 00019 namespace AMOS { 00020 00021 //================================================ BankStream_t ================ 00033 //============================================================================== 00034 class BankStream_t : private Bank_t 00035 { 00036 00037 protected: 00038 00039 static const Size_t DEFAULT_BUFFER_SIZE; 00041 00042 static const Size_t MAX_OPEN_PARTITIONS; 00044 00045 00046 //--------------------------------------------------- init ------------------- 00047 void init ( ) 00048 { 00049 eof_m = false; 00050 curr_bid_m = 1; 00051 triples_m . resize (1); 00052 } 00053 00054 00055 //--------------------------------------------------- inrange ---------------- 00056 bool inrange ( ) 00057 { 00058 return ( curr_bid_m > 0 && curr_bid_m <= last_bid_m ); 00059 } 00060 00061 00062 bool eof_m; 00063 ID_t curr_bid_m; 00064 std::vector<const IDMap_t::HashTriple_t *> triples_m; 00065 00066 00067 public: 00068 00069 enum bankseekdir 00070 { 00071 BEGIN, 00072 CURR, 00073 END, 00074 }; 00075 00076 00077 //--------------------------------------------------- BankStream_t ----------- 00093 BankStream_t (NCode_t type) 00094 : Bank_t (type) 00095 { 00096 init( ); 00097 triples_m [NULL_ID] = NULL; 00098 buffer_size_m = DEFAULT_BUFFER_SIZE; 00099 max_partitions_m = MAX_OPEN_PARTITIONS; 00100 } 00101 00102 00103 //--------------------------------------------------- ~BankStream_t ---------- 00104 ~BankStream_t ( ) 00105 { 00106 if ( is_open_m ) 00107 close( ); 00108 } 00109 00110 00111 //--------------------------------------------------- clear ------------------ 00112 void clear ( ) 00113 { 00114 Bank_t::clear( ); 00115 init( ); 00116 } 00117 00118 00119 //--------------------------------------------------- close ------------------ 00120 void close ( ) 00121 { 00122 Bank_t::close( ); 00123 init( ); 00124 } 00125 00126 00127 //--------------------------------------------------- create ----------------- 00128 void create (const std::string & dir, BankMode_t mode = B_READ | B_WRITE) 00129 { 00130 Bank_t::create (dir, mode); 00131 init( ); 00132 } 00133 00134 00135 //--------------------------------------------------- destroy ---------------- 00136 void destroy ( ) 00137 { 00138 Bank_t::destroy( ); 00139 init( ); 00140 } 00141 00142 00143 //--------------------------------------------------- empty ------------------ 00144 bool empty ( ) const { return Bank_t::empty( ); } 00145 00146 00147 //--------------------------------------------------- eof -------------------- 00157 bool eof ( ) const 00158 { 00159 return ( is_open_m ? eof_m : true ); 00160 } 00161 00162 00163 //--------------------------------------------------- exists ----------------- 00164 bool exists (const std::string & dir) { return Bank_t::exists(dir); } 00165 00166 00167 //--------------------------------------------------- existsEID -------------- 00168 bool existsEID (const std::string & eid) const 00169 { return Bank_t::existsEID(eid); } 00170 00171 00172 //--------------------------------------------------- existsIID -------------- 00173 bool existsIID (ID_t iid) const { return Bank_t::existsIID(iid); } 00174 00175 00176 //--------------------------------------------------- getIDMap --------------- 00177 const IDMap_t & getIDMap ( ) const { return Bank_t::getIDMap( ); } 00178 00179 00180 //--------------------------------------------------- getIDMapSize ----------- 00181 Size_t getIDMapSize ( ) const { return Bank_t::getIDMapSize( ); } 00182 00183 00184 //--------------------------------------------------- getMaxIID -------------- 00185 ID_t getMaxIID ( ) const { return Bank_t::getMaxIID( ); } 00186 00187 00188 //--------------------------------------------------- getSize ---------------- 00189 Size_t getSize ( ) const { return Bank_t::getSize( ); } 00190 00191 00192 //--------------------------------------------------- getStatus -------------- 00193 signed char getStatus ( ) const { return Bank_t::getStatus( ); } 00194 00195 00196 //--------------------------------------------------- getType ---------------- 00197 NCode_t getType ( ) const { return Bank_t::getType( ); } 00198 00199 00200 //--------------------------------------------------- ignore ----------------- 00211 BankStream_t & ignore (bankstreamoff n); 00212 00213 00214 //--------------------------------------------------- isOpen ----------------- 00215 bool isOpen ( ) const { return Bank_t::isOpen( ); } 00216 00217 00218 //--------------------------------------------------- lookupBID -------------- 00219 ID_t lookupBID (ID_t iid) const 00220 { return Bank_t::lookupBID(iid); } 00221 00222 00223 //--------------------------------------------------- lookupBID -------------- 00224 ID_t lookupBID (const std::string & eid) const 00225 { return Bank_t::lookupBID(eid); } 00226 00227 00228 //--------------------------------------------------- lookupEID -------------- 00229 const std::string & lookupEID (ID_t iid) const 00230 { return Bank_t::lookupEID(iid); } 00231 00232 00233 //--------------------------------------------------- lookupIID -------------- 00234 ID_t lookupIID (const std::string & eid) const 00235 { return Bank_t::lookupIID(eid); } 00236 00237 00238 //--------------------------------------------------- open ------------------- 00239 void open (const std::string & dir, BankMode_t mode = B_READ | B_WRITE); 00240 00241 00242 //--------------------------------------------------- seekg ------------------ 00257 BankStream_t & seekg (bankstreamoff off, bankseekdir dir) 00258 { 00259 if ( ! is_open_m || ! (mode_m & B_READ) ) 00260 AMOS_THROW_IO ("Cannot seekg: bank not open for reading"); 00261 00262 if ( dir == BEGIN ) curr_bid_m = 1; 00263 else if ( dir == END ) curr_bid_m = last_bid_m + 1; 00264 // else dir == CURR, do nothing 00265 ignore (off); 00266 return *this; 00267 } 00268 00269 00270 //--------------------------------------------------- seekg ------------------ 00282 BankStream_t & seekg (ID_t pos) 00283 { 00284 if ( ! is_open_m || ! (mode_m & B_READ) ) 00285 AMOS_THROW_IO ("Cannot seekg: bank not open for reading"); 00286 00287 curr_bid_m = pos; 00288 eof_m = !inrange( ); 00289 return *this; 00290 } 00291 00292 00293 //--------------------------------------------------- setStatus -------------- 00294 void setStatus (signed char status) { Bank_t::setStatus(status); } 00295 00296 00297 //--------------------------------------------------- tellg ------------------ 00307 ID_t tellg ( ) 00308 { 00309 return curr_bid_m; 00310 } 00311 00312 00313 //--------------------------------------------------- tellp ------------------ 00323 ID_t tellp ( ) 00324 { 00325 return last_bid_m + 1; 00326 } 00327 00328 00329 //--------------------------------------------------- operator bool( ) ------- 00334 operator bool ( ) const 00335 { 00336 return ! eof( ); 00337 } 00338 00339 00340 //--------------------------------------------------- operator! -------------- 00345 bool operator! ( ) const 00346 { 00347 return eof ( ); 00348 } 00349 00350 00351 //--------------------------------------------------- operator>> ------------- 00367 BankStream_t & operator>> (IBankable_t & obj); 00368 00369 00370 //--------------------------------------------------- operator<< ------------- 00379 BankStream_t & operator<< (IBankable_t & obj); 00380 }; 00381 00382 } // namespace AMOS 00383 00384 #endif // #ifndef __BankStream_AMOS_HH

Generated on Tue May 17 15:19:01 2005 for libAMOS by doxygen 1.3.8