Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
HEP
HEPnOS
Commits
ec1a1d40
Commit
ec1a1d40
authored
Apr 12, 2018
by
Matthieu Dorier
Browse files
added operator[]
parent
b23286ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/hepnos/DataStore.hpp
View file @
ec1a1d40
...
...
@@ -24,6 +24,8 @@ class DataStore {
~
DataStore
();
DataSet
operator
[](
const
std
::
string
&
datasetName
)
const
;
class
iterator
;
class
const_iterator
;
...
...
src/DataStore.cpp
View file @
ec1a1d40
...
...
@@ -271,6 +271,11 @@ DataStore::iterator DataStore::find(const std::string& datasetName) {
return
iterator
(
*
this
,
DataSet
(
*
this
,
1
,
datasetName
));
}
DataSet
DataStore
::
operator
[](
const
std
::
string
&
datasetName
)
const
{
auto
it
=
find
(
datasetName
);
return
std
::
move
(
*
it
);
}
DataStore
::
const_iterator
DataStore
::
find
(
const
std
::
string
&
datasetName
)
const
{
DataStore
::
iterator
it
=
const_cast
<
DataStore
*>
(
this
)
->
find
(
datasetName
);
return
it
;
...
...
test/example.cpp
View file @
ec1a1d40
...
...
@@ -58,5 +58,7 @@ int main(int argc, char** argv) {
dataset4
.
load
(
key
,
value
);
std
::
cout
<<
"load(
\"
matthieu
\"
) = "
<<
value
<<
std
::
endl
;
}
std
::
cout
<<
"====== Testing operator[] ========="
<<
std
::
endl
;
std
::
cout
<<
"datastore[
\"
myproject
\"
].fullname() = "
<<
datastore
[
"myproject"
].
fullname
()
<<
std
::
endl
;
return
0
;
}
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