Skip to content

Commit

Permalink
CPPSDK: templates added for metrics calls-metrics methods
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Dec 13, 2023
1 parent f98e970 commit 4fa5cb7
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 0 deletions.
98 changes: 98 additions & 0 deletions src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "${info.title.lowercase}_impl.h"

${if.implementations}
namespace Firebolt {
namespace ${info.Title} {
${if.providers}
/* ${PROVIDERS} */${end.if.providers}
void ${info.Title}Impl::signIn()
{
Firebolt::Error status = Firebolt::Error::NotConnected;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

JsonObject jsonParameters;

WPEFramework::Core::JSON::Boolean jsonResult;
status = transport->Invoke("${info.title.lowercase}.signIn", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title.signIn is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false"));
}

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

void ${info.Title}Impl::signOut()
{
Firebolt::Error status = Firebolt::Error::NotConnected;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

JsonObject jsonParameters;

WPEFramework::Core::JSON::Boolean jsonResult;
status = transport->Invoke("${info.title.lowercase}.signOut", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.signOut is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false"));
}

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

void ${info.Title}Impl::ready()
{
Firebolt::Error status = Firebolt::Error::NotConnected;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

JsonObject jsonParameters;

WPEFramework::Core::JSON::Boolean jsonResult;
status = transport->Invoke("${info.title.lowercase}.ready", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.ready is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false"));
}

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

// Methods
/* ${METHODS} */

// Events
/* ${EVENTS} */

}//namespace ${info.Title}
}${end.if.implementations}
${if.enums}

namespace WPEFramework {


/* ${ENUMS} */

}${end.if.enums}
52 changes: 52 additions & 0 deletions src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include "FireboltSDK.h"
#include "IModule.h"
/* ${IMPORTS} */
#include "${info.title.lowercase}.h"

${if.implementations}
namespace Firebolt {
namespace ${info.Title} {
${if.enums}

/* ${ENUMS:json-types} */${end.if.enums}
${if.types}
// Types
/* ${TYPES:json-types} */${end.if.types}
${if.methods}class ${info.Title}Impl : public I${info.Title}, public IModule {

public:
${info.Title}Impl() = default;
${info.Title}Impl(const ${info.Title}Impl&) = delete;
${info.Title}Impl& operator=(const ${info.Title}Impl&) = delete;

~${info.Title}Impl() override = default;

static void signIn();
static void signOut();
static void ready();
// Methods & Events
/* ${METHODS:declarations-override} */
};${end.if.methods}

}//namespace ${info.Title}
}${end.if.implementations}

0 comments on commit 4fa5cb7

Please sign in to comment.