<commit_before>/** @file
 *
 * @ingroup modularLibrary
 *
 * @brief A Container object
 *
 * @details
 *
 * @authors <NAME>
 *
 * @copyright © 2010, <NAME> @n
 * This code is licensed under the terms of the "New BSD License" @n
 * http://creativecommons.org/licenses/BSD/
 */


#include "TTContainer.h"

#define thisTTClass			TTContainer
#define thisTTClassName		"Container"
#define thisTTClassTags		"node, container"

TT_MODULAR_CONSTRUCTOR,
mPriority(0), 
mDescription(kTTSym_none),
mService(kTTSym_none),
mTags(TTValue(kTTSym_none)),
mInitialized(NO),
mActive(YES),
mAddress(kTTAdrsEmpty),
mAlias(kTTAdrsEmpty),
activityAttribute(NULL),
contentAttribute(NULL)
{
	if(arguments.size() == 2)
    {
		mReturnAddressCallback = arguments[0];
		mReturnValueCallback = arguments[1];
	}
	
	addAttributeWithSetter(Priority, kTypeInt32);
	addAttribute(Description, kTypeSymbol);
    
    addAttribute(Service, kTypeSymbol);
    
	addAttributeWithSetter(Tags, kTypeLocalValue);
	
	addAttribute(Initialized, kTypeBoolean);
	addAttributeProperty(Initialized, readOnly, YES);
	addAttributeProperty(Initialized, hidden, YES);
    
    addAttributeWithSetter(Active, kTypeBoolean);
	
	addAttributeWithSetter(Address, kTypeSymbol);
	addAttributeProperty(Address, hidden, YES);
	
	addAttributeWithSetter(Alias, kTypeSymbol);

	addAttribute(Activity, kTypeLocalValue);             // TODO : have a way to add notification (instead of a readonly attribute)
	addAttributeProperty(Activity, readOnly, YES);
    
    addAttribute(Content, kTypeLocalValue);             // TODO : have a way to add notification (instead of a readonly attribute)
	addAttributeProperty(Content, readOnly, YES);
    
	addMessageWithArguments(Send);
	addMessageProperty(Send, hidden, YES);
	
	addMessage(Init);
    
    addMessageWithArguments(Rename);
    addMessageProperty(Rename, hidden, YES);
    
	addMessage(AliasRemove);
	
	// needed to be handled by a TTTextHandler
	addMessageWithArguments(WriteAsText);
	addMessageProperty(WriteAsText, hidden, YES);
	
	mIsSending = false;
    
    // cache some attribute for observer notification
    this->findAttribute(kTTSym_activity, &activityAttribute);
    this->findAttribute(kTTSym_content, &contentAttribute);
}

TTContainer::~TTContainer()
{
	setAlias(kTTAdrsEmpty);
	unbind();
}

TTErr TTContainer::Send(TTValue& AddressAndValue, TTValue& outputValue)
{
	TTValue			hk, cacheElement, v, none;
	TTValuePtr		valueToSend;
	TTObject        anObject;
	TTAddress       aRelativeAddress, topAddress, belowAddress, keyAddress;
	TTSymbol		attrOrMess, service;
    TTUInt32        i;
    TTInt8          depth = 0;
	TTErr			err = kTTErrNone;
	
	if (!mIsSending) {
		
		// lock
		mIsSending = true;
        
        // get relativeAddress and valueToSend
        aRelativeAddress = AddressAndValue[0];
        
        // get attribute or message (default is value)
        if (aRelativeAddress.getAttribute() != NO_ATTRIBUTE)
            attrOrMess = aRelativeAddress.getAttribute();<commit_msg>Converting application attribute name into TT attribute name<commit_after>/** @file
 *
 * @ingroup modularLibrary
 *
 * @brief A Container object
 *
 * @details
 *
 * @authors <NAME>
 *
 * @copyright © 2010, <NAME> @n
 * This code is licensed under the terms of the "New BSD License" @n
 * http://creativecommons.org/licenses/BSD/
 */


#include "TTContainer.h"

#define thisTTClass			TTContainer
#define thisTTClassName		"Container"
#define thisTTClassTags		"node, container"

TT_MODULAR_CONSTRUCTOR,
mPriority(0), 
mDescription(kTTSym_none),
mService(kTTSym_none),
mTags(TTValue(kTTSym_none)),
mInitialized(NO),
mActive(YES),
mAddress(kTTAdrsEmpty),
mAlias(kTTAdrsEmpty),
activityAttribute(NULL),
contentAttribute(NULL)
{
	if(arguments.size() == 2)
    {
		mReturnAddressCallback = arguments[0];
		mReturnValueCallback = arguments[1];
	}
	
	addAttributeWithSetter(Priority, kTypeInt32);
	addAttribute(Description, kTypeSymbol);
    
    addAttribute(Service, kTypeSymbol);
    
	addAttributeWithSetter(Tags, kTypeLocalValue);
	
	addAttribute(Initialized, kTypeBoolean);
	addAttributeProperty(Initialized, readOnly, YES);
	addAttributeProperty(Initialized, hidden, YES);
    
    addAttributeWithSetter(Active, kTypeBoolean);
	
	addAttributeWithSetter(Address, kTypeSymbol);
	addAttributeProperty(Address, hidden, YES);
	
	addAttributeWithSetter(Alias, kTypeSymbol);

	addAttribute(Activity, kTypeLocalValue);             // TODO : have a way to add notification (instead of a readonly attribute)
	addAttributeProperty(Activity, readOnly, YES);
    
    addAttribute(Content, kTypeLocalValue);             // TODO : have a way to add notification (instead of a readonly attribute)
	addAttributeProperty(Content, readOnly, YES);
    
	addMessageWithArguments(Send);
	addMessageProperty(Send, hidden, YES);
	
	addMessage(Init);
    
    addMessageWithArguments(Rename);
    addMessageProperty(Rename, hidden, YES);
    
	addMessage(AliasRemove);
	
	// needed to be handled by a TTTextHandler
	addMessageWithArguments(WriteAsText);
	addMessageProperty(WriteAsText, hidden, YES);
	
	mIsSending = false;
    
    // cache some attribute for observer notification
    this->findAttribute(kTTSym_activity, &activityAttribute);
    this->findAttribute(kTTSym_content, &contentAttribute);
}

TTContainer::~TTContainer()
{
	setAlias(kTTAdrsEmpty);
	unbind();
}

TTErr TTContainer::Send(TTValue& AddressAndValue, TTValue& outputValue)
{
	TTValue			hk, cacheElement, v, none;
	TTValuePtr		valueToSend;
	TTObject        anObject;
	TTAddress       aRelativeAddress, topAddress, belowAddress, keyAddress;
	TTSymbol		attrOrMess, service;
    TTUInt32        i;
    TTInt8          depth = 0;
	TTErr			err = kTTErrNone;
	
	if (!mIsSending) {
		
		// lock
		mIsSending = true;
        
        // get relativeAddress and valueToSend
        aRelativeAddress = AddressAndValue[0];
        
        // get attribute or message (default is value)
        if (aRelativeAddress.getAttribute() != NO_ATTRIBUTE)
            attrOrMess = ToTTName(aRelativeAddress.getAttribute());
{'fraction_non_alphanumeric': 0.09912440112340988, 'fraction_numerical': 0.004956220056170494, 'mean_word_length': 4.348056537102473, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1543688', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1822, 'n_words': 420}