6 #include <CLAM/MIDIMessage.hxx>
13 "key",
"ControlPrinterTyped",
14 "category",
"Controls",
15 "description",
"ControlPrinterTyped",
18 static FactoryRegistrator<ProcessingFactory, ControlPrinterTyped>
reg =
metadata;
21 void ControlPrinterTypedConfig::DefaultInit()
25 SetIdentifier(
"ControlPrinterTyped" );
44 const unsigned int ControlPrinterTyped::GetInputsNumber()
const
48 typespec=_config.GetTypesMask();
49 for (nInputs=0; nInputs<typespec.size();nInputs++)
51 const char type = typespec[nInputs];
52 if (type !=
's' and type !=
'i'
53 and type !=
'f' and type !=
'd'
54 and type !=
'h' and type !=
'M')
60 void ControlPrinterTyped::ResizeControls(
unsigned nInputs,
const std::string & baseName)
62 std::list<std::string> names;
65 names.push_back(
"In Control");
66 ResizeControls(nInputs, names);
69 for (
unsigned i=0; i<nInputs; i++)
71 std::ostringstream os;
72 os << baseName <<
"_" << i;
73 names.push_back(os.str());
75 ResizeControls(nInputs, names);
77 InControlBase * ControlPrinterTyped::createControl(
const std::string & type,
const std::string & name)
80 return new InControl<std::string> (name,
this);
84 return new InControl<double> (name,
this);
86 return new InControl<int> (name,
this);
88 return new InControl<MIDI::Message> (name,
this);
92 void ControlPrinterTyped::ResizeControls(
unsigned nInputs,
const std::list<std::string> & names)
96 for (std::list<std::string>::const_iterator it = names.begin(); it != names.end(); it++)
99 type=_config.GetTypesMask()[i];
100 mInControls.push_back(createControl(type,*it));
104 void ControlPrinterTyped::ClearControls()
106 for (InControls::iterator it = mInControls.begin(); it != mInControls.end(); it++)
120 unsigned nInputs = GetInputsNumber();
123 AddConfigErrorMessage(
"No proper OSCTypeSpec setup. Use: 'f' for float, 'd' for double, 'i' for integer, 'h' for integer 64, 'M' for MIDI Message.");
126 std::string baseName = nInputs==1 ?
"In Control" : _config.GetIdentifier();
127 ResizeControls(nInputs, baseName);
134 if (_config.GetGuiOnly())
137 std::string separator =
"";
138 std::stringstream values;
139 for (
unsigned i = 0; i < mInControls.size(); i++)
141 values<<separator<<mInControls[i]->GetLastValueAsString();
144 std::cout << _config.GetIdentifier() <<
": "
145 << values.str() << std::endl;