Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
apps
test
test_dlopen.cxx
Go to the documentation of this file.
1
#include "
WireCellIface/IWireParameters.h
"
2
3
#include "
WireCellUtil/Singleton.h
"
4
#include "
WireCellUtil/PluginManager.h
"
5
#include "
WireCellUtil/NamedFactory.h
"
6
#include "
WireCellUtil/Testing.h
"
7
8
#include <dlfcn.h>
9
10
#include <iostream>
11
using namespace
std
;
12
using namespace
WireCell
;
13
14
int
main
()
15
{
16
PluginManager
&
pm
=
PluginManager::instance
();
17
Plugin
* gen_plug = pm.
add
(
"WireCellGen"
);
18
Assert
(gen_plug);
19
20
21
typedef
NamedFactoryRegistry<IWireParameters>
IWPFactoryRegistry;
22
IWPFactoryRegistry* iwp1 = &
Singleton< IWPFactoryRegistry >::Instance
();
23
IWPFactoryRegistry* iwp2 = &
Singleton< IWPFactoryRegistry >::Instance
();
24
Assert
(iwp1);
25
Assert
(iwp2);
26
Assert
(iwp1 == iwp2);
27
28
cerr <<
"Looking up WireParams factory in NFR: "
<< iwp1 <<
endl
;
29
auto
inst1 = iwp1->lookup_factory(
"WireParams"
);
30
auto
inst2 = iwp1->lookup_factory(
"WireParams"
);
31
32
Assert
(inst1);
33
Assert
(inst2);
34
Assert
(inst1 == inst2);
35
36
cerr <<
"Looking up WireParams factory \n"
;
37
auto
factory = Factory::lookup_factory<IWireParameters>(
"WireParams"
);
38
Assert
(factory);
39
40
cerr <<
"Looking up WireParams:\n"
;
41
auto
wp1 = Factory::lookup<IWireParameters>(
"WireParams"
);
42
Assert
(wp1);
43
cerr <<
"Looking up WireParams, again:\n"
;
44
auto
wp2 = Factory::lookup<IWireParameters>(
"WireParams"
);
45
Assert
(wp2);
46
cerr <<
"Looking up undefined WireParams\n"
;
47
auto
wp3 = Factory::lookup<IWireParameters>(
"WireParams"
,
"MyWireParameters"
);
48
Assert
(wp3);
49
50
Assert
(wp2 == wp1);
51
Assert
(wp3 != wp1);
52
53
return
0;
54
}
55
56
NamedFactory.h
instance
const std::string instance
Definition:
BlipMaker_module.cc:27
std
STL namespace.
WireCell::Plugin
Definition:
PluginManager.h:11
WireCell::Singleton
Definition:
Singleton.h:7
Assert
#define Assert
Definition:
Testing.h:7
Singleton.h
Testing.h
IWireParameters.h
WireCell
Definition:
Main.h:22
PluginManager.h
WireCell::NamedFactoryRegistry
Definition:
NamedFactory.h:71
WireCell::PluginManager::add
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
Definition:
PluginManager.cxx:32
main
int main()
Definition:
test_dlopen.cxx:14
ResimTags.pm
pm
Definition:
ResimTags.py:94
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
WireCell::PluginManager
Definition:
PluginManager.h:32
Generated by
1.8.11