Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
srcs
sbnana
sbnanalysis
core
Loader.cxx
Go to the documentation of this file.
1
#include <cstdio>
2
#include <cstdlib>
3
#include <fstream>
4
#include <string>
5
#include <vector>
6
#include <dlfcn.h>
7
#include <cetlib/filepath_maker.h>
8
#include <fhiclcpp/make_ParameterSet.h>
9
#include <fhiclcpp/ParameterSet.h>
10
#include <
core/ProcessorBase.hh
>
11
#include <
core/ProcessorBlock.hh
>
12
13
namespace
core {
14
15
export_table
*
LoadProcessor
(
char
* libname) {
16
std::cout
<<
"Loading processor: "
<< libname <<
"... "
;
17
18
char
* libdir = getenv(
"SBN_LIB_DIR"
);
19
char
libpath[1000];
20
snprintf(libpath, 1000,
"%s/libsbnanalysis_%s.so"
, libdir, libname);
21
22
void
* handle = dlopen(libpath, RTLD_NOW);
23
if
(!handle) {
24
std::cout
<<
"ERROR"
<< std::endl;
25
std::cerr
<<
"Error loading processor "
<< libname <<
": \n\n"
26
<< dlerror()
27
<<
"\n\nSBN_LIB_DIR = "
<< libdir
28
<< std::endl;
29
exit
(1);
30
}
31
32
export_table
*
exports
= (
export_table
*) dlsym(handle,
"exports"
);
33
34
if
(exports) {
35
std::cout
<<
"OK"
<< std::endl;
36
}
37
else
{
38
std::cout
<<
"ERROR"
<< std::endl;
39
std::cerr
<<
"Invalid library "
<< libpath <<
". "
40
<<
"Not a Processor?"
<< std::endl;
41
exit
(1);
42
}
43
44
return
exports
;
45
}
46
47
export_table_postprocess
*
LoadPostProcessor
(
char
* libname) {
48
std::cout
<<
"Loading post-processor: "
<< libname <<
"... "
;
49
50
char
* libdir = getenv(
"SBN_LIB_DIR"
);
51
char
libpath[1000];
52
snprintf(libpath, 1000,
"%s/libsbnanalysis_%s.so"
, libdir, libname);
53
54
void
* handle = dlopen(libpath, RTLD_NOW);
55
if
(!handle) {
56
std::cout
<<
"ERROR"
<< std::endl;
57
std::cerr
<<
"Error loading post-processor "
<< libname <<
": \n\n"
58
<< dlerror()
59
<<
"\n\nSBN_LIB_DIR = "
<< libdir
60
<< std::endl;
61
exit
(1);
62
}
63
64
export_table_postprocess
*
exports
= (
export_table_postprocess
*) dlsym(handle,
"exports"
);
65
66
if
(exports) {
67
std::cout
<<
"OK"
<< std::endl;
68
}
69
else
{
70
std::cout
<<
"ERROR"
<< std::endl;
71
std::cerr
<<
"Invalid library "
<< libpath <<
". "
72
<<
"Not a PostProcessor?"
<< std::endl;
73
exit
(1);
74
}
75
76
return
exports
;
77
}
78
79
80
fhicl::ParameterSet*
LoadConfig
(
char
* configfile) {
81
fhicl::ParameterSet* config = NULL;
82
83
if
(configfile) {
84
std::cout
<<
"Loading configuration: "
<< configfile <<
"... "
;
85
config =
new
fhicl::ParameterSet;
86
cet::filepath_lookup_nonabsolute maker(
"FHICL_FILE_PATH"
);
87
fhicl::make_ParameterSet(configfile, maker, *config);
88
std::cout
<<
"OK"
<< std::endl;
89
}
90
91
return
config;
92
}
93
94
}
// namespace core
95
core::export_table
Struct containing (macro defined) creation/deletion operations.
Definition:
Loader.hh:28
cerr
BEGIN_PROLOG could also be cerr
Definition:
messageservice.fcl:10
exit
exit
Definition:
generate_icarus_geometry_splitwire.pl:430
core::LoadProcessor
export_table * LoadProcessor(char *libname)
Definition:
Loader.cxx:15
ProcessorBlock.hh
core::LoadPostProcessor
export_table_postprocess * LoadPostProcessor(char *libname)
Definition:
Loader.cxx:47
exports
struct core::export_table exports
ProcessorBase.hh
core::LoadConfig
fhicl::ParameterSet * LoadConfig(char *configfile)
Definition:
Loader.cxx:80
core::export_table_postprocess
Struct containing (macro defined) creation/deletion operations.
Definition:
Loader.hh:40
cout
BEGIN_PROLOG could also be cout
Definition:
messageservice.fcl:10
Generated by
1.8.5