Skip to content

Commit 613b21f

Browse files
author
theod
committed
allowing to setup an index field into Destination
1 parent 1114b15 commit 613b21f

File tree

13 files changed

+121
-90
lines changed

13 files changed

+121
-90
lines changed

Documentation/Examples/Editor/curve.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ int main()
5959

6060
Tuple t = {new Float(-1.), new Float(0.), new Float(1.)};
6161
localTupleAddress->setValue(&t);
62-
Destination d(localTupleNode);
63-
62+
6463
cout << "*** test 3 ***" << endl;
65-
myCurve->setInitialDestination(&d);
64+
Destination d1(localTupleNode);
65+
myCurve->setInitialDestination(&d1);
6666

6767
cout << "value at 0. = " << myCurve->valueAt(0.) << endl;
6868
cout << "value at 0.5 = " << myCurve->valueAt(0.5) << endl;
@@ -71,7 +71,8 @@ int main()
7171
cout << "value at 2. = " << myCurve->valueAt(2.) << endl;
7272

7373
cout << "*** test 4 ***" << endl;
74-
myCurve->setInitialDestinationIndex({1});
74+
Destination d2(localTupleNode, {1});
75+
myCurve->setInitialDestination(&d2);
7576

7677
cout << "value at 0. = " << myCurve->valueAt(0.) << endl;
7778
cout << "value at 0.5 = " << myCurve->valueAt(0.5) << endl;

Headers/Editor/Curve.h

-10
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,6 @@ class Curve : public CurveAbstract
112112
\param const Destination* */
113113
virtual void setInitialDestination(const Destination*) = 0;
114114

115-
/*! get which index are taken in case the initial destination is a Tuple of Tuple of Tuple ...
116-
\return std::vector<char> */
117-
virtual std::vector<char> getInitialDestinationIndex() const = 0;
118-
119-
/*! precise which index to take in case the initial destination is a Tuple of Tuple of Tuple ...
120-
\param char for first level Tuple index
121-
\param char for second level Tuple index
122-
\param ... */
123-
virtual void setInitialDestinationIndex(std::initializer_list<char>) = 0;
124-
125115
/*! get initial curve value
126116
\return std::map<X, std::pair<Y, std::shared_ptr<CurveSegment<Y>>>> map of {abscissa, {value, previous segment} */
127117
virtual std::map<X, std::pair<Y, std::shared_ptr<CurveSegment<Y>>>> getPointsMap() const = 0;

Headers/Editor/Value.h

-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ struct Tuple final : public Value
311311
\param ... */
312312
Tuple(std::initializer_list<const Value*>);
313313

314-
315314
/*! constructor passing a value vector
316315
\param std::vector<const #Value> value */
317316
Tuple(const std::vector<const Value*>&);

Headers/Network/Address.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ class Address : public CallbackContainer<ValueCallback>
7777

7878
/*! clone the address value
7979
\details thread-safe
80+
\param std::initializer_list<char> optionnal index list to clone only some elements from a Tuple value
8081
\return const #Value* a cloned value. deletion is the responsibility of the caller. */
81-
virtual const Value * cloneValue() const = 0;
82+
virtual const Value * cloneValue(std::vector<char> = {}) const = 0;
8283

8384
/*! set the address value
8485
\note call pushValue if you need to sync the value with the device

Headers/Network/Node.h

+14-4
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,23 @@ class Node : public CallbackContainer<NodeChangeCallback>
152152
# pragma mark -
153153
# pragma mark Destination
154154

155-
/*! \details Destination value */
155+
/*! \details Destination to an Address value and optionnally to several index of this value */
156156
struct Destination final : public Value
157157
{
158158
std::shared_ptr<Node> value;
159-
160-
/*! constructor */
161-
Destination(std::shared_ptr<Node> v);
159+
std::vector<char> index;
160+
161+
/*! constructor for a node and optionnal index values
162+
\param std::shared_ptr<Node>
163+
\param char
164+
\param char
165+
\param ... */
166+
Destination(std::shared_ptr<Node> v, std::initializer_list<char> = {});
167+
168+
/*! constructor for a node and an index vector
169+
\param std::shared_ptr<Node>
170+
\param std::vector<const #Value> value */
171+
Destination(std::shared_ptr<Node> v, std::vector<char>);
162172

163173
/*! clone */
164174
Value * clone() const override;

Implementations/Jamoma/Includes/Editor/JamomaCurve.h

-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ class JamomaCurve final : public Curve<X,Y>
6868

6969
void setInitialDestination(const Destination*) override;
7070

71-
vector<char> getInitialDestinationIndex() const override;
72-
73-
void setInitialDestinationIndex(std::initializer_list<char>) override;
74-
7571
map<X, pair<Y, shared_ptr<CurveSegment<Y>>>> getPointsMap() const override;
7672

7773
# pragma mark -

Implementations/Jamoma/Includes/Network/JamomaAddress.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class JamomaAddress final : public Address, public enable_shared_from_this<Jamom
7373

7474
const Value * getValue() const override;
7575

76-
const Value * cloneValue() const override;
76+
const Value * cloneValue(std::vector<char> = {}) const override;
7777

7878
Address & setValue(const Value *) override;
7979

Implementations/Jamoma/Sources/Editor/Curve.cpp

+1-18
Original file line numberDiff line numberDiff line change
@@ -291,23 +291,6 @@ setInitialDestination(const Destination* destination)
291291
mInitialDestination = static_cast<Destination*>(destination->clone());
292292
}
293293

294-
template <typename X, typename Y>
295-
vector<char> JamomaCurve<X,Y>::
296-
getInitialDestinationIndex() const
297-
{
298-
return mInitialDestinationIndex;
299-
}
300-
301-
template <typename X, typename Y>
302-
void JamomaCurve<X,Y>::
303-
setInitialDestinationIndex(std::initializer_list<char> index)
304-
{
305-
mInitialDestinationIndex.clear();
306-
307-
for (const auto & i : index)
308-
mInitialDestinationIndex.push_back(i);
309-
}
310-
311294
template <typename X, typename Y>
312295
map<X, pair<Y, shared_ptr<CurveSegment<Y>>>> JamomaCurve<X,Y>::
313296
getPointsMap() const
@@ -352,7 +335,7 @@ convertToTemplateTypeValue(const Value * value, char* level) const
352335
{
353336
auto t = static_cast<const Tuple*>(value);
354337

355-
char index = mInitialDestinationIndex[*level];
338+
char index = mInitialDestination->index[*level];
356339
(*level)++;
357340

358341
return convertToTemplateTypeValue(t->value[index], level);

0 commit comments

Comments
 (0)