Project
Loading...
Searching...
No Matches
MermaidHelpers.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "MermaidHelpers.h"
13#include <map>
14#include <iostream>
15#include <string>
16
17namespace o2
18{
19namespace framework
20{
21
22namespace
23{
24std::string quote(std::string const& s) { return R"(")" + s + R"(")"; }
25} // namespace
26
28void MermaidHelpers::dumpDeviceSpec2Mermaid(std::ostream& out, const std::vector<DeviceSpec>& specs)
29{
30 out << R"(graph TD
31)";
32 std::map<std::string, std::string> outputChannel2Device;
33 std::map<std::string, unsigned int> outputChannel2Port;
34
35 for (auto& spec : specs) {
36 auto id = spec.id;
37 out << " " << id << "\n";
38 for (auto&& output : spec.outputChannels) {
39 outputChannel2Device.insert(std::make_pair(output.name, id));
40 outputChannel2Port.insert(std::make_pair(output.name, output.port));
41 }
42 }
43 for (auto& spec : specs) {
44 for (auto& input : spec.inputChannels) {
45 auto outputName = input.name;
46 out << " " << outputChannel2Device[outputName] << "-- " << input.port << ":" << outputName << " -->" << spec.id << "\n";
47 }
48 }
49}
50
51} // namespace framework
52} // namespace o2
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static void dumpDeviceSpec2Mermaid(std::ostream &, const Devices &specs)
Helper to dump a set of devices as a mermaid file.