Public Member Functions | Private Attributes | List of all members
WireCellApps::ConfigDumper Class Reference

#include <ConfigDumper.h>

Inheritance diagram for WireCellApps::ConfigDumper:
WireCell::IApplication WireCell::IConfigurable WireCell::IComponent< IApplication > WireCell::IComponent< IConfigurable > WireCell::Interface WireCell::Interface

Public Member Functions

 ConfigDumper ()
 
virtual ~ConfigDumper ()
 
virtual void execute ()
 Implement to run something. More...
 
virtual void configure (const WireCell::Configuration &config)
 Accept a configuration. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
- Public Member Functions inherited from WireCell::IApplication
virtual ~IApplication ()
 
- Public Member Functions inherited from WireCell::IComponent< IApplication >
virtual ~IComponent ()
 
- Public Member Functions inherited from WireCell::Interface
virtual ~Interface ()
 
- Public Member Functions inherited from WireCell::IConfigurable
virtual ~IConfigurable ()
 
- Public Member Functions inherited from WireCell::IComponent< IConfigurable >
virtual ~IComponent ()
 

Private Attributes

WireCell::Configuration m_cfg
 

Additional Inherited Members

- Public Types inherited from WireCell::IComponent< IApplication >
typedef std::shared_ptr< IApplicationpointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 
- Public Types inherited from WireCell::Interface
typedef std::shared_ptr< Interfacepointer
 
- Public Types inherited from WireCell::IComponent< IConfigurable >
typedef std::shared_ptr< IConfigurablepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 

Detailed Description

Definition at line 10 of file ConfigDumper.h.

Constructor & Destructor Documentation

ConfigDumper::ConfigDumper ( )

Definition at line 20 of file ConfigDumper.cxx.

22 {
23 }
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
WireCell::Configuration m_cfg
Definition: ConfigDumper.h:11
ConfigDumper::~ConfigDumper ( )
virtual

Definition at line 25 of file ConfigDumper.cxx.

26 {
27 }

Member Function Documentation

void ConfigDumper::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 29 of file ConfigDumper.cxx.

30 {
31  m_cfg = config;
32 }
static Config * config
Definition: config.cpp:1054
WireCell::Configuration m_cfg
Definition: ConfigDumper.h:11
WireCell::Configuration ConfigDumper::default_configuration ( ) const
virtual

Optional, override to return a hard-coded default configuration.

Reimplemented from WireCell::IConfigurable.

Definition at line 34 of file ConfigDumper.cxx.

35 {
36  // yo dawg, I heard you liked dumping so I made a dumper that dumps the dumper.
38  cfg["filename"] = "/dev/stdout";
39  cfg["components"] = Json::arrayValue;
40  return cfg;
41 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
void ConfigDumper::execute ( )
virtual

Implement to run something.

Implements WireCell::IApplication.

Definition at line 43 of file ConfigDumper.cxx.

44 {
46  int nfailed = 0;
47 
48  std::vector<std::string> comps;
49  for (auto jone : m_cfg["components"]) {
50  comps.push_back(jone.asString());
51  }
52  if (comps.empty()) {
53  comps = Factory::known_types<IConfigurable>();
54  }
55 
56  for (auto c : comps) {
57 
58  string type, name;
59  tie(type,name) = String::parse_pair(convert<string>(c));
60 
62  try {
63  auto cfgobj = Factory::lookup<IConfigurable>(type,name);
64  cfg = cfgobj->default_configuration();
65  }
66  catch (FactoryException& fe) {
67  warn("failed lookup component: \"{}\":\"{}\"", type, name);
68  ++nfailed;
69  continue;
70  }
71  cm.add(cfg, type, name);
72  }
73 
74  Persist::dump(get<string>(m_cfg, "filename"), cm.all());
75 }
static QCString name
Definition: declinfo.cpp:673
std::pair< std::string, std::string > parse_pair(const std::string &in, const std::string &delim=":")
Definition: String.cxx:15
cfg
Definition: dbjson.py:29
Configuration all() const
Return top-level, aggregate configuration.
Definition: ConfigManager.h:37
int add(Configuration &cfg)
WireCell::Configuration m_cfg
Definition: ConfigDumper.h:11
static QCString type
Definition: declinfo.cpp:672
Json::Value Configuration
Definition: Configuration.h:50
static const double cm
Definition: Units.h:76
void dump(const IFrame::pointer frame)
Definition: Fourdee.cxx:120

Member Data Documentation

WireCell::Configuration WireCellApps::ConfigDumper::m_cfg
private

Definition at line 11 of file ConfigDumper.h.


The documentation for this class was generated from the following files: