All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Loader.hh
Go to the documentation of this file.
1 #ifndef __sbnanalysis_core_Loader__
2 #define __sbnanalysis_core_Loader__
3 
4 /**
5  * \file Loader.hh
6  *
7  * Loading Processors from shared libraries.
8  *
9  * Author: A. Mastbaum <mastbaum@uchicago.edu>, 2018/02/05
10  */
11 
12 #include <string>
13 #include <vector>
14 
15 namespace fhicl {
16  class ParameterSet;
17 }
18 
19 namespace core {
20 
21 class ProcessorBase;
22 class PostProcessorBase;
23 
24 /**
25  * \struct export_table
26  * \brief Struct containing (macro defined) creation/deletion operations
27  */
28 struct export_table {
29  /** Function to create an Processor instance. */
30  ProcessorBase* (*create)(void);
31 
32  /** Function to delete an Processor instance. */
34 };
35 
36 /**
37  * \struct export_table_postprocess
38  * \brief Struct containing (macro defined) creation/deletion operations
39  */
41  /** Function to create an PostProcessor instance. */
42  PostProcessorBase* (*create)(void);
43 
44  /** Function to delete an PostProcessor instance. */
46 };
47 
48 /**
49  * Load a processor from a shared library.
50  *
51  * \param libpath Path to the shared library
52  * \returns A table of exported hooks for creating/deleting instances
53  */
54 export_table* LoadProcessor(char* libname);
55 
56 /**
57  * Load a post-processor from a shared library.
58  *
59  * \param libpath Path to the shared library
60  * \returns A table of exported hooks for creating/deleting instances
61  */
63 
64 
65 /**
66  * Load configuration from JSON file to object.
67  *
68  * \param config Path to the JSON file
69  * \returns Configuration as a JSON object
70  */
71 fhicl::ParameterSet* LoadConfig(char* configfile);
72 
73 
74 /**
75  * \class ProcessorDef
76  * \brief Definition for a dynamically-loaded Processor
77  */
78 struct ProcessorDef {
79  char* name; //!< Name of the Processor
80  struct export_table* exports; //!< Table for ctor/dtor access
81  fhicl::ParameterSet* config; //!< Configuration as an object
82  core::ProcessorBase* proc; //!< Pointer to the processor
83 };
84 
85 } // namespace core
86 
87 #endif // __sbnanalysis_core_Loader__
88 
Definition for a dynamically-loaded Processor.
Definition: Loader.hh:78
Struct containing (macro defined) creation/deletion operations.
Definition: Loader.hh:28
void(* destroy)(ProcessorBase *)
Definition: Loader.hh:33
char * name
Name of the Processor.
Definition: Loader.hh:79
export_table * LoadProcessor(char *libname)
Definition: Loader.cxx:15
export_table_postprocess * LoadPostProcessor(char *libname)
Definition: Loader.cxx:47
void(* destroy)(PostProcessorBase *)
Definition: Loader.hh:45
A generic tree-writing event-by-event processor.
fhicl::ParameterSet * config
Configuration as an object.
Definition: Loader.hh:81
j template void())
Definition: json.hpp:3108
fhicl::ParameterSet * LoadConfig(char *configfile)
Definition: Loader.cxx:80
core::ProcessorBase * proc
Pointer to the processor.
Definition: Loader.hh:82
A generic tree-reading event-by-event processor.
Struct containing (macro defined) creation/deletion operations.
Definition: Loader.hh:40
struct export_table * exports
Table for ctor/dtor access.
Definition: Loader.hh:80