Project
Loading...
Searching...
No Matches
Plugins.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_PLUGINS_H_
12#define O2_FRAMEWORK_PLUGINS_H_
13
15#include <string>
16
17namespace o2::framework
18{
19
20enum struct DplPluginKind : int {
21 // A plugin which can customise the workflow. Needs to return
22 // an object of kind o2::framework::WorkflowCustomizationService
24 // A plugin which implements a ImGUI GUI. Needs to return an
25 // object of the kind o2::framework::DebugGUIImpl
27 // A plugin which implements a custom Services. Needs to return
28 // an object of the kind o2::framework::ServiceSpec
30 // A plugin which implements a new way to discover extra configuration.
31 // parameters. E.g. it can be used to read metadata from a file or a service
32 // if a certain parameter is available.
34 // A capability plugin is a plugin used to discover other viable plugins.
35 // For example, if you find out that you have the --aod-file option
36 // set, you might want to load metadata from it and attach it to the
37 // configuration.
39 // A RootObjectReadingCapability is used to discover if there is away
40 // to read and understand an object serialised with ROOT.
42
43 // A RootObjectReadingImplementation is actually used to read said object
44 // using the arrow dataset API
46
47 // A plugin which was not initialised properly.
49};
50
54template <typename T>
56 // How to load the given service.
57 std::string loadSpec;
58
59 void setInstance(T* instance_)
60 {
61 ptr = instance_;
62 }
63
64 T& operator*() const
65 {
66 return ptr;
67 }
68
69 T* operator->() const
70 {
71 return ptr;
72 }
73
74 T* get() const
75 {
76 return ptr;
77 }
78
79 void reset()
80 {
81 delete ptr;
82 ptr = nullptr;
83 }
84
85 T* ptr = nullptr;
86};
87
88} // namespace o2::framework
89
98
99#define DEFINE_DPL_PLUGIN(NAME, KIND) \
100 extern "C" { \
101 DPLPluginHandle* dpl_plugin_callback(DPLPluginHandle* previous) \
102 { \
103 return new DPLPluginHandle{new NAME{}, strdup(#NAME), o2::framework::DplPluginKind::KIND, previous}; \
104 } \
105 }
106
107#define DEFINE_DPL_PLUGINS_BEGIN \
108 extern "C" { \
109 DPLPluginHandle* dpl_plugin_callback(DPLPluginHandle* previous) \
110 {
111
112#define DEFINE_DPL_PLUGIN_INSTANCE(NAME, KIND) \
113 previous = new DPLPluginHandle{new NAME{}, strdup(#NAME), o2::framework::DplPluginKind::KIND, previous};
114
115#define DEFINE_DPL_PLUGINS_END \
116 return previous; \
117 } \
118 }
119
120#endif // O2_FRAMEWORK_PLUGINS_H_
GLuint const GLchar * name
Definition glcorearb.h:781
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
void * instance
Definition Plugins.h:93
DPLPluginHandle * previous
Definition Plugins.h:96
enum o2::framework::DplPluginKind kind
Definition Plugins.h:95
void setInstance(T *instance_)
Definition Plugins.h:59