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

[IStateController] Update with JSON-RPC interface #1833

Merged
merged 14 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/com/Ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ namespace RPC {
ID_SHELL_CONNECTIONSERVER_NOTIFICATION = (ID_OFFSET_INTERNAL + 0x0043),
ID_STATECONTROL = (ID_OFFSET_INTERNAL + 0x0044),
ID_STATECONTROL_NOTIFICATION = (ID_OFFSET_INTERNAL + 0x0045),
ID_STATE_CONTROLLER = (ID_OFFSET_INTERNAL + 0x0046),
ID_STATE_CONTROLLER_NOTIFICATION = (ID_OFFSET_INTERNAL + 0x0047),

ID_SUBSYSTEM = (ID_OFFSET_INTERNAL + 0x0050),
ID_SUBSYSTEM_NOTIFICATION = (ID_OFFSET_INTERNAL + 0x0051),
Expand Down
5 changes: 5 additions & 0 deletions Source/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ ProxyStubGenerator(NAMESPACE "Thunder::PluginHost" INPUT "${CMAKE_CURRENT_SOURCE
ProxyStubGenerator(NAMESPACE "Thunder::PluginHost" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/IShell.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
ProxyStubGenerator(NAMESPACE "Thunder::Exchange" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/IController.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated" INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/..")
ProxyStubGenerator(NAMESPACE "Thunder::PluginHost" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/IStateControl.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
ProxyStubGenerator(NAMESPACE "Thunder::PluginHost" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/IStateController.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
ProxyStubGenerator(NAMESPACE "Thunder::PluginHost" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/ISubSystem.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
ProxyStubGenerator(NAMESPACE "Thunder::PluginHost" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/IDispatcher.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated" INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/..")

JsonGenerator(CODE NAMESPACE Thunder::Exchange::Controller INPUT ${CMAKE_CURRENT_SOURCE_DIR}/IController.h OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/json" INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/.." NO_INCLUDES)
JsonGenerator(CODE NAMESPACE Thunder::PluginHost INPUT ${CMAKE_CURRENT_SOURCE_DIR}/IStateController.h OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/json" INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/.." NO_INCLUDES)

file(GLOB JSON_ENUM_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/json/JsonEnum_*.cpp")
file(GLOB JSON_DATA_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/json/JsonData_*.h" "${CMAKE_CURRENT_BINARY_DIR}/json/json_*.h")
list(APPEND JSON_CODE_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/json/JStateController.h")

add_library(${TARGET} SHARED
Channel.cpp
Expand Down Expand Up @@ -62,6 +65,7 @@ set(PUBLIC_HEADERS
IController.h
Shell.h
IStateControl.h
IStateController.h
StateControl.h
ISubSystem.h
IDispatcher.h
Expand Down Expand Up @@ -163,6 +167,7 @@ install(

install(
FILES ${JSON_DATA_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/plugins/json COMPONENT ${NAMESPACE}_Development
FILES ${JSON_CODE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/plugins/json COMPONENT ${NAMESPACE}_Development
)

install(
Expand Down
2 changes: 2 additions & 0 deletions Source/plugins/IStateControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ namespace PluginHost {
static const TCHAR* ToString(const command value);

virtual Core::hresult Configure(PluginHost::IShell* framework) = 0;

virtual state State() const = 0;

virtual Core::hresult Request(const command state) = 0;

virtual void Register(IStateControl::INotification* notification) = 0;
Expand Down
71 changes: 71 additions & 0 deletions Source/plugins/IStateController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 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 "IShell.h"

#include <com/ICOM.h>

namespace Thunder {

namespace PluginHost {

// This interface gives direct access to change occuring on the remote object
// @json 1.0.0 @text:legacy_lowercase @prefix:statecontrol
struct EXTERNAL IStateController : virtual public Core::IUnknown {

enum { ID = RPC::ID_STATE_CONTROLLER };

enum command : uint8_t {
SUSPEND,
RESUME
};

enum state : uint8_t {
UNKNOWN,
SUSPENDED,
RESUMED
};

// @event
struct INotification : virtual public Core::IUnknown {

enum { ID = RPC::ID_STATE_CONTROLLER_NOTIFICATION };

// @brief Signals a state change of the service
// @param state: Current state of the service
virtual void StateChanged(const state state) = 0;
};

virtual Core::hresult Register(INotification* const notification) = 0;
virtual Core::hresult Unregister(const INotification* const notification) = 0;

// @property
// @brief Running state of the service
virtual Core::hresult State(state& state /* @out */) const = 0;

// @brief Request a change to the specified state
// @param state: State to which it is requested to change
virtual Core::hresult Request(const command state) = 0;
};

} // namespace PluginHost

}
3 changes: 2 additions & 1 deletion Source/plugins/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
// Generated files include this

#include <core/core.h>
#include <IController.h>
#include <IController.h>
#include <IStateController.h>
1 change: 1 addition & 0 deletions Source/plugins/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "ISubSystem.h"
#include "IVirtualInput.h"
#include "JSONRPC.h"
#include "IStateController.h"
#include "Metadata.h"
#include "Request.h"
#include "Service.h"
Expand Down
14 changes: 14 additions & 0 deletions Source/plugins/plugins.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@
<ClInclude Include="IPlugin.h" />
<ClInclude Include="IShell.h" />
<ClInclude Include="IStateControl.h" />
<CustomBuild Include="IStateController.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" --case-convention legacy --no-includes --keep-empty -c --namespace Thunder::PluginHost -o "$(ProjectDir)/json" "%(FullPath)" --force</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" --case-convention legacy --no-includes --keep-empty -c --namespace Thunder::PluginHost -o "$(ProjectDir)/json" "%(FullPath)" --force</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" --case-convention legacy --no-includes --keep-empty -c --namespace Thunder::PluginHost -o "$(ProjectDir)/json" "%(FullPath)" --force</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" --case-convention legacy --no-includes --keep-empty -c --namespace Thunder::PluginHost -o "$(ProjectDir)/json" "%(FullPath)" --force</Command>
</CustomBuild>
<ClInclude Include="ISubSystem.h" />
<ClInclude Include="JSONRPC.h" />
<ClInclude Include="Metadata.h" />
Expand Down
5 changes: 4 additions & 1 deletion Source/plugins/plugins.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,8 @@
<CustomBuild Include="IController.h">
<Filter>Interface Files</Filter>
</CustomBuild>
<CustomBuild Include="IStateController.h">
<Filter>Interface Files</Filter>
</CustomBuild>
</ItemGroup>
</Project>
</Project>
Loading