Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:jamoma/JamomaCore into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
laugre committed Oct 15, 2013
2 parents 84bcfe0 + 2ac8785 commit df0df99
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 2 deletions.
77 changes: 77 additions & 0 deletions Modular/library/PeerObject/TTCue.cpp
Expand Up @@ -34,6 +34,7 @@ mScript(NULL)

addMessage(Clear);
addMessageWithArguments(Store);
addMessageWithArguments(Update);
addMessageWithArguments(Append);
addMessageWithArguments(Recall);
addMessageWithArguments(Output);
Expand Down Expand Up @@ -544,6 +545,82 @@ TTErr TTCue::processStore(TTObjectBasePtr aScript, const TTAddressItemPtr aNames
return kTTErrNone;
}

TTErr TTCue::Update(const TTValue& inputValue, TTValue& outputValue)
{
TTValue v;
TTBoolean flattened;

// TODO : update from an address

// is the cue already flattened ?
mScript->getAttributeValue(kTTSym_flattened, v);
flattened = v[0];

if (!flattened)
mScript->sendMessage(kTTSym_Flatten, kTTAdrsRoot, kTTValNONE);

return processUpdate(mScript);
}

TTErr TTCue::processUpdate(TTObjectBasePtr aScript)
{
TTListPtr lines;
TTDictionaryPtr aLine;
TTAddress anAddress;
TTNodePtr aNode;
TTObjectBasePtr anObject;
TTSymbol service;
TTValue v;
TTErr err;

aScript->getAttributeValue(TTSymbol("flattenedLines"), v);
lines = TTListPtr((TTPtr)v[0]);

// lookat each line of the script
for (lines->begin(); lines->end(); lines->next()) {

aLine = TTDictionaryPtr((TTPtr)lines->current()[0]);

// if it is a Data object
if (!aLine->lookup(kTTSym_target, v)) {

anAddress = v[0];
err = getDirectoryFrom(anAddress)->getTTNode(anAddress, &aNode);

if (!err) {

anObject = aNode->getObject();

if (anObject) {

if (anObject->getName() == kTTSym_Data) {

// get his service attribute value
anObject->getAttributeValue(kTTSym_service, v);
service = v[0];

// update only parameters
if (service == kTTSym_parameter) {

// get his current value
err = anObject->getAttributeValue(kTTSym_value, v);

if (!err) {

// replace the former value
aLine->remove(kTTSym_value);
aLine->append(kTTSym_value, v);
}
}
}
}
}
}
}

return kTTErrNone;
}

TTErr TTCue::Append(const TTValue& inputValue, TTValue& outputValue)
{
return mScript->sendMessage(TTSymbol("Append"), inputValue, outputValue);
Expand Down
8 changes: 7 additions & 1 deletion Modular/library/PeerObject/TTCue.h
Expand Up @@ -56,6 +56,9 @@ class TTMODULAR_EXPORT TTCue : public TTDataObjectBase
/** Fill the cue on a namespace using namespace pointer or name */
TTErr Store(const TTValue& inputValue, TTValue& outputValue);

/** Update the cue from an address (default : kAdrsRoot to update all the cue) */
TTErr Update(const TTValue& inputValue, TTValue& outputValue);

/** Fill the cue line by line */
TTErr Append(const TTValue& inputValue, TTValue& outputValue);

Expand All @@ -78,11 +81,14 @@ class TTMODULAR_EXPORT TTCue : public TTDataObjectBase

/** a recursive method to store a namespace into a script object */
TTErr processStore(TTObjectBasePtr aScript, const TTAddressItemPtr aNamespace, TTNodePtr nodeToProcess);

/** a method to update each Data value */
TTErr processUpdate(TTObjectBasePtr aScript);

/** a recursive method to process a namespace selection from a script object (and optionnaly fill it) */
TTErr processSelect(TTObjectBasePtr aScript, TTAddressItemPtr aNamespace, TTBoolean fill=NO);

/** a recursive method to change each ramping value into a script */
/** a method to change each ramping value into a script */
TTErr processRamp(TTObjectBasePtr aScript, TTUInt32 ramp);

/** a recursive method to read the ramp value from a script */
Expand Down
51 changes: 51 additions & 0 deletions Modular/library/PeerObject/TTCueManager.cpp
Expand Up @@ -65,6 +65,7 @@ mReturnLineCallback(NULL)
addMessage(Clear);

addMessageWithArguments(Store);
addMessageWithArguments(Update);
addMessageWithArguments(Append);
addMessageWithArguments(Recall);
addMessageWithArguments(Output);
Expand Down Expand Up @@ -453,6 +454,56 @@ TTErr TTCueManager::Store(const TTValue& inputValue, TTValue& outputValue)
return err;
}

TTErr TTCueManager::Update(const TTValue& inputValue, TTValue& outputValue)
{
TTValue v;
TTSymbol anAddress = kTTAdrsRoot;

if (inputValue.size() >= 1) {

// get cue name
if (inputValue[0].type() == kTypeSymbol) {
mCurrent = inputValue[0];

TTSymbol name;
for (TTInt32 i = 0; i < mNames.size(); i++) {
name = mNames[i];
if (name == mCurrent) {
mCurrentPosition = i+1;
break;
}
}
}

// get cue at position
if (inputValue[0].type() == kTypeInt32) {

mCurrentPosition = inputValue[0];

if (mCurrentPosition > 0 && mCurrentPosition <= mNames.size())
mCurrent = mNames[mCurrentPosition-1];
else
return kTTErrGeneric;
}
}

// get address from where update starts (default : kAdrsRoot)
if (inputValue.size() == 2)
if (inputValue[1].type() == kTypeSymbol)
anAddress = inputValue[1];

// if cue exists
if (!mCues->lookup(mCurrent, v)) {

mCurrentCue = TTCuePtr((TTObjectBasePtr)v[0]);

if (mCurrentCue)
return mCurrentCue->sendMessage(kTTSym_Update, anAddress, kTTValNONE);
}

return kTTErrGeneric;
}

TTErr TTCueManager::Append(const TTValue& inputValue, TTValue& outputValue)
{
TTValue v, args, lineValue, parsedLine;
Expand Down
6 changes: 5 additions & 1 deletion Modular/library/PeerObject/TTCueManager.h
Expand Up @@ -83,11 +83,15 @@ class TTMODULAR_EXPORT TTCueManager : public TTDataObjectBase
nothing : store into the current cue */
TTErr Store(const TTValue& inputValue, TTValue& outputValue);

/** Update a cue :
name/id : update an existing cue.
nothing : update the current cue */
TTErr Update(const TTValue& inputValue, TTValue& outputValue);

/** Append a line to a cue :
name/id line : append line to the cue */
TTErr Append(const TTValue& inputValue, TTValue& outputValue);


/** Recall a cue :
name/id : recall the cue.
nothing : recall the current cue */
Expand Down
1 change: 1 addition & 0 deletions Modular/library/includes/TTModularSymbolCache.h
Expand Up @@ -162,6 +162,7 @@ extern TTMODULAR_EXPORT TTSymbol kTTSym_tag;
extern TTMODULAR_EXPORT TTSymbol kTTSym_target;

extern TTMODULAR_EXPORT TTSymbol kTTSym_unit;
extern TTMODULAR_EXPORT TTSymbol kTTSym_Update;

extern TTMODULAR_EXPORT TTSymbol kTTSym_value;
extern TTMODULAR_EXPORT TTSymbol kTTSym_valueDefault;
Expand Down
1 change: 1 addition & 0 deletions Modular/library/source/TTModularSymbolCache.cpp
Expand Up @@ -161,6 +161,7 @@ TTMODULAR_EXPORT TTSymbol kTTSym_tag (("tag")
TTMODULAR_EXPORT TTSymbol kTTSym_target (("target"));

TTMODULAR_EXPORT TTSymbol kTTSym_unit (("unit"));
TTMODULAR_EXPORT TTSymbol kTTSym_Update (("Update"));

TTMODULAR_EXPORT TTSymbol kTTSym_value (("value"));
TTMODULAR_EXPORT TTSymbol kTTSym_valueDefault (("valueDefault"));
Expand Down

0 comments on commit df0df99

Please sign in to comment.