All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
sbn_static.cxx File Reference
#include <fstream>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <vector>
#include <dlfcn.h>
#include <fhiclcpp/ParameterSet.h>
#include <core/ProcessorBase.hh>
#include <core/ProcessorBlock.hh>

Go to the source code of this file.

Functions

core::ProcessorBaseCreateProcessorObject ()
 
void DestroyProcessorObject (core::ProcessorBase *proc)
 
core::export_tableLoadProcessor ()
 
int main (int argc, char *argv[])
 

Variables

struct core::export_table exports
 

Function Documentation

core::ProcessorBase* CreateProcessorObject ( )
void DestroyProcessorObject ( core::ProcessorBase proc)
core::export_table* LoadProcessor ( )
inline

Load a Processor.

Definition at line 20 of file sbn_static.cxx.

20  {
21  return &exports;
22 }
struct core::export_table exports
int main ( int  argc,
char *  argv[] 
)

Definition at line 25 of file sbn_static.cxx.

25  {
26  // Parse command line arguments
27  std::vector<char*> config_names;
28 
29  int c;
30  while ((c=getopt(argc, argv, "c:")) != -1) {
31  switch (c) {
32  case 'c':
33  config_names.push_back(optarg);
34  break;
35  case '?':
36  if (optopt == 'c')
37  fprintf(stderr, "Option -%c requires an argument.\n", optopt);
38  else if (isprint(optopt))
39  fprintf(stderr, "Unknown option `-%c'.\n", optopt);
40  else
41  fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
42  return 1;
43  default:
44  abort();
45  }
46  }
47 
48  if (argc - optind < 1) {
49  std::cout << "Usage: " << argv[0] << " [-c [Config]] "
50  << "INPUTDEF [...]" << std::endl;
51  return 0;
52  }
53 
54  // Process input file definition
55  std::vector<std::string> filenames;
56  for (int i=optind; i<argc; i++) {
57  filenames.push_back(argv[i]);
58  }
59  assert(!filenames.empty());
60 
61  // Setup
62  int n_processors = config_names.empty() ? 1 : config_names.size();
63  std::vector<fhicl::ParameterSet*> configs(n_processors);
64  std::vector<core::ProcessorBase*> procs(n_processors);
65 
66  std::cout << "Configuring... " << std::endl;
67  for (size_t i=0; i<n_processors; i++) {
68  procs[i] = LoadProcessor()->create();
69  configs[i] = config_names.empty() ? NULL : core::LoadConfig(config_names[i]);
70  }
71 
73  for (int i=0; i<procs.size(); i++) {
74  block.AddProcessor(procs[i], configs[i]);
75  }
76 
77  std::cout << "Running... " << std::endl;
78  block.ProcessFiles(filenames);
79 
80  block.DeleteProcessors();
81  std::cout << "Done!" << std::endl;
82 
83  return 0;
84 }
process_name WireCellLarsoft configs
A set of Processors.
ProcessorBase *(* create)(void)
Definition: Loader.hh:30
virtual void DeleteProcessors()
core::export_table * LoadProcessor()
Definition: sbn_static.cxx:20
fhicl::ParameterSet * LoadConfig(char *configfile)
Definition: Loader.cxx:80
virtual void ProcessFiles(std::vector< std::string > filenames)
virtual void AddProcessor(ProcessorBase *processor, fhicl::ParameterSet *config)
BEGIN_PROLOG could also be cout

Variable Documentation

struct core::export_table exports