Examples/ArenaC/C_Streamables/C_Streamables.c
AC_ERROR WriteAndReadStreamables(acDevice hSrcDevice, acDevice* phDstDevices, size_t numDevices)
{
	AC_ERROR err = AC_ERR_SUCCESS;

	// Write features to file
	//    Write streamable features from a device to a file. Each node map
	//    requires a separate feature stream object. When writing to a file, if
	//    no features are explicitly selected, all will be written by default.
	printf("%sSave features from device 0 to %s\n", TAB1, FILE_NAME);

	// get node map
	acNodeMap hNodeMapSrc = NULL;

	err = acDeviceGetNodeMap(hSrcDevice, &hNodeMapSrc);
	if (err != AC_ERR_SUCCESS)
		return err;

	// create feature stream object
	acFeatureStream hFeatureStreamSrc = NULL;

	err = acFeatureStreamCreate(hNodeMapSrc, &hFeatureStreamSrc);
	if (err != AC_ERR_SUCCESS)
		return err;

	// stream features to file
	err = acFeatureStreamWriteFileName(hFeatureStreamSrc, FILE_NAME);
	if (err != AC_ERR_SUCCESS)
		return err;

	// destroy feature stream object
	err = acFeatureStreamDestroy(hFeatureStreamSrc);
	if (err != AC_ERR_SUCCESS)
		return err;

	// Read features to devices
	//    Read streamable features from from a file to the rest of the devices.
	//    Again, each node map requires a separate feature stream object. When
	//    reading from a file, all features saved to the file will be loaded to
	//    the device. If a device does not have a feature, it is skipped.
	size_t i;
	for (i = 0; i < numDevices; i++)
	{
		printf("%sLoad features from %s to device %zu\n", TAB1, FILE_NAME, i);

		// get node map
		acNodeMap hNodeMapDst = NULL;

		err = acDeviceGetNodeMap(phDstDevices[i], &hNodeMapDst);
		if (err != AC_ERR_SUCCESS)
			return err;

		// create feature stream object
		acFeatureStream hFeatureStreamDst = NULL;

		err = acFeatureStreamCreate(hNodeMapDst, &hFeatureStreamDst);
		if (err != AC_ERR_SUCCESS)
			return err;

		// load features from file
		err = acFeatureStreamReadFileName(hFeatureStreamDst, FILE_NAME);
		if (err != AC_ERR_SUCCESS)
			return err;

		// destroy feature stream object
		err = acFeatureStreamDestroy(hFeatureStreamDst);
		if (err != AC_ERR_SUCCESS)
			return err;
	}

	return err;
}
// demonstrates streamable features
// (1) reads all streamable features from source device
// (2) writes features to file
// (3) reads features from file
// (4) writes features to destination devices
demonstrates streamable features
(1) reads all streamable features from source device
(2) writes features to file
(3) reads features from file
(4) writes features to destination devices
demonstrates streamable features ( 1 ) reads all streamable features from source device ( 2 ) writes features to file ( 3 ) reads features from file ( 4 ) writes features to destination devices
AC_ERROR WriteAndReadStreamables(acDevice hSrcDevice, acDevice* phDstDevices, size_t numDevices)
{
	AC_ERROR err = AC_ERR_SUCCESS;
	printf("%sSave features from device 0 to %s\n", TAB1, FILE_NAME);
	acNodeMap hNodeMapSrc = NULL;
	err = acDeviceGetNodeMap(hSrcDevice, &hNodeMapSrc);
	if (err != AC_ERR_SUCCESS)
		return err;
	acFeatureStream hFeatureStreamSrc = NULL;
	err = acFeatureStreamCreate(hNodeMapSrc, &hFeatureStreamSrc);
	if (err != AC_ERR_SUCCESS)
		return err;
	err = acFeatureStreamWriteFileName(hFeatureStreamSrc, FILE_NAME);
	if (err != AC_ERR_SUCCESS)
		return err;
	err = acFeatureStreamDestroy(hFeatureStreamSrc);
	if (err != AC_ERR_SUCCESS)
		return err;
	size_t i;
	for (i = 0; i < numDevices; i++)
	{
		printf("%sLoad features from %s to device %zu\n", TAB1, FILE_NAME, i);
		acNodeMap hNodeMapDst = NULL;
		err = acDeviceGetNodeMap(phDstDevices[i], &hNodeMapDst);
		if (err != AC_ERR_SUCCESS)
			return err;
		acFeatureStream hFeatureStreamDst = NULL;
		err = acFeatureStreamCreate(hNodeMapDst, &hFeatureStreamDst);
		if (err != AC_ERR_SUCCESS)
			return err;
		err = acFeatureStreamReadFileName(hFeatureStreamDst, FILE_NAME);
		if (err != AC_ERR_SUCCESS)
			return err;
		err = acFeatureStreamDestroy(hFeatureStreamDst);
		if (err != AC_ERR_SUCCESS)
			return err;
	}
	return err;
}
AC_ERROR WriteAndReadStreamables ( acDevice hSrcDevice , acDevice * phDstDevices , size_t numDevices ) { AC_ERROR err = AC_ERR_SUCCESS ; printf ( " \n " , TAB1 , FILE_NAME ) ; acNodeMap hNodeMapSrc = NULL ; err = acDeviceGetNodeMap ( hSrcDevice , & hNodeMapSrc ) ; if ( err != AC_ERR_SUCCESS ) return err ; acFeatureStream hFeatureStreamSrc = NULL ; err = acFeatureStreamCreate ( hNodeMapSrc , & hFeatureStreamSrc ) ; if ( err != AC_ERR_SUCCESS ) return err ; err = acFeatureStreamWriteFileName ( hFeatureStreamSrc , FILE_NAME ) ; if ( err != AC_ERR_SUCCESS ) return err ; err = acFeatureStreamDestroy ( hFeatureStreamSrc ) ; if ( err != AC_ERR_SUCCESS ) return err ; size_t i ; for ( i = 0 ; i < numDevices ; i ++ ) { printf ( " \n " , TAB1 , FILE_NAME , i ) ; acNodeMap hNodeMapDst = NULL ; err = acDeviceGetNodeMap ( phDstDevices [ i ] , & hNodeMapDst ) ; if ( err != AC_ERR_SUCCESS ) return err ; acFeatureStream hFeatureStreamDst = NULL ; err = acFeatureStreamCreate ( hNodeMapDst , & hFeatureStreamDst ) ; if ( err != AC_ERR_SUCCESS ) return err ; err = acFeatureStreamReadFileName ( hFeatureStreamDst , FILE_NAME ) ; if ( err != AC_ERR_SUCCESS ) return err ; err = acFeatureStreamDestroy ( hFeatureStreamDst ) ; if ( err != AC_ERR_SUCCESS ) return err ; } return err ; }
demonstrates streamable features
(1) reads all streamable features from source device
(2) writes features to file
(3) reads features from file
(4) writes features to destination devices
demonstrates streamable features ( 1 ) reads all streamable features from source device ( 2 ) writes features to file ( 3 ) reads features from file ( 4 ) writes features to destination devices
// Write features to file //    Write streamable features from a device to a file. Each node map //    requires a separate feature stream object. When writing to a file, if //    no features are explicitly selected, all will be written by default. // get node map // create feature stream object // stream features to file // destroy feature stream object // Read features to devices //    Read streamable features from from a file to the rest of the devices. //    Again, each node map requires a separate feature stream object. When //    reading from a file, all features saved to the file will be loaded to //    the device. If a device does not have a feature, it is skipped. // get node map // create feature stream object // load features from file // destroy feature stream object