Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DataFormats/Detectors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ add_subdirectory(PHOS)
add_subdirectory(CPV)
add_subdirectory(CTP)
add_subdirectory(GlobalTracking)
add_subdirectory(DCS)
if(ENABLE_UPGRADES)
add_subdirectory(Upgrades)
else()
Expand Down
12 changes: 12 additions & 0 deletions DataFormats/Detectors/DCS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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.

o2_add_header_only_library(DataFormatsDCS)
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// 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.

/// \file DCSConfigObject.h
/// \bried Data format to store DCS configurations

#include <vector>
#include <string>
#include <iostream>
#include <iterator>
#include <regex>

#include <TString.h>

namespace o2
{
namespace dcs
{

typedef std::vector<char> DCSconfigObject_t;

template <typename T>
inline void addConfigItem(DCSconfigObject_t& configVector, std::string key, const T value)
{
std::string keyValue = key + ":" + std::to_string(value) + ",";
std::copy(keyValue.begin(), keyValue.end(), std::back_inserter(configVector));
}

// explicit specialization for std::string
template <>
inline void addConfigItem(DCSconfigObject_t& configVector, std::string key, const std::string value)
{
std::string keyValue = key + ":" + value + ",";
std::copy(keyValue.begin(), keyValue.end(), std::back_inserter(configVector));
}

// explicit specialization for char
template <>
inline void addConfigItem(DCSconfigObject_t& configVector, std::string key, const char value)
{
std::string keyValue = key + ":" + value + ",";
std::copy(keyValue.begin(), keyValue.end(), std::back_inserter(configVector));
}

// explicit specialization for char*
template <>
inline void addConfigItem(DCSconfigObject_t& configVector, std::string key, const char* value)
{
std::string keyValue = key + ":" + value + ",";
std::copy(keyValue.begin(), keyValue.end(), std::back_inserter(configVector));
}

// explicit specialization for TString
template <>
inline void addConfigItem(DCSconfigObject_t& configVector, std::string key, const TString value)
{
std::string keyValue = key + ":" + value.Data() + ",";
std::copy(keyValue.begin(), keyValue.end(), std::back_inserter(configVector));
}

inline void printDCSConfig(const DCSconfigObject_t& configVector)
{
std::string sConfig(configVector.begin(), configVector.end());
std::cout << "string "
<< " --> " << sConfig << std::endl;
auto const re = std::regex{R"(,+)"};
auto vecRe = std::vector<std::string>(std::sregex_token_iterator{begin(sConfig), end(sConfig), re, -1},
std::sregex_token_iterator{});
for (size_t i = 0; i < vecRe.size(); ++i) {
// vecRe[i].erase(vecRe[i].end() - 1);
std::cout << i << " --> " << vecRe[i] << std::endl;
}
}

} // namespace dcs
} // namespace o2