CLAM-Development  1.4.0
ControlPrinter.cxx
Go to the documentation of this file.
1 #include "ControlPrinter.hxx"
2 #include <iostream>
3 #include <sstream>
4 #include "ProcessingFactory.hxx"
5 
6 
7 namespace CLAM
8 {
9 namespace Hidden
10 {
11  static const char * metadata[] = {
12  "key", "ControlPrinter",
13  "category", "Controls",
14  "description", "ControlPrinter",
15  "control_display_type", typeid(TControlData).name(),
16  0
17  };
18  static FactoryRegistrator<ProcessingFactory, ControlPrinter> reg = metadata;
19 }
20 
21  void ControlPrinterConfig::DefaultInit()
22  {
23  AddAll();
24  UpdateData();
25  SetIdentifier( "ControlPrinter" );
26  SetNumberOfInputs(1.);
27  SetGuiOnly(true);
28  }
29 
31  {
32  Configure( mConfig );
33  }
34 
36  {
37  Configure( cfg );
38  }
40  {
42  }
43 
45  {
47 
48  CopyAsConcreteConfig( mConfig, cfg );
49 
50  mConfig.AddAll();
51  mConfig.UpdateData();
52 
53  int nInputs = int(mConfig.GetNumberOfInputs());
54  if (nInputs < 1)
55  {
56  mConfig.SetNumberOfInputs(1.);
57  nInputs = 1;
58  }
59  if (nInputs == 1)
60  {
61  // preserve old port name
62  std::list<std::string> names;
63  names.push_back("In Control");
64  mInControls.Resize(1, names, this);
65  }
66  else
67  {
68  // multi-port names share user-configured identifier
69  mInControls.Resize(nInputs,
70  mConfig.GetIdentifier(), this);
71  }
72 
73 
74  return true;
75  }
76 
78  {
79  if (mConfig.GetGuiOnly())
80  return true;
81 
82  std::string separator = "";
83  std::stringstream values;
84  for (int i = 0; i < mInControls.Size(); i++)
85  {
86  values << separator << mInControls[i].GetLastValue();
87  separator = ", ";
88  }
89  std::cout << mConfig.GetIdentifier() << ": "
90  << values.str() << std::endl;
91  return true;
92  }
93 
95  {
96  mInControls.Clear();
97  GetInControls().Clear();
98  }
99 }
100