コード例 #1
0
ファイル: ClashAvoider.cpp プロジェクト: EQ4/lad
void
ClashAvoider::set_property(const Raul::URI& subject,
                           const Raul::URI& predicate,
                           const Atom&      value)
{
    _target.set_property(map_uri(subject), predicate, value);
}
コード例 #2
0
ファイル: ClashAvoider.cpp プロジェクト: EQ4/lad
void
ClashAvoider::delta(const Raul::URI&            path,
                    const Resource::Properties& remove,
                    const Resource::Properties& add)
{
    _target.delta(map_uri(path), remove, add);
}
コード例 #3
0
ファイル: ClashAvoider.cpp プロジェクト: EQ4/lad
void
ClashAvoider::put(const Raul::URI&            path,
                  const Resource::Properties& properties,
                  Resource::Graph             ctx)
{
    _target.put(map_uri(path), properties, ctx);
}
コード例 #4
0
ファイル: ClashAvoider.cpp プロジェクト: EQ4/lad
void
ClashAvoider::del(const Raul::URI& uri)
{
    _target.del(map_uri(uri));
}
コード例 #5
0
ファイル: test_plugin.c プロジェクト: AkiraShirase/audacity
static LV2_State_Status
restore(LV2_Handle                  instance,
        LV2_State_Retrieve_Function retrieve,
        void*                       callback_data,
        uint32_t                    flags,
        const LV2_Feature* const*   features)
{
	Test* plugin = (Test*)instance;

	LV2_State_Map_Path* map_path = NULL;
	for (int i = 0; features && features[i]; ++i) {
		if (!strcmp(features[i]->URI, LV2_STATE__mapPath)) {
			map_path = (LV2_State_Map_Path*)features[i]->data;
		}
	}

	size_t   size;
	uint32_t type;
	uint32_t valflags;

	plugin->num_runs = *(int32_t*)retrieve(
		callback_data,
		map_uri(plugin, "http://example.org/num-runs"),
		&size, &type, &valflags);

	if (!map_path) {
		return LV2_STATE_ERR_NO_FEATURE;
	}

	char* apath = (char*)retrieve(
		callback_data,
		map_uri(plugin, "http://example.org/extfile"),
		&size, &type, &valflags);

	if (apath) {
		char*  path   = map_path->absolute_path(map_path->handle, apath);
		FILE*  f      = fopen(path, "r");
		char   str[8];
		size_t n_read = fread(str, 1, sizeof(str), f);
		fclose(f);
		if (strncmp(str, "Hello\n", n_read)) {
			fprintf(stderr, "error: Restored bad file contents `%s' != `Hello'\n",
			        str);
		}
		free(path);
	}

	apath = (char*)retrieve(
		callback_data,
		map_uri(plugin, "http://example.org/save-file"),
		&size, &type, &valflags);
	if (apath) {
		char* spath = map_path->absolute_path(map_path->handle, apath);
		FILE* sfile = fopen(spath, "r");
		if (!sfile) {
			fprintf(stderr, "error: Failed to open save file %s\n", spath);
		} else {
			fclose(sfile);
		}
		free(spath);
	} else {
		fprintf(stderr, "error: Failed to restore save file.\n");
	}

	return LV2_STATE_SUCCESS;
}
コード例 #6
0
ファイル: test_plugin.c プロジェクト: AkiraShirase/audacity
static LV2_State_Status
save(LV2_Handle                instance,
     LV2_State_Store_Function  store,
     void*                     callback_data,
     uint32_t                  flags,
     const LV2_Feature* const* features)
{
	Test* plugin = (Test*)instance;

	LV2_State_Map_Path*  map_path  = NULL;
	LV2_State_Make_Path* make_path = NULL;
	for (int i = 0; features && features[i]; ++i) {
		if (!strcmp(features[i]->URI, LV2_STATE__mapPath)) {
			map_path = (LV2_State_Map_Path*)features[i]->data;
		} else if (!strcmp(features[i]->URI, LV2_STATE__makePath)) {
			make_path = (LV2_State_Make_Path*)features[i]->data;
		}
	}

	store(callback_data,
	      map_uri(plugin, "http://example.org/greeting"),
	      "hello",
	      strlen("hello") + 1,
	      map_uri(plugin, LV2_ATOM__String),
	      LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);

	const uint32_t urid = map_uri(plugin, "http://example.org/urivalue");
	store(callback_data,
	      map_uri(plugin, "http://example.org/uri"),
	      &urid,
	      sizeof(uint32_t),
	      map_uri(plugin, LV2_ATOM__URID),
	      LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);

	store(callback_data,
	      map_uri(plugin, "http://example.org/num-runs"),
	      &plugin->num_runs,
	      sizeof(plugin->num_runs),
	      map_uri(plugin, LV2_ATOM__Int),
	      LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);

	const float two = 2.0f;
	store(callback_data,
	      map_uri(plugin, "http://example.org/two"),
	      &two,
	      sizeof(two),
	      map_uri(plugin, LV2_ATOM__Float),
	      LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);

	const uint32_t affirmative = 1;
	store(callback_data,
	      map_uri(plugin, "http://example.org/true"),
	      &affirmative,
	      sizeof(affirmative),
	      map_uri(plugin, LV2_ATOM__Bool),
	      LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);

	const uint32_t negative = 0;
	store(callback_data,
	      map_uri(plugin, "http://example.org/false"),
	      &negative,
	      sizeof(negative),
	      map_uri(plugin, LV2_ATOM__Bool),
	      LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);

	const uint8_t blob[] = "I am a blob of arbitrary data.";
	store(callback_data,
	      map_uri(plugin, "http://example.org/blob"),
	      blob,
	      sizeof(blob),
	      map_uri(plugin, "http://example.org/SomeUnknownType"),
	      LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);

	if (map_path) {
		FILE* file = fopen(plugin->tmp_file_path, "w");
		fprintf(file, "Hello\n");
		fclose(file);
		char* apath = map_path->abstract_path(map_path->handle,
		                                      plugin->tmp_file_path);
		char* apath2 = map_path->abstract_path(map_path->handle,
		                                       plugin->tmp_file_path);
		if (strcmp(apath, apath2)) {
			fprintf(stderr, "ERROR: Path %s != %s\n", apath, apath2);
		}

		store(callback_data,
		      map_uri(plugin, "http://example.org/extfile"),
		      apath,
		      strlen(apath) + 1,
		      map_uri(plugin, LV2_ATOM__Path),
		      LV2_STATE_IS_PORTABLE);

		free(apath);
		free(apath2);

		if (plugin->rec_file) {
			fflush(plugin->rec_file);
			apath = map_path->abstract_path(map_path->handle,
			                                plugin->rec_file_path);

			store(callback_data,
			      map_uri(plugin, "http://example.org/recfile"),
			      apath,
			      strlen(apath) + 1,
			      map_uri(plugin, LV2_ATOM__Path),
			      LV2_STATE_IS_PORTABLE);

			free(apath);
		}

		if (make_path) {
			char* spath = make_path->path(make_path->handle, "save");
			FILE* sfile = fopen(spath, "w");
			fprintf(sfile, "save");
			fclose(sfile);

			apath = map_path->abstract_path(map_path->handle, spath);
			store(callback_data,
			      map_uri(plugin, "http://example.org/save-file"),
			      apath,
			      strlen(apath) + 1,
			      map_uri(plugin, LV2_ATOM__Path),
			      LV2_STATE_IS_PORTABLE);
			free(apath);
			free(spath);
		}
	}

	return LV2_STATE_SUCCESS;
}