Пример #1
0
NSPStatus 
Namespace::namespacePresetsLoadFromXml(std::string filepath)
{
	TTValue				args, v, attr;
//	TTPresetManagerPtr	returnedPresetManager	= NULL;
	TTXmlHandlerPtr		aXmlHandler				= NULL;
	TTHashPtr			toStore					= new TTHash();
	TTObjectPtr			testObjectCallback;
//	TTValuePtr			testObjectBaton;
	
	// Instanciate a PresetManager
	args.append(GalamusApplication);	// add application arg
	
	testObjectCallback = NULL;			// without this, TTObjectInstantiate try to release an oldObject that doesn't exist ... Is it good ?
	TTObjectInstantiate(TTSymbol("callback"),			&testObjectCallback,					kTTValNONE);
//	testObjectBaton = new TTValue(TTPtr(x));
//	testObjectCallback->setAttributeValue(kTTSym_baton, TTPtr(testObjectBaton));
//	testObjectCallback->setAttributeValue(kTTSym_function, TTPtr(&jamoma_presetManager_test_object_callback));
	args.append(testObjectCallback);	// add callback method arg (we don't need here)
	
	// Here we decide to store only Value and Priority attributes for Data object
	attr = TTValue(kTTSym_value);
	attr.append(kTTSym_priority);
	//toStore->append(TTSymbol("Data"), attr);
	
	args.append((TTPtr)toStore);		// add storing hash table arg
	
	m_presetManager = NULL;
	TTObjectInstantiate(TTSymbol("PresetManager"),	TTObjectHandle(&m_presetManager), args);
	
	// Instanciate a XmlHandler
	args.clear();
	TTObjectInstantiate(TTSymbol("XmlHandler"),		TTObjectHandle(&aXmlHandler),			args);
	
	// Set XmlHandler being used by PresetManager
	v = TTValue(TTPtr(m_presetManager));
	aXmlHandler->setAttributeValue(kTTSym_object, v);
	aXmlHandler->setAttributeValue(TTSymbol("headerNodeName"),	TT(XML_PRESET_HEADER_NODE_NAME));
	aXmlHandler->setAttributeValue(TTSymbol("version"),			TT(XML_PRESET_VERSION));
	aXmlHandler->setAttributeValue(TTSymbol("xmlSchemaLocation"), TT(XML_PRESET_SCHEMA_LOCATION));
	
	v.clear();
	v.append(TT(filepath));
	aXmlHandler->sendMessage(TTSymbol("Read"), v);//TODO : return an error code if fail
	
//	TTValue tmp;
//	m_presetManager->getAttributeValue(TTSymbol("names"), tmp);
//	
//	for (int i = 0; i < tmp.getSize(); i++) {
//		TTString s;
//		tmp.toString();
//		tmp.get(i, s);
//		
//		std::cout << s << std::endl;
//	}
	
	return NSP_NO_ERROR;
}
Пример #2
0
NSPStatus
Namespace::namespaceParameterCreate(std::string address, int instanceNumber, void* object, void (*returnValueCallback)	(TTPtr, TTValue&)
																  						 , void (*returnAddressCallback)(TTPtr, TTValue&))
{
	// Create a TTData
	TTDataPtr		data = NULL;
	TTCallbackPtr	p_returnValueCallback, p_returnAddressCallback;
	TTValuePtr		p_returnValueBaton, p_returnAddressBaton;
	
	// prepare arguments : see TTData.h to know which args are needed
	TTValue args;
	args.clear();
	
	p_returnValueCallback = NULL;
	TTObjectInstantiate(TTSymbol("callback"), TTObjectHandle(&p_returnValueCallback), kTTValNONE);
	p_returnValueBaton = new TTValue(TTPtr(object));
	p_returnValueCallback->setAttributeValue(kTTSym_baton, TTPtr(p_returnValueBaton));
	p_returnValueCallback->setAttributeValue(kTTSym_function, TTPtr(returnValueCallback));
	args.append(p_returnValueCallback);

	p_returnAddressCallback = NULL;
	TTObjectInstantiate(TTSymbol("callback"), TTObjectHandle(&p_returnAddressCallback), kTTValNONE);
	p_returnAddressBaton = new TTValue(TTPtr(object));
	p_returnAddressCallback->setAttributeValue(kTTSym_baton, TTPtr(p_returnAddressBaton));
	p_returnAddressCallback->setAttributeValue(kTTSym_function, TTPtr(p_returnAddressCallback));
	args.append(p_returnAddressCallback);

	// Register a TTObject into the NSPDirectory
	TTNodePtr	returnedNode;
	TTBoolean	newInstanceCreated;

	for (int i = 0; i < instanceNumber; i++) { 
		data				= NULL;
		returnedNode		= NULL;
		newInstanceCreated	= NULL;

		// create an instance of TTData
		TTObjectInstantiate(TTSymbol("Data"), TTObjectHandle(&data), args);

		std::string absAddress = AppName + address;
		// add instance number
		if (i != 0) {
			absAddress += ".";
			stringstream st;
			st << i;
			absAddress += st.str();
		}

		// add the parameter data in the namespace directory
		NSPDirectory->TTNodeCreate(TT(absAddress), (TTObjectPtr)data, NULL, &returnedNode, &newInstanceCreated);
		// note : our myRegistrationObserver is informed if declared 
	}

	return NSP_NO_ERROR;
}
Пример #3
0
NSPStatus 
Namespace::namespaceMappingLoadFromXml(std::string filepath)
{
	// Parse xml file to instantiate TTData for each input 
	XMLNode xMainNode;
	XMLError err = XMLNode::openFileHelper(&xMainNode, filepath.c_str(), XML_MAPPING_HEADER_NODE_NAME);
	
	if (err == eXMLErrorFileNotFound)
		return NSP_FILE_NOTFOUND;
	if (err == eXMLErrorFirstTagNotFound)
		return NSP_XMLPARSING_ERROR;
	
	int nChild = xMainNode.nChildNode();
	
	// For each child of the node create a mapping parameter according to the input attribute
	for (int i = 0; i < nChild; i++) {
		XMLNode child = xMainNode.getChildNode(i);
		namespaceParameterCreate(child.getAttribute("input"), NULL);
	}
	
	// Instanciate a MapperManager
	TTValue				args, v;
	TTMapperManagerPtr	returnedMapperManager	= NULL;
	TTXmlHandlerPtr		aXmlHandler				= NULL;
	
	args.append(GalamusApplication);
	TTObjectInstantiate(TTSymbol("MapperManager"),	TTObjectHandle(&returnedMapperManager), args);
	
	// Instanciate a XmlHandler
	args.clear();
	TTObjectInstantiate(TTSymbol("XmlHandler"),		TTObjectHandle(&aXmlHandler),			args);
	
	// Set XmlHandler being used by MapperManager
	v = TTValue(TTPtr(returnedMapperManager));
	aXmlHandler->setAttributeValue(kTTSym_object, v);
	aXmlHandler->setAttributeValue(TTSymbol("headerNodeName"),	TT(XML_MAPPING_HEADER_NODE_NAME));
	aXmlHandler->setAttributeValue(TTSymbol("version"),			TT(XML_MAPPING_VERSION));
	aXmlHandler->setAttributeValue(TTSymbol("xmlSchemaLocation"), TT(XML_MAPPING_SCHEMA_LOCATION));
	
	v.clear();
	v.append(TT(filepath));
	aXmlHandler->sendMessage(TTSymbol("Read"), v);//TODO : return an error code if fail
	
//	v.clear();
//	v.append(TTSymbol("writtenMapping.xml"));
//	aXmlHandler->sendMessage(TTSymbol("Write"), v);
	
	return NSP_NO_ERROR;
}
Пример #4
0
NSPStatus
Namespace::namespaceInit(bool useDeviceManager)
{
	// Initialise TT environments
	TTModularInit(m_appName, "");
	
	GalamusApplication = (TTApplicationPtr)TTModularGetApplication(TT(m_appName));
	
	if (NSPDirectory == NULL) {
		return NSP_INIT_ERROR;
	}

	if (useDeviceManager) {
		// Initialise DeviceManager if wanted
		/*TTDeviceManagerPtr */m_deMan = NULL;
		TTValue	args;
		
		// Make a TTDeviceManager object
		args.append(GalamusApplication);
		args.append(TT(m_appName));
		
		TTObjectInstantiate(TTSymbol("DeviceManager"), TTObjectHandle(&m_deMan), args);
		
		// Load plugins and config with xml
		TTValue value;
		value.append(TT(PLUGINS_PATH));
		value.append(TT(XML_CONFIG_PATH));
		m_deMan->LoadPlugins(value);

		// Load devices with xml
		m_deMan->LoadDeviceXmlConfig(TT(XML_CONFIG_PATH));
	}

	return NSP_NO_ERROR;
}
Пример #5
0
NSPStatus 
Namespace::namespaceValueSend(std::string address, TTSymbolPtr attribute, TTValue value, int instance)
{
	TTSenderPtr	sender = NULL;
	
	// prepare arguments : see TTSender.h to know which args are needed
	TTValue args;
	args.clear();
	args.append(GalamusApplication);

	// add Application name to the address
	std::string absAddress = AppName + address;

	// add instance number
	if (instance != 0) {
		absAddress += ".";
		stringstream st;
		st << instance;
		absAddress += st.str();
	}

	args.append(TT(absAddress));
	args.append(attribute);
		
	TTObjectInstantiate(TTSymbol("Sender"), TTObjectHandle(&sender), args);

	sender->sendMessage(kTTSym_Send, value);
	// note : the value is returned by the Data and the Receiver

	//TTObjectRelease(TTObjectHandle(&sender));// throw an exception on windows

	return NSP_NO_ERROR;
}
Пример #6
0
NSPStatus 
Namespace::namespaceObserverCreate(std::string address, TTSymbolPtr attribute, void* object, void (*returnValueCallback)	(TTPtr, TTValue&)
																						   , void (*returnAddressCallback)	(TTPtr, TTValue&)
																						   , int instance)
{
	TTReceiverPtr	myReceiver = NULL;
	TTCallbackPtr	r_returnAddressCallback; 
	TTCallbackPtr	r_returnValueCallback;
	TTValuePtr		r_returnAddressBaton, r_returnValueBaton;
	
	// prepare arguments : see TTReceiver.h to know which args are needed
	TTValue args;
	args.clear();
	args.append(GalamusApplication);

	// add Application name to the address
	std::string absAddress = AppName + address;

	// add instance number
	if (instance != 0) {
		absAddress += ".";
		stringstream st;
		st << instance;
		absAddress += st.str();
	}

	args.append(TT(absAddress));
	args.append(attribute);
		
	r_returnAddressCallback = NULL;
	TTObjectInstantiate(TTSymbol("callback"), TTObjectHandle(&r_returnAddressCallback), kTTValNONE);
	r_returnAddressBaton = new TTValue(TTPtr(object));
	r_returnAddressCallback->setAttributeValue(kTTSym_baton, TTPtr(r_returnAddressBaton));
	r_returnAddressCallback->setAttributeValue(kTTSym_function, TTPtr(returnAddressCallback));
	args.append(r_returnAddressCallback);
	
	r_returnValueCallback = NULL;
	TTObjectInstantiate(TTSymbol("callback"), TTObjectHandle(&r_returnValueCallback), kTTValNONE);
	r_returnValueBaton = new TTValue(TTPtr(object));
	r_returnValueCallback->setAttributeValue(kTTSym_baton, TTPtr(r_returnValueBaton));
	r_returnValueCallback->setAttributeValue(kTTSym_function, TTPtr(returnValueCallback));
	args.append(r_returnValueCallback);
		
	TTObjectInstantiate(TTSymbol("Receiver"), TTObjectHandle(&myReceiver), args);

	return NSP_NO_ERROR;
}
Пример #7
0
NSPStatus
Namespace::namespaceFree(void)
{
	if(TTObjectRelease(TTObjectHandle(NSPDirectory)) != kTTErrNone) {
		return NSP_RELEASE_ERROR;
	}

	return NSP_NO_ERROR;
}
Пример #8
0
#define thisTTClass			TTNode
#define thisTTClassName		"Node"
#define thisTTClassTags		"node"

TT_OBJECT_CONSTRUCTOR,
	parent(NULL)
{
	TT_ASSERT("Correct number of args to create TTNode", arguments.getSize() == 6);
	
	arguments.get(0, &name);
	arguments.get(1, &instance);
	arguments.get(2, &type);
	arguments.get(3, &object);
	arguments.get(4, &context);
	arguments.get(5, TTObjectHandle(&directory));
	TT_ASSERT("Directory passed to TTNode is not NULL", directory);
	
	// a new TTNode have no child
	this->children = new TTHash();
}

TTNode::~TTNode()
{
	TTErr err;
	unsigned int i, j, nb_c, nb_i;
	TTValue hk, hk_i;
	TTSymbolPtr OSCaddress, key, key_i;
	TTValue c, c_i, p_c, data;
	TTHashPtr ht_i, p_ht_i;
	TTNodePtr n_c;