Nymph  v1.5.2
Flow-Based Data Processing Framework
KTRunNymph.cc
Go to the documentation of this file.
1 /*
2  * RunNymph.cc
3  *
4  * Created on: Sep 13, 2016
5  * Author: obla999
6  */
7 
8 #include "KTApplication.hh"
9 #include "KTLogger.hh"
10 #include "KTProcessorToolbox.hh"
11 
12 #include "param.hh"
13 
14 #include <string>
15 
16 KTLOGGER( nlog, "RunNymph" );
17 
18 namespace Nymph
19 {
20  int RunNymph( std::shared_ptr< KTApplication > app )
21  {
22  try
23  {
24  const scarab::param_node& parentConfigNode = app->GetConfigurator()->Config();
25 
26  if( ! app->Configure( parentConfigNode[app->GetConfigName()].as_node() ) )
27  {
28  KTERROR( nlog, "Unable to configure the application. Aborting." );
29  return -2;
30  }
31 
32  // Create and configure the processor toolbox.
33  // This will create all of the requested processors, connect their signals and slots, and fill the run queue.
34  KTProcessorToolbox procTB;
35 
36  if( ! procTB.Configure( parentConfigNode[procTB.GetConfigName()].as_node() ) )
37  {
38  KTERROR( nlog, "Unable to configure processor toolbox. Aborting." );
39  return -3;
40  }
41 
42  // Configure the processors
43  if( ! procTB.ConfigureProcessors( parentConfigNode ) )
44  {
45  KTERROR( nlog, "Unable to configure processors. Aborting." );
46  return -4;
47  }
48 
49  // Execute the run queue!
50  bool success = procTB.Run();
51 
52  procTB.ClearProcessors();
53 
54  KTPROG( nlog, "That's all, folks!" );
55 
56  if( ! success ) return -5;
57  return 0;
58  }
59  catch( std::exception& e )
60  {
61  KTERROR( nlog, "Exception caught:\n" << e.what() );
62  return -1;
63  }
64  }
65 }
int RunNymph(std::shared_ptr< KTApplication > app)
Definition: KTRunNymph.cc:20
Manages processors requested by the user at run time.
KTLOGGER(nlog, "RunNymph")
Contains KTApplication.
bool ConfigureProcessors(const scarab::param_node &node)
Configure processors (only those specified in the toolbox)
#define KTPROG(...)
Definition: KTLogger.hh:345
bool Configure(const scarab::param_node &node)
Configure the toolbox: create the processors; connnect signals and slots; and setup the run queue...
Contains KTProcessorToolbox.
const std::string & GetConfigName() const
#define KTERROR(...)
Definition: KTLogger.hh:347
Contains the logger class and macros, based on Kasper&#39;s KLogger class.