Commit 98e7aee4 authored by Matthieu Dorier's avatar Matthieu Dorier

done with getEventByID

parent f380fca9
......@@ -43,6 +43,15 @@ public:
return FileNamespace();
}
event_type getEventByID(std::uint64_t id) {
std::stringstream ss;
ss << _path << ".ref/" << std::setfill('0') << std::setw(20) << id;
std::string link = ss.str();
if(!fs::exists(link)) return FileEvent();
std::string p = fs::canonical(link).string();
return FileEvent(p);
}
private:
std::string _path;
......
......@@ -13,11 +13,13 @@ namespace hepnos {
namespace fs = boost::filesystem;
class FileSubRun;
class FileDataStore;
class FileEvent : public ProductAccessor<FileProductAccessorBackend> {
private:
friend class FileDataStore;
friend class FileSubRun;
friend class FileObjectIterator<FileEvent>;
......@@ -42,6 +44,24 @@ class FileEvent : public ProductAccessor<FileProductAccessorBackend> {
createRefAndSetID();
}
FileEvent(const std::string& dir)
: ProductAccessor<FileProductAccessorBackend>(dir)
, _eventNumber(0)
, _path(dir) {
if(_path.back() != '/') _path += std::string("/");
std::size_t i,j;
j = _path.size()-1;
if(_path[j] == '/') j--;
i = j;
while(_path[i] != '/') i--;
i += 1;
while(_path[i] == '0') i++;
j += 1;
std::string eventDir(&dir[i], j-i);
if(eventDir.size() > 0)
_eventNumber = std::stoi(eventDir);
}
FileEvent()
: ProductAccessor<FileProductAccessorBackend>("")
, _eventNumber(std::numeric_limits<std::uint64_t>::max())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment