diff --git a/Framework/Core/CMakeLists.txt b/Framework/Core/CMakeLists.txt index c1214a8f56beb..5ca98f4a29225 100644 --- a/Framework/Core/CMakeLists.txt +++ b/Framework/Core/CMakeLists.txt @@ -137,6 +137,7 @@ o2_add_library(Framework src/Task.cxx src/Array2D.cxx src/Variant.cxx + src/VariantPropertyTreeHelpers.cxx src/WorkflowCustomizationHelpers.cxx src/WorkflowHelpers.cxx src/WorkflowSerializationHelpers.cxx diff --git a/Framework/Core/include/Framework/VariantPropertyTreeHelpers.h b/Framework/Core/include/Framework/VariantPropertyTreeHelpers.h index 484501a18991e..a51e3e03ffc5e 100644 --- a/Framework/Core/include/Framework/VariantPropertyTreeHelpers.h +++ b/Framework/Core/include/Framework/VariantPropertyTreeHelpers.h @@ -11,15 +11,14 @@ #ifndef FRAMEWORK_VARIANTPTREEHELPERS_H #define FRAMEWORK_VARIANTPTREEHELPERS_H +#include "Array2D.h" #include "Framework/Variant.h" #include namespace o2::framework { -namespace -{ template -auto basicVectorToBranch(T* values, size_t size) +boost::property_tree::ptree basicVectorToBranch(T* values, size_t size) { boost::property_tree::ptree branch; for (auto i = 0u; i < size; ++i) { @@ -31,30 +30,27 @@ auto basicVectorToBranch(T* values, size_t size) } template -auto basicVectorToBranch(std::vector&& values) +boost::property_tree::ptree basicVectorToBranch(std::vector&& values) { return basicVectorToBranch(values.data(), values.size()); } template -auto vectorToBranch(T* values, size_t size) +boost::property_tree::ptree vectorToBranch(T* values, size_t size) { boost::property_tree::ptree branch; branch.put_child("values", basicVectorToBranch(values, size)); return branch; } -} // namespace template -auto vectorToBranch(std::vector&& values) +boost::property_tree::ptree vectorToBranch(std::vector&& values) { return vectorToBranch(values.data(), values.size()); } -namespace -{ template -auto basicArray2DToBranch(Array2D&& array) +boost::property_tree::ptree basicArray2DToBranch(Array2D&& array) { boost::property_tree::ptree subtree; for (auto i = 0u; i < array.rows; ++i) { @@ -68,20 +64,17 @@ auto basicArray2DToBranch(Array2D&& array) } return subtree; } -} // namespace template -auto array2DToBranch(Array2D&& array) +boost::property_tree::ptree array2DToBranch(Array2D&& array) { boost::property_tree::ptree subtree; subtree.put_child("values", basicArray2DToBranch(std::forward>(array))); return subtree; } -namespace -{ template -auto basicVectorFromBranch(boost::property_tree::ptree const& branch) +std::vector basicVectorFromBranch(boost::property_tree::ptree const& branch) { std::vector result(branch.size()); auto count = 0U; @@ -90,18 +83,15 @@ auto basicVectorFromBranch(boost::property_tree::ptree const& branch) } return result; } -} // namespace template -auto vectorFromBranch(boost::property_tree::ptree const& branch) +std::vector vectorFromBranch(boost::property_tree::ptree const& branch) { return basicVectorFromBranch(branch.get_child("values")); } -namespace -{ template -auto basicArray2DFromBranch(boost::property_tree::ptree const& branch) +Array2D basicArray2DFromBranch(boost::property_tree::ptree const& branch) { std::vector cache; uint32_t nrows = branch.size(); @@ -122,10 +112,9 @@ auto basicArray2DFromBranch(boost::property_tree::ptree const& branch) } return Array2D{cache, nrows, ncols}; } -} // namespace template -auto array2DFromBranch(boost::property_tree::ptree const& ptree) +Array2D array2DFromBranch(boost::property_tree::ptree const& ptree) { return basicArray2DFromBranch(ptree.get_child("values")); } @@ -133,7 +122,7 @@ auto array2DFromBranch(boost::property_tree::ptree const& ptree) std::pair, std::vector> extractLabels(boost::property_tree::ptree const& tree); template -auto labeledArrayFromBranch(boost::property_tree::ptree const& tree) +LabeledArray labeledArrayFromBranch(boost::property_tree::ptree const& tree) { auto [labels_rows, labels_cols] = extractLabels(tree); auto values = basicArray2DFromBranch(tree.get_child("values")); @@ -142,7 +131,7 @@ auto labeledArrayFromBranch(boost::property_tree::ptree const& tree) } template -auto labeledArrayToBranch(LabeledArray&& array) +boost::property_tree::ptree labeledArrayToBranch(LabeledArray&& array) { boost::property_tree::ptree subtree; subtree.put_child(labels_rows_str, basicVectorToBranch(array.getLabelsRows())); @@ -153,4 +142,48 @@ auto labeledArrayToBranch(LabeledArray&& array) } } // namespace o2::framework +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::vector&& values); +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::vector&& values); +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::vector&& values); +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::vector&& values); +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(float*, size_t); +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(int*, size_t); +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(double*, size_t); +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(bool*, size_t); +extern template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::basic_string*, size_t); + +extern template boost::property_tree::ptree o2::framework::vectorToBranch(std::vector&& values); +extern template boost::property_tree::ptree o2::framework::vectorToBranch(std::vector&& values); +extern template boost::property_tree::ptree o2::framework::vectorToBranch(std::vector&& values); +extern template boost::property_tree::ptree o2::framework::vectorToBranch(std::vector&& values); +extern template boost::property_tree::ptree o2::framework::vectorToBranch(float*, size_t); +extern template boost::property_tree::ptree o2::framework::vectorToBranch(int*, size_t); +extern template boost::property_tree::ptree o2::framework::vectorToBranch(double*, size_t); +extern template boost::property_tree::ptree o2::framework::vectorToBranch(bool*, size_t); +extern template boost::property_tree::ptree o2::framework::vectorToBranch(std::basic_string*, size_t); + +extern template boost::property_tree::ptree o2::framework::labeledArrayToBranch(o2::framework::LabeledArray&& array); +extern template boost::property_tree::ptree o2::framework::labeledArrayToBranch(o2::framework::LabeledArray&& array); +extern template boost::property_tree::ptree o2::framework::labeledArrayToBranch(o2::framework::LabeledArray&& array); +extern template boost::property_tree::ptree o2::framework::labeledArrayToBranch(o2::framework::LabeledArray&& array); + +extern template std::vector o2::framework::basicVectorFromBranch(boost::property_tree::ptree const& tree); +extern template std::vector o2::framework::basicVectorFromBranch(boost::property_tree::ptree const& tree); +extern template std::vector> o2::framework::basicVectorFromBranch>(boost::property_tree::ptree const& tree); +extern template std::vector o2::framework::basicVectorFromBranch(boost::property_tree::ptree const& tree); + +extern template o2::framework::LabeledArray o2::framework::labeledArrayFromBranch(boost::property_tree::ptree const& tree); +extern template o2::framework::LabeledArray o2::framework::labeledArrayFromBranch(boost::property_tree::ptree const& tree); +extern template o2::framework::LabeledArray o2::framework::labeledArrayFromBranch(boost::property_tree::ptree const& tree); +extern template o2::framework::LabeledArray o2::framework::labeledArrayFromBranch(boost::property_tree::ptree const& tree); + +extern template o2::framework::Array2D o2::framework::array2DFromBranch(boost::property_tree::ptree const& tree); +extern template o2::framework::Array2D o2::framework::array2DFromBranch(boost::property_tree::ptree const& tree); +extern template o2::framework::Array2D o2::framework::array2DFromBranch(boost::property_tree::ptree const& tree); +extern template o2::framework::Array2D o2::framework::array2DFromBranch(boost::property_tree::ptree const& tree); + +extern template boost::property_tree::ptree o2::framework::array2DToBranch(o2::framework::Array2D&& array); +extern template boost::property_tree::ptree o2::framework::array2DToBranch(o2::framework::Array2D&& array); +extern template boost::property_tree::ptree o2::framework::array2DToBranch(o2::framework::Array2D&& array); +extern template boost::property_tree::ptree o2::framework::array2DToBranch(o2::framework::Array2D&& array); #endif // FRAMEWORK_VARIANTPTREEHELPERS_H diff --git a/Framework/Core/src/VariantPropertyTreeHelpers.cxx b/Framework/Core/src/VariantPropertyTreeHelpers.cxx new file mode 100644 index 0000000000000..2b1746aae2c66 --- /dev/null +++ b/Framework/Core/src/VariantPropertyTreeHelpers.cxx @@ -0,0 +1,57 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "Framework/VariantPropertyTreeHelpers.h" + +template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::vector&& values); +template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::vector&& values); +template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::vector&& values); +template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::vector&& values); +template boost::property_tree::ptree o2::framework::basicVectorToBranch(float*, size_t); +template boost::property_tree::ptree o2::framework::basicVectorToBranch(int*, size_t); +template boost::property_tree::ptree o2::framework::basicVectorToBranch(double*, size_t); +template boost::property_tree::ptree o2::framework::basicVectorToBranch(bool*, size_t); +template boost::property_tree::ptree o2::framework::basicVectorToBranch(std::basic_string*, size_t); + +template boost::property_tree::ptree o2::framework::vectorToBranch(std::vector&& values); +template boost::property_tree::ptree o2::framework::vectorToBranch(std::vector&& values); +template boost::property_tree::ptree o2::framework::vectorToBranch(std::vector&& values); +template boost::property_tree::ptree o2::framework::vectorToBranch(std::vector&& values); +template boost::property_tree::ptree o2::framework::vectorToBranch(float*, size_t); +template boost::property_tree::ptree o2::framework::vectorToBranch(int*, size_t); +template boost::property_tree::ptree o2::framework::vectorToBranch(double*, size_t); +template boost::property_tree::ptree o2::framework::vectorToBranch(bool*, size_t); +template boost::property_tree::ptree o2::framework::vectorToBranch(std::basic_string*, size_t); + +template boost::property_tree::ptree o2::framework::labeledArrayToBranch(o2::framework::LabeledArray&& array); +template boost::property_tree::ptree o2::framework::labeledArrayToBranch(o2::framework::LabeledArray&& array); +template boost::property_tree::ptree o2::framework::labeledArrayToBranch(o2::framework::LabeledArray&& array); +template boost::property_tree::ptree o2::framework::labeledArrayToBranch(o2::framework::LabeledArray&& array); + +template std::vector o2::framework::basicVectorFromBranch(boost::property_tree::ptree const& tree); +template std::vector o2::framework::basicVectorFromBranch(boost::property_tree::ptree const& tree); +template std::vector> o2::framework::basicVectorFromBranch>(boost::property_tree::ptree const& tree); +template std::vector o2::framework::basicVectorFromBranch(boost::property_tree::ptree const& tree); + +template o2::framework::LabeledArray o2::framework::labeledArrayFromBranch(boost::property_tree::ptree const& tree); +template o2::framework::LabeledArray o2::framework::labeledArrayFromBranch(boost::property_tree::ptree const& tree); +template o2::framework::LabeledArray o2::framework::labeledArrayFromBranch(boost::property_tree::ptree const& tree); +template o2::framework::LabeledArray o2::framework::labeledArrayFromBranch(boost::property_tree::ptree const& tree); + +template o2::framework::Array2D o2::framework::array2DFromBranch(boost::property_tree::ptree const& tree); +template o2::framework::Array2D o2::framework::array2DFromBranch(boost::property_tree::ptree const& tree); +template o2::framework::Array2D o2::framework::array2DFromBranch(boost::property_tree::ptree const& tree); +template o2::framework::Array2D o2::framework::array2DFromBranch(boost::property_tree::ptree const& tree); + +template boost::property_tree::ptree o2::framework::array2DToBranch(o2::framework::Array2D&& array); +template boost::property_tree::ptree o2::framework::array2DToBranch(o2::framework::Array2D&& array); +template boost::property_tree::ptree o2::framework::array2DToBranch(o2::framework::Array2D&& array); +template boost::property_tree::ptree o2::framework::array2DToBranch(o2::framework::Array2D&& array);