22 #ifndef _ControlArray_hxx_
23 #define _ControlArray_hxx_
40 template <
class ControlT>
43 typedef std::vector<ControlT *> Controls;
54 Resize(size, names, parent);
56 template <
typename ProcessingType,
typename ValueType>
57 ControlArray(
int size,
const std::string &name, ProcessingType * parent,
58 void (ProcessingType::*method)(
unsigned, ValueType) )
60 Resize(size,name,parent,method);
65 const ControlT &
operator[](
int i)
const {
return *mControls[i]; }
68 void Resize(
int size,
const std::list<std::string>& names,
Processing* parent);
69 template <
typename ProcessingType,
typename ValueType>
70 void Resize(
int size,
const std::string &name, ProcessingType * parent,
71 void (ProcessingType::*method)(
unsigned, ValueType) )
73 int previousSize = mControls.size();
74 if(size < previousSize)
79 mControls.resize(size);
80 for (
int i = previousSize; i<size; i++) {
81 std::stringstream str;
82 str << name <<
"_" << i;
83 mControls[i] =
new ControlT(i, str.str(), parent, method);
88 void Append(
int size,
const std::list<std::string>& names,
Processing* parent);
90 int Size()
const {
return mControls.size(); }
98 template <
class ControlT>
102 int previousSize = mControls.size();
103 if(size < previousSize)
108 mControls.resize(size);
109 for (
int i = previousSize; i<size; i++) {
110 std::stringstream str;
111 str << name <<
"_" << i;
112 mControls[i] =
new ControlT(str.str(), parent);
117 template <
class ControlT>
119 const std::list<std::string>& names,
Processing* parent)
121 int previousSize = mControls.size();
122 if (size < previousSize)
127 CLAM_ASSERT(size - previousSize <=
int(names.size()),
128 "ControlArray::Resize: error, not enough labels provided");
129 mControls.resize(size);
130 std::list<std::string>::const_iterator name = names.begin();
131 for (
int i = previousSize; i<size; i++, name++)
132 mControls[i] =
new ControlT(*name, parent);
135 template <
class ControlT>
139 Resize(Size() + count, name, parent);
142 template <
class ControlT>
144 const std::list<std::string>& names,
Processing* parent)
146 Resize(Size() + count, names, parent);
150 template <
class ControlT>
153 int previousSize = mControls.size();
154 if (size == previousSize)
return;
156 "ControlArray::Cannot Shrink a ControlArray to a larger size");
157 for (
int i = previousSize-1; i >= size; i--)
159 mControls.resize(size);