Skip to content

Commit 9ec3563

Browse files
committed
DPL Analysis: Expressions <-> JSON
* add serialization/deserialization support for expressions * add test
1 parent cad3e3f commit 9ec3563

File tree

5 files changed

+617
-1
lines changed

5 files changed

+617
-1
lines changed

Framework/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ o2_add_library(Framework
143143
src/Array2D.cxx
144144
src/Variant.cxx
145145
src/VariantJSONHelpers.cxx
146+
src/ExpressionJSONHelpers.cxx
146147
src/VariantPropertyTreeHelpers.cxx
147148
src/WorkflowCustomizationHelpers.cxx
148149
src/WorkflowHelpers.cxx
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2019-2025 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+
#ifndef FRAMEWORK_EXPRESSIONJSONHELPERS_H
12+
#define FRAMEWORK_EXPRESSIONJSONHELPERS_H
13+
14+
#include "Framework/Expressions.h"
15+
16+
namespace o2::framework {
17+
struct ExpressionJSONHelpers {
18+
static std::unique_ptr<expressions::Node> read(std::istream& s);
19+
static void write(std::ostream& o, expressions::Node* n);
20+
};
21+
}
22+
23+
#endif // FRAMEWORK_EXPRESSIONJSONHELPERS_H

Framework/Core/include/Framework/Expressions.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ std::string upcastTo(atype::type f);
110110

111111
/// An expression tree node corresponding to a literal value
112112
struct LiteralNode {
113+
using var_t = LiteralValue::stored_type;
114+
113115
LiteralNode()
114116
: value{-1},
115117
type{atype::INT32}
@@ -120,7 +122,12 @@ struct LiteralNode {
120122
{
121123
}
122124

123-
using var_t = LiteralValue::stored_type;
125+
LiteralNode(var_t v, atype::type t)
126+
: value{v},
127+
type{t}
128+
{
129+
}
130+
124131
var_t value;
125132
atype::type type = atype::NA;
126133
};
@@ -617,6 +624,11 @@ inline Node ncfg(T defaultValue, std::string path)
617624
struct Filter {
618625
Filter() = default;
619626

627+
Filter(std::unique_ptr<Node>&& ptr)
628+
{
629+
node = std::move(ptr);
630+
}
631+
620632
Filter(Node&& node_) : node{std::make_unique<Node>(std::forward<Node>(node_))}
621633
{
622634
(void)designateSubtrees(node.get());

0 commit comments

Comments
 (0)