Project
Loading...
Searching...
No Matches
ExpressionHelpers.h
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#ifndef O2_FRAMEWORK_EXPRESSIONS_HELPERS_H_
12#define O2_FRAMEWORK_EXPRESSIONS_HELPERS_H_
14
15#include <iosfwd>
16#include <fmt/format.h>
17
19{
20
21struct DatumSpec {
23 using datum_t = std::variant<std::monostate, size_t, LiteralNode::var_t, std::string>;
24 datum_t datum = std::monostate{};
25 size_t hash = 0;
26 atype::type type = atype::NA;
27
28 explicit DatumSpec(size_t index, atype::type type_) : datum{index}, type{type_} {}
29 explicit DatumSpec(LiteralNode::var_t literal, atype::type type_) : datum{literal}, type{type_} {}
30 explicit DatumSpec(std::string binding, size_t hash_, atype::type type_) : datum{binding}, hash{hash_}, type{type_} {}
31 DatumSpec() = default;
32 DatumSpec(DatumSpec const&) = default;
33 DatumSpec(DatumSpec&&) = default;
34 DatumSpec& operator=(DatumSpec const&) = default;
36};
37
38bool operator==(DatumSpec const& lhs, DatumSpec const& rhs);
39
40std::ostream& operator<<(std::ostream& os, DatumSpec const& spec);
41
43 size_t index = 0;
49 atype::type type = atype::NA;
51 explicit ColumnOperationSpec(BasicOp op_, size_t index_ = 0)
52 : index{index_},
53 op{op_},
54 left{},
55 right{},
56 condition{},
57 result{}
58 {
59 switch (op) {
66 case BasicOp::Equal:
68 type = atype::BOOL;
69 break;
71 type = atype::FLOAT;
72 default:
73 type = atype::NA;
74 }
76 }
77};
78
80struct NodeRecord {
82 Node* node_ptr = nullptr;
83 size_t index = 0;
84 explicit NodeRecord(Node* node_, size_t index_) : node_ptr(node_), index{index_} {}
85 bool operator!=(NodeRecord const& rhs)
86 {
87 return this->node_ptr != rhs.node_ptr;
88 }
89};
90} // namespace o2::framework::expressions
91
92#endif // O2_FRAMEWORK_EXPRESSIONS_HELPERS_H_
GLuint64EXT * result
Definition glcorearb.h:5662
GLuint index
Definition glcorearb.h:781
GLdouble GLdouble right
Definition glcorearb.h:4077
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
bool operator==(DatumSpec const &lhs, DatumSpec const &rhs)
std::ostream & operator<<(std::ostream &os, DatumSpec const &spec)
@ GreaterThanOrEqual
Definition BasicOps.h:29
ColumnOperationSpec(BasicOp op_, size_t index_=0)
DatumSpec(size_t index, atype::type type_)
DatumSpec(std::string binding, size_t hash_, atype::type type_)
DatumSpec & operator=(DatumSpec &&)=default
std::variant< std::monostate, size_t, LiteralNode::var_t, std::string > datum_t
datum spec either contains an index, a value of a literal or a binding label
DatumSpec & operator=(DatumSpec const &)=default
DatumSpec(DatumSpec const &)=default
DatumSpec(LiteralNode::var_t literal, atype::type type_)
LiteralValue::stored_type var_t
helper struct used to parse trees
bool operator!=(NodeRecord const &rhs)
Node * node_ptr
pointer to the actual tree node
NodeRecord(Node *node_, size_t index_)