Nymph  v1.5.2
Flow-Based Data Processing Framework
TestSignalsAndSlots.cc
Go to the documentation of this file.
1 /*
2  * TestSignalsAndSlots.cc
3  *
4  * Created on: Aug 15, 2012
5  * Author: nsoblath
6  */
7 
8 
9 #include "KTTestProcessor.hh"
10 #include "KTLogger.hh"
11 
12 using namespace Nymph;
13 
14 KTLOGGER(testsiglog, "TestSignalsAndSlots")
15 
16 int main()
17 {
18 
19  KTTestProcessorA tpA;
20  KTTestProcessorB tpB;
21 
22  /* Basic Test
23  KTSignalWrapper* signalPtr = tpA.GetSignal("the_signal");
24  KTSlotWrapper* slot1Ptr = tpB.GetSlot("first_slot");
25 
26  slot1Ptr->SetConnection(signalPtr);
27 
28  tpA.EmitSignals(5);
29 
30  slot1Ptr->Disconnect();
31 
32  return 0;
33  */
34 
35  /* More Complicated Test */
36  KTINFO(testsiglog, "Connecting the_signal to first_slot and second_slot");
37  try
38  {
39  tpA.ConnectASlot("the_signal", &tpB, "first_slot", 20);
40  tpB.ConnectASignal(&tpA, "the_signal", "second_slot", 10);
41  }
42  catch(std::exception& e)
43  {
44  KTERROR(testsiglog, "A problem occurred while connecting the signal and slots:\n" << e.what());
45  return -1;
46  }
47 
48  KTINFO(testsiglog, "Emitting signals");
49  KTINFO(testsiglog, "First test signal: 5");
50  tpA.EmitSignals(5);
51  KTINFO(testsiglog, "Second test signal: 18");
52  tpA.EmitSignals(18);
53 
54  KTINFO(testsiglog, "Tests complete");
55  return 0;
56 
57 }
58 
#define KTINFO(...)
Definition: KTLogger.hh:344
void ConnectASignal(KTProcessor *processor, const std::string &signalName, const std::string &slotName, int groupNum=-1)
Definition: KTProcessor.cc:70
KTLOGGER(applog, "KTApplication")
void ConnectASlot(const std::string &signalName, KTProcessor *processor, const std::string &slotName, int groupNum=-1)
Definition: KTProcessor.cc:47
int main()
#define KTERROR(...)
Definition: KTLogger.hh:347
Contains the logger class and macros, based on Kasper&#39;s KLogger class.