Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HEPnOS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
HEP
HEPnOS
Commits
11f84b91
Commit
11f84b91
authored
Feb 13, 2020
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved internals of the implementation classes
parent
fe9485cf
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
97 deletions
+63
-97
src/Event.cpp
src/Event.cpp
+3
-12
src/EventImpl.hpp
src/EventImpl.hpp
+18
-19
src/Run.cpp
src/Run.cpp
+8
-26
src/RunImpl.hpp
src/RunImpl.hpp
+6
-0
src/SubRun.cpp
src/SubRun.cpp
+10
-27
src/SubRunImpl.hpp
src/SubRunImpl.hpp
+18
-13
No files found.
src/Event.cpp
View file @
11f84b91
...
...
@@ -11,8 +11,7 @@
namespace
hepnos
{
Event
::
Event
()
:
m_impl
(
std
::
make_shared
<
EventImpl
>
(
nullptr
,
0
,
std
::
make_shared
<
std
::
string
>
(
""
),
InvalidRunNumber
,
InvalidSubRunNumber
,
InvalidEventNumber
))
{}
:
m_impl
(
std
::
make_shared
<
EventImpl
>
(
0
,
nullptr
,
InvalidEventNumber
))
{}
Event
::
Event
(
std
::
shared_ptr
<
EventImpl
>&&
impl
)
:
m_impl
(
std
::
move
(
impl
))
{
}
...
...
@@ -40,9 +39,7 @@ Event Event::next() const {
if
(
keys
[
0
].
size
()
<=
i
)
return
Event
();
EventNumber
n
=
parseNumberFromKeyString
<
EventNumber
>
(
&
keys
[
0
][
i
]);
if
(
n
==
InvalidEventNumber
)
return
Event
();
return
Event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
m_impl
->
m_subrun_number
,
n
));
return
Event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_level
,
m_impl
->
m_subrun
,
n
));
}
bool
Event
::
valid
()
const
{
...
...
@@ -88,13 +85,7 @@ bool Event::operator==(const Event& other) const {
if
(
!
v1
&&
!
v2
)
return
true
;
if
(
!
v1
&&
v2
)
return
false
;
if
(
v1
&&
!
v2
)
return
false
;
return
m_impl
->
m_datastore
==
other
.
m_impl
->
m_datastore
&&
m_impl
->
m_level
==
other
.
m_impl
->
m_level
&&
(
m_impl
->
m_dataset_name
==
other
.
m_impl
->
m_dataset_name
||
*
m_impl
->
m_dataset_name
==
*
other
.
m_impl
->
m_dataset_name
)
&&
m_impl
->
m_run_number
==
other
.
m_impl
->
m_run_number
&&
m_impl
->
m_subrun_number
==
other
.
m_impl
->
m_subrun_number
&&
m_impl
->
m_event_number
==
other
.
m_impl
->
m_event_number
;
return
(
m_impl
==
other
.
m_impl
)
||
(
*
m_impl
==
*
other
.
m_impl
);
}
bool
Event
::
operator
!=
(
const
Event
&
other
)
const
{
...
...
src/EventImpl.hpp
View file @
11f84b91
...
...
@@ -15,6 +15,7 @@
#include "hepnos/SubRun.hpp"
#include "hepnos/Event.hpp"
#include "NumberUtil.hpp"
#include "SubRunImpl.hpp"
namespace
hepnos
{
...
...
@@ -23,33 +24,31 @@ class EventImpl {
public:
std
::
shared_ptr
<
DataStoreImpl
>
m_datastore
;
uint8_t
m_level
;
std
::
shared_ptr
<
std
::
string
>
m_dataset_name
;
RunNumber
m_run_number
;
SubRunNumber
m_subrun_number
;
std
::
shared_ptr
<
SubRunImpl
>
m_subrun
;
EventNumber
m_event_number
;
uint8_t
m_level
;
EventImpl
(
const
std
::
shared_ptr
<
DataStoreImpl
>&
ds
,
uint8_t
level
,
const
std
::
shared_ptr
<
std
::
string
>&
dataset
,
const
RunNumber
&
rn
,
const
SubRunNumber
&
srn
,
EventImpl
(
uint8_t
level
,
const
std
::
shared_ptr
<
SubRunImpl
>&
subrun
,
const
EventNumber
&
evn
)
:
m_datastore
(
ds
)
,
m_level
(
level
)
,
m_dataset_name
(
dataset
)
,
m_run_number
(
rn
)
,
m_subrun_number
(
srn
)
,
m_event_number
(
evn
)
{}
:
m_subrun
(
subrun
)
,
m_event_number
(
evn
)
,
m_level
(
level
)
{
if
(
subrun
)
m_datastore
=
subrun
->
m_datastore
;
}
bool
operator
==
(
const
EventImpl
&
other
)
const
{
if
(
m_event_number
!=
other
.
m_event_number
)
return
false
;
if
(
m_subrun
==
other
.
m_subrun
)
return
true
;
return
*
m_subrun
==
*
other
.
m_subrun
;
}
std
::
string
makeKeyStringFromEventNumber
()
const
{
return
makeKeyStringFromNumber
(
m_event_number
);
}
std
::
string
container
()
const
{
return
*
m_dataset_name
+
"/"
+
makeKeyStringFromNumber
(
m_run_number
)
+
"/"
+
makeKeyStringFromNumber
(
m_subrun_number
);
return
m_subrun
->
fullpath
();
}
std
::
string
fullpath
()
const
{
...
...
src/Run.cpp
View file @
11f84b91
...
...
@@ -91,11 +91,7 @@ bool Run::operator==(const Run& other) const {
if
(
!
v1
&&
!
v2
)
return
true
;
if
(
v1
&&
!
v2
)
return
false
;
if
(
!
v1
&&
v2
)
return
false
;
return
m_impl
->
m_datastore
==
other
.
m_impl
->
m_datastore
&&
m_impl
->
m_level
==
other
.
m_impl
->
m_level
&&
(
m_impl
->
m_dataset_name
==
other
.
m_impl
->
m_dataset_name
||
*
m_impl
->
m_dataset_name
==
*
other
.
m_impl
->
m_dataset_name
)
&&
m_impl
->
m_run_number
==
other
.
m_impl
->
m_run_number
;
return
(
m_impl
==
other
.
m_impl
)
||
(
*
m_impl
==
*
other
.
m_impl
);
}
bool
Run
::
operator
!=
(
const
Run
&
other
)
const
{
...
...
@@ -123,9 +119,7 @@ SubRun Run::createSubRun(const SubRunNumber& subRunNumber) {
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
subRunStr
=
makeKeyStringFromNumber
(
subRunNumber
);
m_impl
->
m_datastore
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
subRunNumber
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
subRunNumber
);
return
SubRun
(
std
::
move
(
new_subrun_impl
));
}
...
...
@@ -136,9 +130,7 @@ SubRun Run::createSubRun(WriteBatch& batch, const SubRunNumber& subRunNumber) {
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
subRunStr
=
makeKeyStringFromNumber
(
subRunNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
subRunStr
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
subRunNumber
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
subRunNumber
);
return
SubRun
(
std
::
move
(
new_subrun_impl
));
}
...
...
@@ -160,9 +152,7 @@ Run::iterator Run::find(const SubRunNumber& subRunNumber) {
if
(
!
b
)
{
return
m_impl
->
m_end
;
}
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
subRunNumber
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
subRunNumber
);
return
iterator
(
SubRun
(
std
::
move
(
new_subrun_impl
)));
}
...
...
@@ -175,9 +165,7 @@ Run::iterator Run::begin() {
auto
it
=
find
(
0
);
if
(
it
!=
end
())
return
*
it
;
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
0
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
0
);
SubRun
subrun
(
std
::
move
(
new_subrun_impl
));
subrun
=
subrun
.
next
();
...
...
@@ -221,9 +209,7 @@ Run::iterator Run::lower_bound(const SubRunNumber& lb) {
if
(
it
!=
end
())
{
return
it
;
}
else
{
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
0
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
0
);
SubRun
subrun
(
std
::
move
(
new_subrun_impl
));
subrun
=
subrun
.
next
();
if
(
!
subrun
.
valid
())
return
end
();
...
...
@@ -235,9 +221,7 @@ Run::iterator Run::lower_bound(const SubRunNumber& lb) {
++
it
;
return
it
;
}
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
lb
-
1
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
lb
-
1
);
SubRun
subrun
(
std
::
move
(
new_subrun_impl
));
subrun
=
subrun
.
next
();
if
(
!
subrun
.
valid
())
return
end
();
...
...
@@ -254,9 +238,7 @@ Run::iterator Run::upper_bound(const SubRunNumber& ub) {
if
(
!
valid
())
{
throw
Exception
(
"Calling Run member function on an invalid Run object"
);
}
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
ub
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
ub
);
SubRun
subrun
(
std
::
move
(
new_subrun_impl
));
subrun
=
subrun
.
next
();
if
(
!
subrun
.
valid
())
return
end
();
...
...
src/RunImpl.hpp
View file @
11f84b91
...
...
@@ -35,6 +35,12 @@ class RunImpl {
,
m_dataset_name
(
dataset
)
,
m_run_number
(
rn
)
{}
bool
operator
==
(
const
RunImpl
&
other
)
const
{
if
(
m_run_number
!=
other
.
m_run_number
)
return
false
;
if
(
m_dataset_name
==
other
.
m_dataset_name
)
return
true
;
return
*
m_dataset_name
==
*
other
.
m_dataset_name
;
}
std
::
string
makeKeyStringFromRunNumber
()
const
{
return
makeKeyStringFromNumber
(
m_run_number
);
}
...
...
src/SubRun.cpp
View file @
11f84b91
...
...
@@ -16,7 +16,7 @@ namespace hepnos {
SubRun
::
iterator
SubRunImpl
::
m_end
;
SubRun
::
SubRun
()
:
m_impl
(
std
::
make_shared
<
SubRunImpl
>
(
nullptr
,
0
,
std
::
make_shared
<
std
::
string
>
(
""
),
InvalidRunNumbe
r
,
InvalidSubRunNumber
))
{}
:
m_impl
(
std
::
make_shared
<
SubRunImpl
>
(
0
,
nullpt
r
,
InvalidSubRunNumber
))
{}
SubRun
::
SubRun
(
std
::
shared_ptr
<
SubRunImpl
>&&
impl
)
:
m_impl
(
std
::
move
(
impl
))
{
}
...
...
@@ -44,8 +44,7 @@ SubRun SubRun::next() const {
if
(
keys
[
0
].
size
()
<=
i
)
return
SubRun
();
SubRunNumber
srn
=
parseNumberFromKeyString
<
SubRunNumber
>
(
&
keys
[
0
][
i
]);
if
(
srn
==
InvalidSubRunNumber
)
return
SubRun
();
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
srn
);
auto
new_subrun_impl
=
std
::
make_shared
<
SubRunImpl
>
(
m_impl
->
m_level
,
m_impl
->
m_run
,
srn
);
return
SubRun
(
std
::
move
(
new_subrun_impl
));
}
...
...
@@ -91,12 +90,7 @@ bool SubRun::operator==(const SubRun& other) const {
if
(
!
v1
&&
!
v2
)
return
true
;
if
(
!
v1
&&
v2
)
return
false
;
if
(
v1
&&
!
v2
)
return
false
;
return
m_impl
->
m_datastore
==
other
.
m_impl
->
m_datastore
&&
m_impl
->
m_level
==
other
.
m_impl
->
m_level
&&
(
m_impl
->
m_dataset_name
==
other
.
m_impl
->
m_dataset_name
||
*
m_impl
->
m_dataset_name
==
*
other
.
m_impl
->
m_dataset_name
)
&&
m_impl
->
m_run_number
==
other
.
m_impl
->
m_run_number
&&
m_impl
->
m_subrun_number
==
other
.
m_impl
->
m_subrun_number
;
return
(
m_impl
==
other
.
m_impl
)
||
(
*
m_impl
==
*
other
.
m_impl
);
}
bool
SubRun
::
operator
!=
(
const
SubRun
&
other
)
const
{
...
...
@@ -114,8 +108,7 @@ Event SubRun::createEvent(const EventNumber& eventNumber) {
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
eventStr
=
makeKeyStringFromNumber
(
eventNumber
);
m_impl
->
m_datastore
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
return
Event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
m_impl
->
m_subrun_number
,
eventNumber
));
return
Event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
eventNumber
));
}
Event
SubRun
::
createEvent
(
WriteBatch
&
batch
,
const
EventNumber
&
eventNumber
)
{
...
...
@@ -125,8 +118,7 @@ Event SubRun::createEvent(WriteBatch& batch, const EventNumber& eventNumber) {
std
::
string
parent
=
m_impl
->
fullpath
();
std
::
string
eventStr
=
makeKeyStringFromNumber
(
eventNumber
);
batch
.
m_impl
->
store
(
m_impl
->
m_level
+
1
,
parent
,
eventStr
);
return
Event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
m_impl
->
m_subrun_number
,
eventNumber
));
return
Event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
eventNumber
));
}
Event
SubRun
::
operator
[](
const
EventNumber
&
eventNumber
)
const
{
...
...
@@ -147,9 +139,7 @@ SubRun::iterator SubRun::find(const EventNumber& eventNumber) {
if
(
!
b
)
{
return
m_impl
->
m_end
;
}
return
iterator
(
Event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
m_impl
->
m_subrun_number
,
eventNumber
)));
return
iterator
(
Event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
eventNumber
)));
}
SubRun
::
const_iterator
SubRun
::
find
(
const
EventNumber
&
eventNumber
)
const
{
...
...
@@ -164,8 +154,7 @@ SubRun::iterator SubRun::begin() {
auto
level
=
m_impl
->
m_level
;
auto
datastore
=
m_impl
->
m_datastore
;
std
::
string
container
=
m_impl
->
fullpath
();
Event
event
(
std
::
make_shared
<
EventImpl
>
(
datastore
,
level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
m_impl
->
m_subrun_number
,
0
));
Event
event
(
std
::
make_shared
<
EventImpl
>
(
level
+
1
,
m_impl
,
0
));
event
=
event
.
next
();
if
(
event
.
valid
())
return
iterator
(
std
::
move
(
event
));
...
...
@@ -207,9 +196,7 @@ SubRun::iterator SubRun::lower_bound(const EventNumber& lb) {
if
(
it
!=
end
())
{
return
it
;
}
else
{
Event
event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
m_impl
->
m_subrun_number
,
0
));
Event
event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
0
));
event
=
event
.
next
();
if
(
!
event
.
valid
())
return
end
();
else
return
iterator
(
event
);
...
...
@@ -220,9 +207,7 @@ SubRun::iterator SubRun::lower_bound(const EventNumber& lb) {
++
it
;
return
it
;
}
Event
event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
m_impl
->
m_subrun_number
,
lb
-
1
));
Event
event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
lb
-
1
));
event
=
event
.
next
();
if
(
!
event
.
valid
())
return
end
();
else
return
iterator
(
event
);
...
...
@@ -238,9 +223,7 @@ SubRun::iterator SubRun::upper_bound(const EventNumber& ub) {
if
(
!
valid
())
{
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
}
Event
event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_datastore
,
m_impl
->
m_level
+
1
,
m_impl
->
m_dataset_name
,
m_impl
->
m_run_number
,
m_impl
->
m_subrun_number
,
ub
));
Event
event
(
std
::
make_shared
<
EventImpl
>
(
m_impl
->
m_level
+
1
,
m_impl
,
ub
));
event
=
event
.
next
();
if
(
!
event
.
valid
())
return
end
();
else
return
iterator
(
event
);
...
...
src/SubRunImpl.hpp
View file @
11f84b91
...
...
@@ -12,6 +12,7 @@
#include "DataStoreImpl.hpp"
#include "hepnos/Run.hpp"
#include "hepnos/SubRun.hpp"
#include "RunImpl.hpp"
#include "NumberUtil.hpp"
namespace
hepnos
{
...
...
@@ -21,29 +22,33 @@ class SubRunImpl {
public:
std
::
shared_ptr
<
DataStoreImpl
>
m_datastore
;
uint8_t
m_level
;
std
::
shared_ptr
<
std
::
string
>
m_dataset_name
;
RunNumber
m_run_number
;
std
::
shared_ptr
<
RunImpl
>
m_run
;
SubRunNumber
m_subrun_number
;
uint8_t
m_level
;
static
SubRun
::
iterator
m_end
;
SubRunImpl
(
const
std
::
shared_ptr
<
DataStoreImpl
>&
ds
,
uint8_t
level
,
const
std
::
shared_ptr
<
std
::
string
>&
dataset
,
const
RunNumber
&
rn
,
const
SubRunNumber
&
srn
)
:
m_datastore
(
ds
)
,
m_level
(
level
)
,
m_dataset_name
(
dataset
)
,
m_run_number
(
rn
)
,
m_subrun_number
(
srn
)
{}
SubRunImpl
(
uint8_t
level
,
const
std
::
shared_ptr
<
RunImpl
>&
run
,
const
SubRunNumber
&
srn
)
:
m_run
(
run
)
,
m_subrun_number
(
srn
)
,
m_level
(
level
)
{
if
(
m_run
)
m_datastore
=
m_run
->
m_datastore
;
}
bool
operator
==
(
const
SubRunImpl
&
other
)
const
{
if
(
m_subrun_number
!=
other
.
m_subrun_number
)
return
false
;
if
(
m_run
==
other
.
m_run
)
return
true
;
return
*
m_run
==
*
other
.
m_run
;
}
std
::
string
makeKeyStringFromSubRunNumber
()
const
{
return
makeKeyStringFromNumber
(
m_subrun_number
);
}
std
::
string
container
()
const
{
return
*
m_dataset_name
+
"/"
+
makeKeyStringFromNumber
(
m_run_number
);
return
m_run
->
fullpath
(
);
}
std
::
string
fullpath
()
const
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment