Skip to main content
Inspiring
May 16, 2024
Answered

SDK Create a map of install keys and matchnames

  • May 16, 2024
  • 1 reply
  • 381 views

Hi

 

I thought I was real clever when I did this. LOL. The problem is, I can't get it to work. The idea was to put all the install keys and matchname couples into a map. That way i could quicly get the right install keys without having to loop through installed effects every time. Problem is, I keep getting the wrong install keys, which results in the effect added is the wrong effect.

Can anybody see what I'm doing wrong?

 

The classes looks like this:

h:

class InstallKeys
{
public:
	static std::map<A_char, A_long>	keys;
};

class AEGPTools
{
public:
	static PF_Err	SetupInstallKeys(SPBasicSuite* sP);
};

 cpp:

std::map<A_char, A_long> InstallKeys::keys;

PF_Err AEGPTools::SetupInstallKeys(SPBasicSuite* sP)
{
	PF_Err					err = PF_Err_NONE;
	A_long					numInstalledEffects;
	AEGP_InstalledEffectKey	nextKey;

	AEGP_SuiteHandler suites(sP);

	ERR(suites.EffectSuite4()->AEGP_GetNumInstalledEffects(&numInstalledEffects));
	ERR(suites.EffectSuite4()->AEGP_GetNextInstalledEffect(AEGP_InstalledEffectKey_NONE, &nextKey));

	while (!err && nextKey)
	{
		A_char nextMatchName[AEGP_MAX_EFFECT_MATCH_NAME_SIZE] = { '\0' };

		ERR(suites.EffectSuite4()->AEGP_GetEffectMatchName(nextKey, nextMatchName));

		InstallKeys::keys[*nextMatchName] = nextKey;

		ERR(suites.EffectSuite4()->AEGP_GetNextInstalledEffect(nextKey, &nextKey));
	}

	return err;
}

I can then run this once when the app starts:

AEGPTools::SetupInstallKeys(sP);

And then apply an effect like this:

AEGP_EffectRefH			effectRef;
A_char					myMatchName[AEGP_MAX_EFFECT_MATCH_NAME_SIZE] = "ADBE Gaussian Blur 2";
AEGP_InstalledEffectKey	installKey = InstallKeys::keys[*myMatchName];

ERR(suites.EffectSuite4()->AEGP_ApplyEffect(S_my_id, layer, installKey, &effectRef));

But as said, it applies the wrong effect.

 

Thanks,

Jakob

This topic has been closed for replies.
Correct answer shachar carmi

err... i think you're storing just one A_char in the map and not the full string...
shouldn't the map be declated with a string type (or at least an array of A_char) and not just the A_char type?

1 reply

shachar carmiCommunity ExpertCorrect answer
Community Expert
May 16, 2024

err... i think you're storing just one A_char in the map and not the full string...
shouldn't the map be declated with a string type (or at least an array of A_char) and not just the A_char type?

Inspiring
May 16, 2024

Arh, you're right. I keep messing up with strings and char arrays. 

Thanks!