The Gaudi Framework
master (57817a18)
Toggle main menu visibility
Loading...
Searching...
No Matches
AnyViewAlgorithm.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#include <
Gaudi/Functional/Consumer.h
>
12
#include <
Gaudi/Functional/Producer.h
>
13
#include <
GaudiKernel/Algorithm.h
>
14
#include <
GaudiKernel/DataObjectHandle.h
>
15
#include <gsl/span>
16
#include <string>
17
#include <string_view>
18
#include <vector>
19
20
using
BaseClass_t
=
Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>
;
21
22
template
<
typename
Data,
typename
View>
23
using
writeViewFor
=
Gaudi::Functional::Traits::use_<Gaudi::Functional::Traits::writeViewFor<Data, View>
,
BaseClass_t
>;
24
25
struct
ProduceStringView
:
Gaudi::Functional::Producer
<std::string(), writeViewFor<std::string, std::string_view>> {
26
ProduceStringView
(
const
std::string& name,
ISvcLocator
* svcLoc )
27
: Producer{ name, svcLoc, {
"Output"
,
"/Event/Test/StringView"
} } {}
28
29
std::string
operator()
()
const override
{
return
"Hello World"
; }
30
};
31
DECLARE_COMPONENT
(
ProduceStringView
)
32
33
struct
ProduceIntView
34
:
Gaudi
::Functional::Producer<
std
::
vector
<
int
>(),
writeViewFor
<
std
::
vector
<
int
>, gsl::span<const
int
>>> {
35
ProduceIntView
(
const
std::string& name,
ISvcLocator
* svcLoc )
36
: Producer{ name, svcLoc, {
"Output"
,
"/Event/Test/IntView"
} } {}
37
38
std::vector<int>
operator()
()
const override
{
39
std::vector<int> vi{ 1, 2, 3, 5, 8, 13, 21, 34 };
40
info() <<
"made vector with data at : "
<< vi.data() <<
endmsg
;
41
return
vi;
42
}
43
};
44
DECLARE_COMPONENT
(
ProduceIntView
)
45
46
struct
GetStringView
:
Gaudi
::Functional::Consumer<
void
(
std
::string_view const& ),
BaseClass_t
> {
47
GetStringView
(
const
std::string& name,
ISvcLocator
* svcLoc )
48
: Consumer{ name, svcLoc, {
"Input"
,
"/Event/Test/StringView"
} } {}
49
50
void
operator()
(
const
std::string_view& sv )
const override
{ info() << sv <<
endmsg
; }
51
};
52
DECLARE_COMPONENT
(
GetStringView
)
53
54
struct
GetIntView
:
Gaudi
::Functional::Consumer<
void
( gsl::span<const
int
> const& ),
BaseClass_t
> {
55
GetIntView
(
const
std::string& name,
ISvcLocator
* svcLoc )
56
: Consumer{ name, svcLoc, {
"Input"
,
"/Event/Test/IntView"
} } {}
57
58
void
operator()
(
const
gsl::span<const int>& view )
const override
{
59
info() <<
"got a span with data at : "
<< view.data() <<
endmsg
;
60
auto
& out = info();
61
for
(
int
i : view ) out << i <<
" "
;
62
out <<
endmsg
;
63
}
64
};
65
DECLARE_COMPONENT
(
GetIntView
)
writeViewFor
Gaudi::Functional::Traits::use_< Gaudi::Functional::Traits::writeViewFor< Data, View >, BaseClass_t > writeViewFor
Definition
AnyViewAlgorithm.cpp:23
BaseClass_t
Gaudi::Functional::Traits::BaseClass_t< Gaudi::Algorithm > BaseClass_t
Definition
AnyViewAlgorithm.cpp:20
Consumer.h
DataObjectHandle.h
Algorithm.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
Producer.h
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition
ISvcLocator.h:42
vector
STL class.
Gaudi::Functional::Producer
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Definition
Producer.h:37
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition
__init__.py:1
std
STL namespace.
Gaudi::Functional::Traits::BaseClass_t
Definition
utilities.h:36
Gaudi::Functional::Traits::use_
Definition
utilities.h:32
GetIntView
Definition
AnyViewAlgorithm.cpp:54
GetIntView::GetIntView
GetIntView(const std::string &name, ISvcLocator *svcLoc)
Definition
AnyViewAlgorithm.cpp:55
GetIntView::operator()
void operator()(const gsl::span< const int > &view) const override
Definition
AnyViewAlgorithm.cpp:58
GetStringView
Definition
AnyViewAlgorithm.cpp:46
GetStringView::operator()
void operator()(const std::string_view &sv) const override
Definition
AnyViewAlgorithm.cpp:50
GetStringView::GetStringView
GetStringView(const std::string &name, ISvcLocator *svcLoc)
Definition
AnyViewAlgorithm.cpp:47
ProduceIntView
Definition
AnyViewAlgorithm.cpp:34
ProduceIntView::ProduceIntView
ProduceIntView(const std::string &name, ISvcLocator *svcLoc)
Definition
AnyViewAlgorithm.cpp:35
ProduceIntView::operator()
std::vector< int > operator()() const override
Definition
AnyViewAlgorithm.cpp:38
ProduceStringView
Definition
AnyViewAlgorithm.cpp:25
ProduceStringView::ProduceStringView
ProduceStringView(const std::string &name, ISvcLocator *svcLoc)
Definition
AnyViewAlgorithm.cpp:26
ProduceStringView::operator()
std::string operator()() const override
Definition
AnyViewAlgorithm.cpp:29
GaudiTestSuite
src
AnyData
AnyViewAlgorithm.cpp
Generated on
for The Gaudi Framework by
1.17.0