Пример #1
0
void ConnectionIO::xmlExportContent(
    ExportContext&						context) const {

    context.beginContent();

    // write output
    {
        context.beginElement(_OUTPUT_ELEMENT);
        context.beginContent();

        // describe the node
//		LiveNodeIO nodeIO(
//			m_manager,
//			dynamic_cast<NodeSetIOContext*>(&context),
//			m_outputNode);
        context.writeObject(m_outputNodeIO);

//		context.beginElement(_LIVE_NODE_ELEMENT);
//		if(m_outputNodeKey.Length()) {
//			context.writeAttr("key", m_outputNodeKey);
//		}
//		else {
//			_write_simple("name", m_outputNodeName.String(), context);
//			_write_node_kinds(m_outputNodeKind, context);
//		}
//		context.endElement(); // _LIVE_NODE_ELEMENT

        // describe the output

        _write_simple("name", m_outputName.String(), context);

        if(m_outputFormat.type > B_MEDIA_UNKNOWN_TYPE) {
            MediaFormatIO io(m_outputFormat);
            context.writeObject(&io);
        }

        context.endElement(); // _OUTPUT_ELEMENT
    }

    // write input
    {
        context.beginElement(_INPUT_ELEMENT);
        context.beginContent();

        // describe the node
//		LiveNodeIO nodeIO(
//			m_manager,
//			dynamic_cast<NodeSetIOContext*>(&context),
//			m_inputNode);
        context.writeObject(m_inputNodeIO);

//		context.beginElement(_LIVE_NODE_ELEMENT);
//		if(m_inputNodeKey.Length()) {
//			context.writeAttr("key", m_inputNodeKey);
//		}
//		else {
//			_write_simple("name", m_inputNodeName.String(), context);
//			_write_node_kinds(m_inputNodeKind, context);
//		}
//		context.endElement(); // _LIVE_NODE_ELEMENT

        // describe the input

        _write_simple("name", m_inputName.String(), context);

        if(m_inputFormat.type > B_MEDIA_UNKNOWN_TYPE) {
            MediaFormatIO io(m_inputFormat);
            context.writeObject(&io);
        }

        context.endElement(); // _INPUT_ELEMENT
    }

    // write requested format
    if(m_requestedFormat.type > B_MEDIA_UNKNOWN_TYPE) {
        MediaFormatIO io(m_requestedFormat);
        BString comment = "\n";
        comment << context.indentString();
        comment << "<!-- initial requested format -->";
        context.writeString(comment);
        context.writeObject(&io);
    }
}
Пример #2
0
void RouteAppNodeManager::xmlExportContent(
	ExportContext&								context) const {

	status_t err;

	try {
		NodeSetIOContext& nodeSet = dynamic_cast<NodeSetIOContext&>(context);
		context.beginContent();
	
		// write nodes; enumerate connections
		typedef map<uint32,Connection> connection_map;
		connection_map connections;
		int count = nodeSet.countNodes();
		for(int n = 0; n < count; ++n) {
			media_node_id id = nodeSet.nodeAt(n);
			ASSERT(id != media_node::null.node);
			
			// fetch node
			NodeRef* ref;
			err = getNodeRef(id, &ref);
			if(err < B_OK) {
				D_SETTINGS((
					"! RouteAppNodeManager::xmlExportContent():\n"
					"  getNodeRef(%ld) failed: '%s'\n",
					id, strerror(err)));
				continue;
			}

			// fetch connections
			vector<Connection> conSet;
			ref->getInputConnections(conSet);
			ref->getOutputConnections(conSet);
			for(uint32 c = 0; c < conSet.size(); ++c)
				// non-unique connections will be rejected:
				connections.insert(
					connection_map::value_type(conSet[c].id(), conSet[c]));

			// create an IO object for the node & write it
			DormantNodeIO io(ref, nodeSet.keyAt(n));
			if(context.writeObject(&io) < B_OK)
				// abort
				return;
		}		

		// write connections
		for(connection_map::const_iterator it = connections.begin();
			it != connections.end(); ++it) {
		
			ConnectionIO io(
				&(*it).second, 
				this,
				&nodeSet);
			if(context.writeObject(&io) < B_OK)
				// abort
				return;
				
		}
	
		// +++++ write groups
	
		// write UI state
		{
			BMessage m;
			nodeSet.exportUIState(&m);
			context.beginElement(_UI_STATE_ELEMENT);
			context.beginContent();
			MessageIO io(&m);
			context.writeObject(&io);
			context.endElement();
		}
	}
	catch(bad_cast& e) {
		context.reportError("RouteAppNodeManager: expected a NodeSetIOContext\n");
	}	
}