ATLAS Offline Software
Loading...
Searching...
No Matches
TPCnvFactory.h File Reference

Set up plugin loading of TP converters. More...

#include "Gaudi/PluginService.h"
Include dependency graph for TPCnvFactory.h:

Go to the source code of this file.

Classes

struct  Athena::TPCnvVers
struct  Athena::TPCnvType

Namespaces

namespace  Athena
 Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc.h and will be non-nullptr in case the GaudiSvc/AthenaKernel shared libraries have been loaded.

Macros

#define DO_ATHTPCNV_FACTORY_REGISTER_CNAME(name, serial)
#define DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, cnv_type, signature, serial)
#define DO_ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, cnv_type, signature, serial)
#define ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, signature)
#define TRIGTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, signature)
#define ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, signature)
#define TRIGTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, signature)
#define DECLARE_TPCNV_FACTORY(x, trans_type, pers_type, is_last_version)
#define DECLARE_TRIGTPCNV_FACTORY(x, trans_type, pers_type, is_last_version)
#define DECLARE_NAMED_TPCNV_FACTORY(x, n, trans_type, pers_type, is_last_version)
#define DECLARE_NAMED_TRIGTPCNV_FACTORY(x, n, trans_type, pers_type, is_last_version)

Detailed Description

Set up plugin loading of TP converters.

Author
scott snyder, S. Binet

The definitions here are used to allow loading the TP converters directly via the Gaudi plugin mechanism.

Usage

In a TPCnv package, create a source file with the same name as the package, add add this to your requirements file:

apply_pattern tpcnv_library

That file should contain a declaration like this for each TP converter:

#include "FooTPCnv/FooCnv_p2.h"
Foo,
Foo_p2,
Set up plugin loading of TP converters.
#define DECLARE_TPCNV_FACTORY(x, trans_type, pers_type, is_last_version)
Definition FooBar.h:9

The first three arguments should be the converter class, the transient class, and the persistent class, respectively. The fourth argument should be Athena::TPCnvVers::Current if this is the most recent version of the converter. You should also declare previous versions of the converter, using Old:

#include "FooTPCnv/FooCnv_p1.h"
Foo,
Foo_p1,

There is a separate macro DECLARE_TRIGTPCNV_FACTORY to allow declaring separate converters to use for the trigger.

Finally, in some cases you may need to use a different name for the plugin than the C++ class name. This is generally the case if the converter class is actually a typedef. In that case, use DECLARE_NAMED_TPCNV_FACTORY:

#include "FooTPCnv/BarCnv_p2.h"
// BarCnv_p2 is actually a typedef.
BarCnv_p2,
Bar,
Bar_p2,
#define DECLARE_NAMED_TPCNV_FACTORY(x, n, trans_type, pers_type, is_last_version)
Definition FooBar.h:27

Implementation

The implementation is very simple. Let the converter, transient, and persistent types be C, T, and P, respectively. We always make plugin entries for C and _PERS_P. If the converter is current, we also make an entry for _TRANS_T. If the converter is for _TRIG, we add _TRIG to the front of the pers and trans names.

Thus, to find the correct converter for a transient class, we look up _TRANS_T; and for a persistent class we look up _PERS_P. For TRIG, we first try the look up with _TRIG in front of those names. To get the transient class name corresponding to a persistent class, we create an instance of the converter and use the transientTInfo interface. No registry is needed beyond the existing Gaudi plugin registry.

One limitation: if you have multiple transient classes that use the same persistent class, you'll get warnings from the plugin service.

Definition in file TPCnvFactory.h.

Macro Definition Documentation

◆ ATHTPCNV_PLUGINSVC_FACTORY

#define ATHTPCNV_PLUGINSVC_FACTORY ( type,
trans_type,
pers_type,
is_last_version,
signature )
Value:
DO_ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, Athena::TPCnvType::Athena, signature, __LINE__)
#define DO_ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, cnv_type, signature, serial)

Definition at line 149 of file TPCnvFactory.h.

149#define ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, signature) \
150 DO_ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, Athena::TPCnvType::Athena, signature, __LINE__)

◆ ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID

#define ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID ( type,
id,
trans_type,
pers_type,
is_last_version,
signature )
Value:
DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, Athena::TPCnvType::Athena, signature, __LINE__)
#define DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, cnv_type, signature, serial)

Definition at line 154 of file TPCnvFactory.h.

154#define ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, signature) \
155 DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, Athena::TPCnvType::Athena, signature, __LINE__)

◆ DECLARE_NAMED_TPCNV_FACTORY

#define DECLARE_NAMED_TPCNV_FACTORY ( x,
n,
trans_type,
pers_type,
is_last_version )
Value:
ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(x,std::string(#n), trans_type,pers_type, is_last_version, ITPCnvBase*())
#define ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, signature)
#define x

Definition at line 171 of file TPCnvFactory.h.

171#define DECLARE_NAMED_TPCNV_FACTORY(x,n,trans_type,pers_type,is_last_version) \
172 ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(x,std::string(#n), trans_type,pers_type, is_last_version, ITPCnvBase*())

◆ DECLARE_NAMED_TRIGTPCNV_FACTORY

#define DECLARE_NAMED_TRIGTPCNV_FACTORY ( x,
n,
trans_type,
pers_type,
is_last_version )
Value:
TRIGTPCNV_PLUGINSVC_FACTORY_WITH_ID(x,std::string(#n), trans_type,pers_type, is_last_version, ITPCnvBase*())
#define TRIGTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, signature)

Definition at line 174 of file TPCnvFactory.h.

174#define DECLARE_NAMED_TRIGTPCNV_FACTORY(x,n,trans_type,pers_type,is_last_version) \
175 TRIGTPCNV_PLUGINSVC_FACTORY_WITH_ID(x,std::string(#n), trans_type,pers_type, is_last_version, ITPCnvBase*())

◆ DECLARE_TPCNV_FACTORY

#define DECLARE_TPCNV_FACTORY ( x,
trans_type,
pers_type,
is_last_version )
Value:
ATHTPCNV_PLUGINSVC_FACTORY(x,trans_type,pers_type,is_last_version,ITPCnvBase*())
#define ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, signature)

Definition at line 165 of file TPCnvFactory.h.

165#define DECLARE_TPCNV_FACTORY(x,trans_type,pers_type,is_last_version) \
166 ATHTPCNV_PLUGINSVC_FACTORY(x,trans_type,pers_type,is_last_version,ITPCnvBase*())

◆ DECLARE_TRIGTPCNV_FACTORY

#define DECLARE_TRIGTPCNV_FACTORY ( x,
trans_type,
pers_type,
is_last_version )
Value:
TRIGTPCNV_PLUGINSVC_FACTORY(x,trans_type,pers_type,is_last_version,ITPCnvBase*())
#define TRIGTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, signature)

Definition at line 168 of file TPCnvFactory.h.

168#define DECLARE_TRIGTPCNV_FACTORY(x,trans_type,pers_type,is_last_version) \
169 TRIGTPCNV_PLUGINSVC_FACTORY(x,trans_type,pers_type,is_last_version,ITPCnvBase*())

◆ DO_ATHTPCNV_FACTORY_REGISTER_CNAME

#define DO_ATHTPCNV_FACTORY_REGISTER_CNAME ( name,
serial )
Value:
_register_ ## _ ## serial

Definition at line 117 of file TPCnvFactory.h.

117#define DO_ATHTPCNV_FACTORY_REGISTER_CNAME(name, serial) \
118 _register_ ## _ ## serial

◆ DO_ATHTPCNV_PLUGINSVC_FACTORY

#define DO_ATHTPCNV_PLUGINSVC_FACTORY ( type,
trans_type,
pers_type,
is_last_version,
cnv_type,
signature,
serial )
Value:
DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, ::Gaudi::PluginService::Details::demangle<type>(), trans_type, pers_type, is_last_version, cnv_type, signature, serial)

Definition at line 144 of file TPCnvFactory.h.

144#define DO_ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, cnv_type, signature, serial) \
145 DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, ::Gaudi::PluginService::Details::demangle<type>(), trans_type, pers_type, is_last_version, cnv_type, signature, serial)

◆ DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID

#define DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID ( type,
id,
trans_type,
pers_type,
is_last_version,
cnv_type,
signature,
serial )
Value:
namespace { \
DO_ATHTPCNV_FACTORY_REGISTER_CNAME( type, serial )() \
{ \
using ::Gaudi::PluginService::DeclareFactory; \
std::string prefix; \
if (cnv_type == Athena::TPCnvType::Trigger) \
prefix = "_TRIG"; \
DeclareFactory<type> normal{}; \
if (is_last_version == Athena::TPCnvVers::Current) \
DeclareFactory<type> transient{prefix + "_TRANS_" + #trans_type}; \
DeclareFactory<type> persistent{prefix + "_PERS_" + #pers_type}; \
} \
} DO_ATHTPCNV_FACTORY_REGISTER_CNAME(s_ ## type, serial); \
}
#define DO_ATHTPCNV_FACTORY_REGISTER_CNAME(name, serial)

Definition at line 126 of file TPCnvFactory.h.

126#define DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, cnv_type, signature, serial) \
127 namespace { \
128 struct DO_ATHTPCNV_FACTORY_REGISTER_CNAME( type, serial ) { \
129 DO_ATHTPCNV_FACTORY_REGISTER_CNAME( type, serial )() \
130 { \
131 using ::Gaudi::PluginService::DeclareFactory; \
132 std::string prefix; \
133 if (cnv_type == Athena::TPCnvType::Trigger) \
134 prefix = "_TRIG"; \
135 DeclareFactory<type> normal{}; \
136 if (is_last_version == Athena::TPCnvVers::Current) \
137 DeclareFactory<type> transient{prefix + "_TRANS_" + #trans_type}; \
138 DeclareFactory<type> persistent{prefix + "_PERS_" + #pers_type}; \
139 } \
140 } DO_ATHTPCNV_FACTORY_REGISTER_CNAME(s_ ## type, serial); \
141 }

◆ TRIGTPCNV_PLUGINSVC_FACTORY

#define TRIGTPCNV_PLUGINSVC_FACTORY ( type,
trans_type,
pers_type,
is_last_version,
signature )
Value:
DO_ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, Athena::TPCnvType::Trigger, signature, __LINE__)

Definition at line 151 of file TPCnvFactory.h.

151#define TRIGTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, signature) \
152 DO_ATHTPCNV_PLUGINSVC_FACTORY(type, trans_type, pers_type, is_last_version, Athena::TPCnvType::Trigger, signature, __LINE__)

◆ TRIGTPCNV_PLUGINSVC_FACTORY_WITH_ID

#define TRIGTPCNV_PLUGINSVC_FACTORY_WITH_ID ( type,
id,
trans_type,
pers_type,
is_last_version,
signature )
Value:
DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, Athena::TPCnvType::Trigger, signature, __LINE__)

Definition at line 156 of file TPCnvFactory.h.

156#define TRIGTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, signature) \
157 DO_ATHTPCNV_PLUGINSVC_FACTORY_WITH_ID(type, id, trans_type, pers_type, is_last_version, Athena::TPCnvType::Trigger, signature, __LINE__)