-
Notifications
You must be signed in to change notification settings - Fork 34
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
base: main
Are you sure you want to change the base?
Conversation
@@ -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; |
There was a problem hiding this comment.
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.
virtual auto GetParameter(SilKit::Parameter parameter) -> const std::string& = 0; | |
virtual auto GetParameter(SilKit::Parameter parameter) -> std::string = 0; |
SilKitAPI SilKit_ReturnCode SilKitCALL SilKit_Participant_GetParameter(const char** outParameterValue, | ||
SilKit_Parameter parameter, | ||
SilKit_Participant* participant); |
There was a problem hiding this comment.
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.
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); |
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:
Currently, the
participantName
andregistryURI
are available:#Any more parameters?
How to deal with non-string parameters?