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

Plugin skeleton generator #117

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
62 changes: 62 additions & 0 deletions PluginSkeletonGenerator/examples/IP_JSONRPC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#
# Copyright 2024 Metrological
#
# 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.

project(IP_JSONRPC)

cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

project_version(1.0.0)

set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})

message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")

set(PLUGIN_IP_JSONRPC_STARTMODE "Activated" CACHE STRING "Automatically start IP_JSONRPC plugin")

if(BUILD_REFERENCE)
add_definitions(-DBUILD_REFERENCE=${BUILD_REFERENCE})
endif()

find_package(${NAMESPACE}Plugins REQUIRED)
find_package(${NAMESPACE}Definitions REQUIRED)
find_package(CompileSettingsDebug CONFIG REQUIRED)

add_library(${MODULE_NAME} SHARED
IP_JSONRPC.cpp
)

set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES)

target_link_libraries(${MODULE_NAME}
PRIVATE
CompileSettingsDebug::CompileSettingsDebug
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions)

target_include_directories( ${MODULE_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
startmode = "@PLUGIN_IP_JSONRPC_STARTMODE@"
56 changes: 56 additions & 0 deletions PluginSkeletonGenerator/examples/IP_JSONRPC/IP_JSONRPC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2024 Metrological
*
* 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.
*/

#include "IP_JSONRPC.h"

namespace Thunder{
namespace Plugin{
namespace {
static Metadata<IP_JSONRPC>metadata(
// Version
1, 0, 0,
// Preconditions
{},
// Terminations
{},
// Controls
{}
)
}

// Implement all methods from IP_JSONRPC.h

const string IP_JSONRPC::Initialize(PluginHost::IShell* service) {
string message;
nxtum marked this conversation as resolved.
Show resolved Hide resolved

ASSERT (service != nullptr);

Config config;
config.FromString(service->ConfigLine());
}

void IP_JSONRPC::Deinitialize(PluginHost::IShell* service) {
nxtum marked this conversation as resolved.
Show resolved Hide resolved

}

string IP_JSONRPC::Information(PluginHost::IShell* service) {
nxtum marked this conversation as resolved.
Show resolved Hide resolved
return string()
}
} // Plugin
} // Thunder
72 changes: 72 additions & 0 deletions PluginSkeletonGenerator/examples/IP_JSONRPC/IP_JSONRPC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2024 Metrological
*
* 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.
*/

#pragma once
#include <interfaces/json/JSON1.h>
#include <interfaces/COM1>

namespace Thunder {
namespace Plugin {

class IP_JSONRPC : public PluginHost::IPlugin, public PluginHost::JSONRPC, public COM1 {
nxtum marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

For allignment (certainly if the user will specify more then one interface better not to have all interfaces on one line

public:
IP_JSONRPC(const IP_JSONRPC&) = delete;
nxtum marked this conversation as resolved.
Show resolved Hide resolved
IP_JSONRPC &operator=(const IP_JSONRPC&) = delete;
IP_JSONRPC() {}
nxtum marked this conversation as resolved.
Show resolved Hide resolved
~IP_JSONRPC override {}
nxtum marked this conversation as resolved.
Show resolved Hide resolved

private:

class Config : public Core::JSON::Container {
private:
Config(const Config&) = delete;
nxtum marked this conversation as resolved.
Show resolved Hide resolved
Config& operator=(const Config&) = delete;
public:
Config()
nxtum marked this conversation as resolved.
Show resolved Hide resolved
: Example("Example")
{
Add(_T("example"), &Example);
}
~Config(){}
nxtum marked this conversation as resolved.
Show resolved Hide resolved
public:
Core::JSON::String Example;
}

public:

// Inherited Methods
nxtum marked this conversation as resolved.
Show resolved Hide resolved
const string Initialize(PluginHost::IShell* service) override;
void Deinitialize(PluginHost::IShell* service) override;
string Information() const override;
void COM1Method1() override;
nxtum marked this conversation as resolved.
Show resolved Hide resolved
void COM1Method2() override;
// Plugin Methods
void IP_JSONRPCMethod(1);
nxtum marked this conversation as resolved.
Show resolved Hide resolved

BEGIN_INTERFACE_MAP(IP_JSONRPC)
nxtum marked this conversation as resolved.
Show resolved Hide resolved
INTERFACE_ENTRY(COM1)
nxtum marked this conversation as resolved.
Show resolved Hide resolved

nxtum marked this conversation as resolved.
Show resolved Hide resolved
END_INTERFACE_MAP
private:
// Include the correct member variables for your plugin:
// Note this is only an example, you are responsible for adding the correct members:
uint32_t _connectionId;
nxtum marked this conversation as resolved.
Show resolved Hide resolved
};
}
}
22 changes: 22 additions & 0 deletions PluginSkeletonGenerator/examples/IP_JSONRPC/Module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2024 Metrological
*
* 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.
*/

#include "Module.h"

MODULE_NAME_DECLARATION(BUILD_REFERENCE)
29 changes: 29 additions & 0 deletions PluginSkeletonGenerator/examples/IP_JSONRPC/Module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2024 Metrological
*
* 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.
*/

#pragma once

#ifndef MODULE_NAME
#define MODULE_NAME Plugin_IP_JSONRPC
#endif

#include <plugins/plugins.h>
nxtum marked this conversation as resolved.
Show resolved Hide resolved

#undef EXTERNAL
#define EXTERNAL
63 changes: 63 additions & 0 deletions PluginSkeletonGenerator/examples/OOP_JSONRPC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#
# Copyright 2024 Metrological
#
# 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.

project(OOP_JSONRPC)

cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

project_version(1.0.0)

set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})

message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")

set(PLUGIN_OOP_JSONRPC_STARTMODE "Activated" CACHE STRING "Automatically start OOP_JSONRPC plugin")

if(BUILD_REFERENCE)
add_definitions(-DBUILD_REFERENCE=${BUILD_REFERENCE})
endif()

find_package(${NAMESPACE}Plugins REQUIRED)
find_package(${NAMESPACE}Definitions REQUIRED)
find_package(CompileSettingsDebug CONFIG REQUIRED)

add_library(${MODULE_NAME} SHARED
OOP_JSONRPC.cpp
OOP_JSONRPCImplementation.cpp
)

set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES)

target_link_libraries(${MODULE_NAME}
PRIVATE
CompileSettingsDebug::CompileSettingsDebug
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions)

target_include_directories( ${MODULE_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()

22 changes: 22 additions & 0 deletions PluginSkeletonGenerator/examples/OOP_JSONRPC/Module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2024 Metrological
*
* 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.
*/

#include "Module.h"

MODULE_NAME_DECLARATION(BUILD_REFERENCE)
29 changes: 29 additions & 0 deletions PluginSkeletonGenerator/examples/OOP_JSONRPC/Module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2024 Metrological
*
* 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.
*/

#pragma once

#ifndef MODULE_NAME
#define MODULE_NAME Plugin_OOP_JSONRPC
#endif

#include <plugins/plugins.h>

#undef EXTERNAL
#define EXTERNAL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
startmode = "@PLUGIN_OOP_JSONRPC_STARTMODE@"
Loading