Skip to content

Commit

Permalink
CPPSDK: template added capabilties-method
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Oct 25, 2023
1 parent 24eedc4 commit 7a047df
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 68 deletions.
68 changes: 0 additions & 68 deletions languages/cpp/src/shared/include/firebolt.h

This file was deleted.

5 changes: 5 additions & 0 deletions languages/cpp/templates/declarations-override/default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
${method.name}
${method.description}
*/
${method.signature.result} ${method.Name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err = nullptr )${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid} override;
6 changes: 6 additions & 0 deletions languages/cpp/templates/declarations/default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
${method.name}
${method.description}
${method.params.annotations}${if.deprecated} * @deprecated ${method.deprecation}${end.if.deprecated}
*/
virtual ${method.signature.result} ${method.Name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err = nullptr )${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid} = 0;
Empty file.
23 changes: 23 additions & 0 deletions languages/cpp/templates/methods/default.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* ${method.rpc.name} - ${method.description} */
${method.signature.result} ${info.Title}Impl::${method.Name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err ) ${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid}
{
Firebolt::Error status = Firebolt::Error::NotConnected;
${if.result.nonvoid}${method.result.initialization}${end.if.result.nonvoid}
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

JsonObject jsonParameters;
${method.params.serialization.with.indent}
${method.result.json.type} jsonResult;
status = transport->Invoke("${info.title.lowercase}.${method.rpc.name}", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.${method.rpc.name} is successfully invoked");
${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid}
}

} else {
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Error in getting Transport err = %d", status);
}

return${if.result.nonvoid} ${method.result.name}${end.if.result.nonvoid};
}
Empty file.

0 comments on commit 7a047df

Please sign in to comment.