Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Participant parameters #165

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Participant parameters #165

wants to merge 3 commits into from

Conversation

KonradBkd
Copy link
Contributor

@KonradBkd KonradBkd commented Jan 7, 2025

Get the actual values of SIL Kit parameters that are set by public API and possibly overwritten by the participant configuration.

Instead of a seperate interface per parameter, a enum is handed in specifying which parameter should be obtained:

auto GetParameter(SilKit::Parameter parameter) -> const std::string& override;

Currently, the participantName and registryURI are available:#

enum class Parameter : SilKit_Parameter
{
    //! An undefined parameter
    Undefined = SilKit_Parameter_Undefined,
    //! The name of the participant
    ParticipantName = SilKit_Parameter_ParticipantName,
    //! The registry URI
    RegistryUri = SilKit_Parameter_ReistryUri,
};

Any more parameters?

How to deal with non-string parameters?

@@ -99,6 +101,9 @@ class IParticipant

//! \brief Return the ILogger at this SIL Kit participant.
virtual auto GetLogger() -> Services::Logging::ILogger* = 0;

//! \brief Get a parameter set by an API call and/or the participant configuration.
virtual auto GetParameter(SilKit::Parameter parameter) -> const std::string& = 0;
Copy link
Member

@VDanielEdwards VDanielEdwards Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would produce a new std::string on each invocation. This API shouldn't be called more than once per parameter (under normal circumstances) anyway. This will also simplify the implementation, because the caching in the Hourglass-API can be dropped.

Suggested change
virtual auto GetParameter(SilKit::Parameter parameter) -> const std::string& = 0;
virtual auto GetParameter(SilKit::Parameter parameter) -> std::string = 0;

Comment on lines +94 to +96
SilKitAPI SilKit_ReturnCode SilKitCALL SilKit_Participant_GetParameter(const char** outParameterValue,
SilKit_Parameter parameter,
SilKit_Participant* participant);
Copy link
Member

@VDanielEdwards VDanielEdwards Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we return a single const char * (which is owned by the SIL Kit participant and not to be deallocated by the user) then we have to ensure that the string this is pointing to never changes / gets reallocated. This will work for the current set of parameters (participant name and registry uri won't change), but who knows if we want to provide parameters that could change in the future.

I would propose an API that copies the strings to user-provided buffer in a similar manner to snprintf. It must be allowed to specify the data-pointer as nullptr which will only fill in the size (which can then be used to create an appropriately sized buffer).

Same as with the C++ API, I think copying is fine here - these parameters shouldn't be performance critical or queried in hot-loops.

Suggested change
SilKitAPI SilKit_ReturnCode SilKitCALL SilKit_Participant_GetParameter(const char** outParameterValue,
SilKit_Parameter parameter,
SilKit_Participant* participant);
SilKitAPI SilKit_ReturnCode SilKitCALL SilKit_Participant_GetParameter(char* outParameterValueData,
size_t *outParameterValueSize,
SilKit_Parameter parameter,
SilKit_Participant* participant);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants