31 bool MemoryBundleSet::__store_path_set__ =
false;
34 : _name(), _bf_size(bf_size), _bf(bf_size * 8), _listener(listener), _consistent(true)
39 : _name(name), _bf_size(bf_size), _bf(bf_size * 8), _listener(listener), _consistent(true)
45 }
catch (
const std::exception &ex) {
59 for (bundle_set::const_iterator iter = _bundles.begin(); iter != _bundles.end(); iter++)
76 if (set == NULL)
return;
79 for (bundle_set::const_iterator iter = set->_bundles.begin(); iter != set->_bundles.end(); iter++)
88 pair<bundle_set::iterator,bool> ret = _bundles.insert(bundle);
108 if (bundle.isIn(_bf)) {
111 if (!_consistent)
return true;
114 return (iter != _bundles.end());
122 return _bundles.size();
130 if (timestamp == 0)
return;
132 expire_set::iterator iter = _expire.begin();
134 while (iter != _expire.end())
141 if (_listener != NULL)
142 _listener->eventBundleExpired( b.
bundle );
145 _bundles.erase( b.
bundle );
148 _expire.erase( iter++ );
158 for (bundle_set::const_iterator iter = _bundles.begin(); iter != _bundles.end(); ++iter)
178 for (bundle_set::const_iterator iter = _bundles.begin(); iter != _bundles.end(); ++iter)
180 if (!(*iter).isIn(filter))
182 ret.insert( (*iter) );
199 const char *data =
reinterpret_cast<const char*
>(_bf.
table());
200 stream.write(data, _bf.
size());
210 std::vector<char> buffer(count.get<
size_t>());
212 stream.read(&buffer[0], buffer.size());
215 _bf.
load((
unsigned char*)&buffer[0], buffer.size());
233 __store_path_set__ =
true;
243 void MemoryBundleSet::store()
246 if (!MemoryBundleSet::__store_path_set__)
return;
249 if (_name.length() == 0)
return;
252 if (!__store_path__.
exists())
256 std::stringstream ss; ss << __store_path__.
getPath() <<
"/" << _name;
258 if(path_bundles.exists())
262 ofstream output_file;
263 output_file.open(path_bundles.getPath().c_str());
266 output_file << _bundles.size();
268 bundle_set::iterator iter = _bundles.begin();
269 while( iter != _bundles.end())
271 output_file << (*iter++);
277 void MemoryBundleSet::restore()
280 if (!MemoryBundleSet::__store_path_set__)
return;
282 std::stringstream ss; ss << __store_path__.
getPath() <<
"/" << _name;
286 if(!path_bundles.exists())
290 input_file.open(ss.str().c_str());
294 input_file >> num_bundles;
296 while (( i < num_bundles) && input_file.good())