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
33018afe
Commit
33018afe
authored
Apr 23, 2018
by
Matthieu Dorier
Browse files
added support for DataSets storing Runs
parent
fc5472c0
Changes
16
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
33018afe
...
...
@@ -11,6 +11,8 @@ cmake_minimum_required (VERSION 3.0)
project
(
hepnos CXX
)
enable_testing
()
add_definitions
(
-g
)
# add our cmake module directory to the path
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
...
...
include/hepnos/DataSet.hpp
View file @
33018afe
...
...
@@ -8,10 +8,14 @@
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/string.hpp>
#include <hepnos/Exception.hpp>
#include <hepnos/RunNumber.hpp>
#include <hepnos/DataStore.hpp>
namespace
hepnos
{
class
RunSet
;
class
Run
;
/**
* @brief The DataSet class represents a handle to a named dataset
* stored either at the root of an HEPnOS DataStore service, or within
...
...
@@ -21,6 +25,7 @@ namespace hepnos {
class
DataSet
{
friend
class
DataStore
;
friend
class
RunSet
;
private:
...
...
@@ -258,6 +263,19 @@ class DataSet {
*/
DataSet
createDataSet
(
const
std
::
string
&
name
);
/**
* @brief Creates a run with a given run number inside the DataSet.
* A Run object pointing to the created run is returned.
* If a run with the same number exists in this DataSet, the run
* is not created by a Run object pointing to the existing one is
* returned instead.
*
* @param runNumber Run number of the run to create.
*
* @return A Run instance pointing to the created run.
*/
Run
createRun
(
const
RunNumber
&
runNumber
);
typedef
DataStore
::
const_iterator
const_iterator
;
typedef
DataStore
::
iterator
iterator
;
...
...
@@ -309,12 +327,29 @@ class DataSet {
/**
* @brief Returns an iterator referring to the end of the DataSet.
* The DataSet pointed to by this iterator is not valid (that is,
* `end()->valid()` return `false`).
* `end()->valid()` return
s
`false`).
*
* @return an iterator referring to the end of the DataSet.
*/
iterator
end
();
/**
* @brief Returns a const_iterator referring to the first DataSet
* in this DataSet.
*
* @return a const_iterator referring to the first DataSet in this DataSet.
*/
const_iterator
begin
()
const
;
/**
* @brief Returns a const_iterator referring to the end of the DataSet.
* The DataSet pointed to by this iterator is not valid (that is,
* `end()->valid()` returns `false`).
*
* @return a const_iterator referring to the end of the DataSet.
*/
const_iterator
end
()
const
;
/**
* @brief Returns a const_iterator referring to the first DataSet
* in this DataSet.
...
...
@@ -382,7 +417,31 @@ class DataSet {
*/
const_iterator
upper_bound
(
const
std
::
string
&
ub
)
const
;
/**
* @brief Returns a reference to the RunSet associated with this DataSet.
*
* @return a reference to the RunSet associated with this DataSet.
*/
RunSet
&
runs
();
/**
* @brief Returns a reference to the RunSet associated with this DataSet.
*
* @return a reference to the RunSet associated with this DataSet.
*/
const
RunSet
&
runs
()
const
;
/**
* @brief Accesses an existing run using the ()
* operator. If no run corresponds to the provided run number,
* the function returns a Run instance d such that
* r.valid() is false.
*
* @param runNumber Number of the run to retrieve.
*
* @return a Run corresponding to the provided run number.
*/
Run
operator
()(
const
RunNumber
&
runNumber
)
const
;
};
}
...
...
include/hepnos/DataStore.hpp
View file @
33018afe
...
...
@@ -8,6 +8,9 @@
namespace
hepnos
{
class
DataSet
;
class
RunSet
;
class
Run
;
class
SubRun
;
/**
* The DataStore class is the main handle referencing an HEPnOS service.
...
...
@@ -16,6 +19,9 @@ class DataSet;
class
DataStore
{
friend
class
DataSet
;
friend
class
RunSet
;
friend
class
Run
;
friend
class
SubRun
;
public:
...
...
@@ -120,12 +126,29 @@ class DataStore {
/**
* @brief Returns an iterator referring to the end of the DataStore.
* The DataSet pointed to by this iterator is not valid (that is,
* `end()->valid()` return `false`).
* `end()->valid()` return
s
`false`).
*
* @return an iterator referring to the end of the DataStore.
*/
iterator
end
();
/**
* @brief Returns a const_iterator referring to the first DataSet
* in the DataStore.
*
* @return a const_iterator referring to the first DataSet in the DataStore.
*/
const_iterator
begin
()
const
;
/**
* @brief Returns a const_iterator referring to the end of the DataStore.
* The DataSet pointed to by this iterator is not valid (that is,
* `end()->valid()` returns `false`).
*
* @return a const_iterator referring to the end of the DataStore.
*/
const_iterator
end
()
const
;
/**
* @brief Returns a const_iterator referring to the first DataSet
* in the DataStore.
...
...
include/hepnos/Run.hpp
0 → 100644
View file @
33018afe
#ifndef __HEPNOS_RUN_H
#define __HEPNOS_RUN_H
#include <memory>
#include <string>
#include <hepnos/DataStore.hpp>
#include <hepnos/RunNumber.hpp>
namespace
hepnos
{
class
RunSet
;
class
Run
{
private:
friend
class
RunSet
;
friend
class
DataSet
;
class
Impl
;
std
::
unique_ptr
<
Impl
>
m_impl
;
Run
(
DataStore
*
datastore
,
uint8_t
level
,
const
std
::
string
&
container
,
const
RunNumber
&
run
);
public:
Run
();
Run
(
const
Run
&
);
Run
(
Run
&&
);
Run
&
operator
=
(
const
Run
&
);
Run
&
operator
=
(
Run
&&
);
~
Run
();
Run
next
()
const
;
bool
valid
()
const
;
bool
storeRawData
(
const
std
::
string
&
key
,
const
std
::
vector
<
char
>&
buffer
);
bool
loadRawData
(
const
std
::
string
&
key
,
std
::
vector
<
char
>&
buffer
)
const
;
bool
operator
==
(
const
Run
&
other
)
const
;
bool
operator
!=
(
const
Run
&
other
)
const
;
const
RunNumber
&
number
()
const
;
const
std
::
string
&
container
()
const
;
};
}
#endif
include/hepnos/RunNumber.hpp
0 → 100644
View file @
33018afe
#ifndef __HEPNOS_RUN_NUMBER_H
#define __HEPNOS_RUN_NUMBER_H
#include <cstdint>
namespace
hepnos
{
typedef
std
::
uint64_t
RunNumber
;
}
#endif
include/hepnos/RunSet.hpp
0 → 100644
View file @
33018afe
#ifndef __HEPNOS_RUN_SET_H
#define __HEPNOS_RUN_SET_H
#include <memory>
#include <hepnos/Exception.hpp>
#include <hepnos/DataStore.hpp>
#include <hepnos/DataSet.hpp>
#include <hepnos/RunNumber.hpp>
#include <hepnos/Run.hpp>
namespace
hepnos
{
/**
* @brief The RunSet class is a helper class to access Runs
* stored in a particular DataSet.
*/
class
RunSet
{
friend
class
DataSet
::
Impl
;
private:
/**
* @brief Constructor.
*
* @param ds DataSet to which this RunSet belongs.
*/
RunSet
(
DataSet
*
ds
);
/**
* @brief Implementation class (used for the Pimpl idiom).
*/
class
Impl
;
std
::
unique_ptr
<
Impl
>
m_impl
;
/*!< Pointer to implementation. */
public:
/**
* @brief Copy-constructor. Deleted.
*
* @param other RunSet to copy.
*/
RunSet
(
const
RunSet
&
other
)
=
delete
;
/**
* @brief Move-constructor. Deleted.
*
* @param other RunSet to move.
*/
RunSet
(
RunSet
&&
other
)
=
delete
;
/**
* @brief Copy-assignment operator. Deleted.
*
* @param other RunSet to copy.
*
* @return this.
*/
RunSet
&
operator
=
(
const
RunSet
&
other
)
=
delete
;
/**
* @brief Move-assignment operator. Deleted.
*
* @param other RunSet to move.
*
* @return this.
*/
RunSet
&
operator
=
(
RunSet
&&
other
)
=
delete
;
/**
* @brief Destructor.
*/
~
RunSet
();
class
const_iterator
;
class
iterator
;
/**
* @brief Searches this RunSet for a Run with
* the provided run number and returns an iterator to
* it if found, otherwise it returns an iterator pointing
* to RunSet::end().
*
* @param runNumber Run number of the Run to find.
*
* @return an iterator pointing to the Run if found,
* RunSet::end() otherwise.
*/
iterator
find
(
const
RunNumber
&
runNumber
);
/**
* @brief Searches this RunSet for a Run with
* the provided run number and returns an const_iterator to
* it if found, otherwise it returns an iterator pointing
* to RunSet::cend().
*
* @param runNumber Run number of the Run to find.
*
* @return a const_iterator pointing to the Run if found,
* RunSet::cend() otherwise.
*/
const_iterator
find
(
const
RunNumber
&
runNumber
)
const
;
/**
* @brief Returns an iterator referring to the first Run
* in this RunSet.
*
* @return an iterator referring to the first Run in this RunSet.
*/
iterator
begin
();
/**
* @brief Returns an iterator referring to the end of the RunSet.
* The RunSet pointed to by this iterator is not valid (that is,
* `end()->valid()` returns `false`).
*
* @return an iterator referring to the end of the RunSet.
*/
iterator
end
();
/**
* @brief Returns a const_iterator referring to the first Run
* in this RunSet.
*
* @return an iterator referring to the first Run in this RunSet.
*/
const_iterator
begin
()
const
;
/**
* @brief Returns a const_iterator referring to the end of the RunSet.
* The RunSet pointed to by this iterator is not valid (that is,
* `end()->valid()` returns `false`).
*
* @return a const_iterator referring to the end of the RunSet.
*/
const_iterator
end
()
const
;
/**
* @brief Returns a const_iterator referring to the first Run
* in this RunSet.
*
* @return a const_iterator referring to the first Run in this RunSet.
*/
const_iterator
cbegin
()
const
;
/**
* @brief Returns a const_iterator referring to the end of the RunSet.
* The RunSet pointed to by this iterator is not valid (that is,
* `cend()->valid()` return `false`).
*
* @return a const_iterator referring to the end of the RunSet.
*/
const_iterator
cend
()
const
;
/**
* @brief Returns an iterator pointing to the first Run in this
* RunSet, whose number is equal or greater than lb.
*
* @param lb Run number to search for.
*
* @return An iterator to the the first Run in this RunSet
* whose number is equal or greater than, lb or RunSet::end()
* if such a Run does not exist.
*/
iterator
lower_bound
(
const
RunNumber
&
lb
);
/**
* @brief Returns a const_iterator pointing to the first Run in this
* RunSet whose number is equal or greater than lb.
*
* @param lb Run number to search for.
*
* @return A const_iterator to the the first Run in this RunSet
* whose number is equal or greater than, lb or RunSet::end()
* if such a Run does not exist.
*/
const_iterator
lower_bound
(
const
RunNumber
&
lb
)
const
;
/**
* @brief Returns an iterator pointing to the first Run in the
* RunSet whose number is strictly greater than ub.
*
* @param ub Run number to search for.
*
* @return An iterator to the the first Run in this RunSet,
* whose number is stricly greater than ub, or RunSet::end() if
* no such a Run exist.
*/
iterator
upper_bound
(
const
RunNumber
&
ub
);
/**
* @brief Returns a const_iterator pointing to the first Run in the
* RunSet whose number is strictly greater than ub.
*
* @param ub Run number to search for.
*
* @return A const_iterator to the the first Run in this RunSet,
* whose number is stricly greater than ub, or RunSet::end() if
* no such a Run exist.
*/
const_iterator
upper_bound
(
const
RunNumber
&
ub
)
const
;
};
class
RunSet
::
const_iterator
{
protected:
/**
* @brief Implementation of the class (using Pimpl idiom)
*/
class
Impl
;
std
::
unique_ptr
<
Impl
>
m_impl
;
/*!< Pointer to implementation */
public:
/**
* @brief Constructor. Creates a const_iterator pointing
* to an invalid Run.
*/
const_iterator
();
/**
* @brief Constructor. Creates a const_iterator pointing
* to a given Run. The Run may or may not be valid.
*
* @param current Run to make the const_iterator point to.
*/
const_iterator
(
const
Run
&
current
);
/**
* @brief Constructor. Creates a const_iterator pointing
* to a given Run. The Run may or may not be valid.
*
* @param current Run to make the const_iterator point to.
*/
const_iterator
(
Run
&&
current
);
typedef
const_iterator
self_type
;
typedef
Run
value_type
;
typedef
Run
&
reference
;
typedef
Run
*
pointer
;
typedef
int
difference_type
;
typedef
std
::
forward_iterator_tag
iterator_category
;
/**
* @brief Destructor. This destructor is virtual because
* the iterator class inherits from const_iterator.
*/
virtual
~
const_iterator
();
/**
* @brief Copy-constructor.
*
* @param other const_iterator to copy.
*/
const_iterator
(
const
const_iterator
&
other
);
/**
* @brief Move-constructor.
*
* @param other const_iterator to move.
*/
const_iterator
(
const_iterator
&&
other
);
/**
* @brief Copy-assignment operator.
*
* @param other const_iterator to copy.
*
* @return this.
*/
const_iterator
&
operator
=
(
const
const_iterator
&
);
/**
* @brief Move-assignment operator.
*
* @param other const_iterator to move.
*
* @return this.
*/
const_iterator
&
operator
=
(
const_iterator
&&
);
/**
* @brief Increments the const_iterator, returning
* a copy of the iterator after incrementation.
*
* @return a copy of the iterator after incrementation.
*/
self_type
operator
++
();
/**
* @brief Increments the const_iterator, returning
* a copy of the iterator before incrementation.
*
* @return a copy of the iterator after incrementation.
*/
self_type
operator
++
(
int
);
/**
* @brief Dereference operator. Returns a const reference
* to the DataSet this const_iterator points to.
*
* @return a const reference to the DataSet this
* const_iterator points to.
*/
const
reference
operator
*
();
/**
* @brief Returns a const pointer to the DataSet this
* const_iterator points to.
*
* @return a const pointer to the DataSet this
* const_iterator points to.
*/
const
pointer
operator
->
();
/**
* @brief Compares two const_iterators. The two const_iterators
* are equal if they point to the same DataSet or if both
* correspond to RunSet::cend().
*
* @param rhs const_iterator to compare with.
*
* @return true if the two const_iterators are equal, false otherwise.
*/
bool
operator
==
(
const
self_type
&
rhs
)
const
;
/**
* @brief Compares two const_iterators.
*
* @param rhs const_iterator to compare with.
*
* @return true if the two const_iterators are different, false atherwise.
*/
bool
operator
!=
(
const
self_type
&
rhs
)
const
;
};
class
RunSet
::
iterator
:
public
RunSet
::
const_iterator
{
public:
/**
* @brief Constructor. Builds an iterator pointing to an
* invalid Run.
*/
iterator
();
/**
* @brief Constructor. Builds an iterator pointing to
* an existing Run. The Run may or may not be valid.
*
* @param current Run to point to.
*/
iterator
(
const
Run
&
current
);
/**
* @brief Constructor. Builds an iterator pointing to
* an existing Run. The Run may or may not be valid.
*
* @param current DataSet to point to.
*/
iterator
(
Run
&&
current
);
typedef
iterator
self_type
;
typedef
Run
value_type
;
typedef
Run
&
reference
;
typedef
Run
*
pointer
;
typedef
int
difference_type
;
typedef
std
::
forward_iterator_tag
iterator_category
;
/**
* @brief Destructor.
*/
~
iterator
();
/**
* @brief Copy constructor.
*
* @param other iterator to copy.
*/
iterator
(
const
iterator
&
other
);
/**
* @brief Move constructor.
*
* @param other iterator to move.
*/
iterator
(
iterator
&&
other
);
/**
* @brief Copy-assignment operator.
*
* @param other iterator to copy.
*
* @return this.
*/
iterator
&
operator
=
(
const
iterator
&
other
);
/**
* @brief Move-assignment operator.
*