Functions
test_dlopen.cxx File Reference
#include "WireCellIface/IWireParameters.h"
#include "WireCellUtil/Singleton.h"
#include "WireCellUtil/PluginManager.h"
#include "WireCellUtil/NamedFactory.h"
#include "WireCellUtil/Testing.h"
#include <dlfcn.h>
#include <iostream>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( void  )

Definition at line 14 of file test_dlopen.cxx.

15 {
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 }
const std::string instance
#define Assert
Definition: Testing.h:7
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
QTextStream & endl(QTextStream &s)