47 const std::string SimpleBundleStorage::TAG =
"SimpleBundleStorage";
50 :
BundleStorage(maxsize), _datastore(*this, workdir, buffer_limit), _metastore(*this)
63 _pending_bundles.erase(hash);
84 _pending_bundles.erase(hash);
148 _metastore.
store(meta, bundle_size);
154 }
catch (
const std::exception&) {
215 }
catch (
const std::bad_cast&) { }
220 return "SimpleBundleStorage";
226 return _metastore.
empty();
238 return _metastore.
size();
254 size_t items_added = 0;
259 for (
MetaStorage::const_iterator iter = _metastore.begin(); (iter != _metastore.end()) && ((cb.limit() == 0) || (items_added < cb.limit())); ++iter)
266 if ( cb.shouldAdd(meta) )
296 pending_map::iterator it = _pending_bundles.find(hash);
298 if (_pending_bundles.end() != it)
313 }
catch (
const std::exception &ex) {
372 __store(ca_bundle, bundle_size);
375 __store(bundle, bundle_size);
407 std::auto_ptr<BundleContainer> bc(
new BundleContainer(bundle));
415 _pending_bundles[hash] = bundle;
423 _metastore.
store(meta, bundle_size);
427 _datastore.
store(hash, bc.get());
482 _datastore.remove(hash);
491 eventBundleRemoved(b);
494 SimpleBundleStorage::BundleContainer::BundleContainer(
const dtn::data::Bundle &b)
498 SimpleBundleStorage::BundleContainer::~BundleContainer()
501 std::string SimpleBundleStorage::BundleContainer::getKey()
const
506 std::ostream& SimpleBundleStorage::BundleContainer::serialize(std::ostream &stream)
515 s << _bundle; stream.flush();
520 std::stringstream ss; ss <<
"Output stream went bad [" << std::strerror(errno) <<
"]";
525 if (static_cast<std::streamoff>(size) > stream.tellp())
527 std::stringstream ss; ss <<
"Not all data were written [" << stream.tellp() <<
" of " << size <<
" bytes]";