init
This commit is contained in:
commit
4689ed7374
|
@ -0,0 +1,3 @@
|
||||||
|
x64/
|
||||||
|
PenetrateBasic/x64/
|
||||||
|
.vs/
|
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.10.35122.118
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PenetrateBasic", "PenetrateBasic\PenetrateBasic.vcxproj", "{D8292764-1B3E-401E-858B-BBBD8F07BEC5}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{D8292764-1B3E-401E-858B-BBBD8F07BEC5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{D8292764-1B3E-401E-858B-BBBD8F07BEC5}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{D8292764-1B3E-401E-858B-BBBD8F07BEC5}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{D8292764-1B3E-401E-858B-BBBD8F07BEC5}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B111E4D7-F1F3-45C3-A97D-75752139749D}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{D8292764-1B3E-401E-858B-BBBD8F07BEC5}</ProjectGuid>
|
||||||
|
<Keyword>QtVS_v304</Keyword>
|
||||||
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0</WindowsTargetPlatformVersion>
|
||||||
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
|
||||||
|
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
|
||||||
|
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||||
|
<QtInstall>5.12.11_msvc2017_64</QtInstall>
|
||||||
|
<QtModules>core</QtModules>
|
||||||
|
<QtBuildConfig>debug</QtBuildConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||||
|
<QtInstall>5.12.11_msvc2017_64</QtInstall>
|
||||||
|
<QtModules>core</QtModules>
|
||||||
|
<QtBuildConfig>release</QtBuildConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||||
|
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||||
|
</Target>
|
||||||
|
<ImportGroup Label="ExtensionSettings" />
|
||||||
|
<ImportGroup Label="Shared" />
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
<ClCompile>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||||
|
<ClCompile>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="dispatch.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="cmds.h" />
|
||||||
|
<ClInclude Include="cmds_basic.h" />
|
||||||
|
<ClInclude Include="data_types.h" />
|
||||||
|
<ClInclude Include="dispatch.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||||
|
<Import Project="$(QtMsBuild)\qt.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Form Files">
|
||||||
|
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
||||||
|
<Extensions>ui</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Translation Files">
|
||||||
|
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||||
|
<Extensions>ts</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dispatch.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="cmds_basic.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="dispatch.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="cmds.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="data_types.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<QtTouchProperty>
|
||||||
|
</QtTouchProperty>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<QtTouchProperty>
|
||||||
|
</QtTouchProperty>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,47 @@
|
||||||
|
#pragma once
|
||||||
|
#include "dispatch.h"
|
||||||
|
#include "cmds_basic.h"
|
||||||
|
|
||||||
|
namespace cmds {
|
||||||
|
template<typename... Types> struct T;
|
||||||
|
template<typename Ret, typename... Args> struct T<Ret(Args...)> {
|
||||||
|
public:
|
||||||
|
template<Inlet::Callable<Ret, Args...> func> struct Cmd {
|
||||||
|
private:
|
||||||
|
dispatch::Dispatch* _core_bind;
|
||||||
|
QString _name_value;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Cmd(dispatch::Dispatch* core, const QString& name)
|
||||||
|
: _core_bind(core), _name_value(name) {
|
||||||
|
auto inst = Inlet::CmdsImpl<(void*) func, Ret, Args...>::global();
|
||||||
|
core->registerCmd(inst->address(), inst, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ret operator()(Args... args) {
|
||||||
|
Inlet::CmdsImpl<(void*) func, Ret, Args...> new_inst(args...);
|
||||||
|
_core_bind->runWith(&new_inst);
|
||||||
|
return new_inst.result();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<Inlet::Callable<Ret, Args...> func> struct Event {
|
||||||
|
private:
|
||||||
|
dispatch::Dispatch* _core_bind;
|
||||||
|
QString _name_value;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Event(dispatch::Dispatch* core, const QString& name)
|
||||||
|
: _core_bind(core), _name_value(name) {
|
||||||
|
auto inst = Inlet::EventsImpl<(void*) func, Ret, Args...>::global();
|
||||||
|
core->registerEvent(inst->address(), inst, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator()(Args... args) {
|
||||||
|
Inlet::EventsImpl<(void*)func, Ret, Args...> new_inst(args...);
|
||||||
|
_core_bind->notifyWith(&new_inst);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,168 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <QString>
|
||||||
|
#include "data_types.h"
|
||||||
|
|
||||||
|
namespace Inlet {
|
||||||
|
template<typename... Types> struct SignatureImpl;
|
||||||
|
template<> struct SignatureImpl<> {
|
||||||
|
public:
|
||||||
|
SignatureImpl() { }
|
||||||
|
|
||||||
|
void execute(std::function<void(void)> unit) {
|
||||||
|
unit();
|
||||||
|
}
|
||||||
|
void result() const { }
|
||||||
|
|
||||||
|
void saveTo(int index, datas::IDataObject &object) { }
|
||||||
|
void loadFrom(int index, datas::IDataObject &object) { }
|
||||||
|
};
|
||||||
|
template<typename Ret> struct SignatureImpl<Ret> {
|
||||||
|
private:
|
||||||
|
Ret _result;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SignatureImpl() : _result(Ret()) { }
|
||||||
|
|
||||||
|
Ret execute(std::function<Ret(void)> unit) {
|
||||||
|
_result = unit();
|
||||||
|
return _result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ret result() const {
|
||||||
|
return _result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveTo(int index, datas::IDataObject &object) {
|
||||||
|
datas::dataSet<Ret>(object, u8"RetValue", _result);
|
||||||
|
}
|
||||||
|
void loadFrom(int index, datas::IDataObject &object) {
|
||||||
|
_result = datas::dataGet<Ret>(object, u8"RetValue");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename Ret, typename First, typename... Args>
|
||||||
|
struct SignatureImpl<Ret, First, Args...> : public SignatureImpl<Ret, Args...> {
|
||||||
|
private:
|
||||||
|
First _args_value;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SignatureImpl() : SignatureImpl<Ret, Args...>(), _args_value(First()) { }
|
||||||
|
SignatureImpl(First a0, Args... args) :SignatureImpl<Ret, Args...>(args...), _args_value(a0) { }
|
||||||
|
|
||||||
|
Ret execute(std::function<Ret(First, Args...)> unit) {
|
||||||
|
auto unit_wrap = [&](Args... args) {
|
||||||
|
return unit(_args_value, args...);
|
||||||
|
};
|
||||||
|
return SignatureImpl<Ret, Args...>::execute(unit_wrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void saveTo(int index, datas::IDataObject &object) {
|
||||||
|
datas::dataSet<First>(object, QString(u8"Args_%1").arg(index), _args_value);
|
||||||
|
SignatureImpl<Ret, Args...>::saveTo(index + 1, object);
|
||||||
|
}
|
||||||
|
void loadFrom(int index, datas::IDataObject &object) {
|
||||||
|
_args_value = datas::dataGet<First>(object, QString(u8"Args_%1").arg(index));
|
||||||
|
SignatureImpl<Ret, Args...>::loadFrom(index + 1, object);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class IRunbase {
|
||||||
|
public:
|
||||||
|
virtual ~IRunbase() = default;
|
||||||
|
|
||||||
|
virtual quint64 address() const = 0;
|
||||||
|
virtual void run() = 0;
|
||||||
|
|
||||||
|
virtual void saveTo(datas::IDataObject& object) = 0;
|
||||||
|
virtual void loadFrom(datas::IDataObject& object) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Ret, typename... Args> using Callable = Ret(*)(Args...);
|
||||||
|
|
||||||
|
template<void* addr, typename Ret, typename... Args> struct CmdsImpl : public IRunbase {
|
||||||
|
private:
|
||||||
|
Callable<Ret, Args...> _func = (Callable<Ret, Args...>)addr;
|
||||||
|
SignatureImpl<Ret, Args...> _args_value;
|
||||||
|
|
||||||
|
static CmdsImpl<addr, Ret, Args...>* _global_inst;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CmdsImpl() : _args_value() { }
|
||||||
|
CmdsImpl(Args... args) :_args_value(args...) { }
|
||||||
|
|
||||||
|
static CmdsImpl<addr, Ret, Args...>* global() {
|
||||||
|
if (!_global_inst) {
|
||||||
|
_global_inst = new CmdsImpl<addr, Ret, Args...>();
|
||||||
|
}
|
||||||
|
return _global_inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ret execute(Args... args) {
|
||||||
|
_args_value = SignatureImpl<Ret, Args...>(args...);
|
||||||
|
return _args_value.execute(_func);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ret result() const {
|
||||||
|
return _args_value.result();
|
||||||
|
}
|
||||||
|
|
||||||
|
// IRunbase
|
||||||
|
quint64 address() const {
|
||||||
|
return (quint64) addr;
|
||||||
|
}
|
||||||
|
void run() {
|
||||||
|
_args_value.execute(_func);
|
||||||
|
}
|
||||||
|
virtual void saveTo(datas::IDataObject &object) {
|
||||||
|
_args_value.saveTo(0, object);
|
||||||
|
}
|
||||||
|
virtual void loadFrom(datas::IDataObject &object) {
|
||||||
|
_args_value.loadFrom(0, object);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<void* addr, typename Ret, typename... Args> CmdsImpl<addr, Ret, Args...>* CmdsImpl<addr, Ret, Args...>::_global_inst = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
template<void* addr, typename Ret, typename... Args> struct EventsImpl : public IRunbase {
|
||||||
|
private:
|
||||||
|
Callable<Ret, Args...> _func = (Callable<Ret, Args...>)addr;
|
||||||
|
SignatureImpl<Ret, Args...> _args_value;
|
||||||
|
|
||||||
|
static EventsImpl<addr, Ret, Args...>* _global_inst;
|
||||||
|
|
||||||
|
public:
|
||||||
|
EventsImpl() : _args_value() { }
|
||||||
|
EventsImpl(Args... args) : _args_value(args...) { }
|
||||||
|
|
||||||
|
static EventsImpl<addr, Ret, Args...>* global() {
|
||||||
|
if (!_global_inst) {
|
||||||
|
_global_inst = new EventsImpl<addr, Ret, Args...>();
|
||||||
|
}
|
||||||
|
return _global_inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
void execute(Args... args) {
|
||||||
|
_args_value = SignatureImpl<Ret, Args...>(args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IRunbase
|
||||||
|
quint64 address() const {
|
||||||
|
return (quint64) addr;
|
||||||
|
}
|
||||||
|
void run() {
|
||||||
|
_args_value.execute(_func);
|
||||||
|
}
|
||||||
|
virtual void saveTo(datas::IDataObject &object) {
|
||||||
|
_args_value.saveTo(0, object);
|
||||||
|
}
|
||||||
|
virtual void loadFrom(datas::IDataObject &object) {
|
||||||
|
_args_value.loadFrom(0, object);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<void* addr, typename Ret, typename... Args> EventsImpl<addr, Ret, Args...>* EventsImpl<addr, Ret, Args...>::_global_inst = nullptr;
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace datas {
|
||||||
|
|
||||||
|
class IDataArray;
|
||||||
|
class IDataObject {
|
||||||
|
public:
|
||||||
|
virtual ~IDataObject() = default;
|
||||||
|
|
||||||
|
virtual bool isArray() const = 0;
|
||||||
|
|
||||||
|
virtual bool getBool(const QString& key) = 0;
|
||||||
|
virtual double getDouble(const QString& key) = 0;
|
||||||
|
virtual int32_t getInt32(const QString& key) = 0;
|
||||||
|
virtual int64_t getInt64(const QString& key) = 0;
|
||||||
|
virtual QString getString(const QString& key) = 0;
|
||||||
|
virtual IDataObject getObject(const QString& key) = 0;
|
||||||
|
virtual IDataArray toArray() = 0;
|
||||||
|
|
||||||
|
virtual void setBool(const QString& key, bool value) = 0;
|
||||||
|
virtual void setDouble(const QString& key, double value) = 0;
|
||||||
|
virtual void setInt32(const QString& key, int32_t value) = 0;
|
||||||
|
virtual void setInt64(const QString& key, int64_t value) = 0;
|
||||||
|
virtual void setString(const QString& key, const QString& value) = 0;
|
||||||
|
virtual void setObject(const QString& key, IDataObject value) = 0;
|
||||||
|
};
|
||||||
|
class IDataArray : public IDataObject {
|
||||||
|
public:
|
||||||
|
virtual ~IDataArray() = default;
|
||||||
|
|
||||||
|
virtual int32_t size() const = 0;
|
||||||
|
virtual IDataObject get(int index) = 0;
|
||||||
|
virtual void insert(int index, IDataObject value) = 0;
|
||||||
|
virtual void append(IDataObject value) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T> void dataSet(IDataObject& object, const QString& key, T value);
|
||||||
|
template<typename T> T dataGet(IDataObject& object, const QString& key);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "dispatch.h"
|
||||||
|
|
||||||
|
using namespace dispatch;
|
||||||
|
using namespace Inlet;
|
||||||
|
|
||||||
|
QList<quint64> Dispatch::allCmds() const {
|
||||||
|
return _cmds_map.keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dispatch::registerCmd(quint64 addr, IRunbase* unit, const QString& alias) {
|
||||||
|
_cmds_map[addr] = std::make_pair(alias, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Dispatch::getCmdAlias(quint64 addr) const {
|
||||||
|
return _cmds_map[addr].first;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Dispatch::getCmdDefault(quint64 addr) const {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dispatch::runWith(IRunbase* unit) {
|
||||||
|
unit->run();
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QHash>
|
||||||
|
#include "cmds_basic.h"
|
||||||
|
|
||||||
|
namespace dispatch {
|
||||||
|
|
||||||
|
class IOutput {
|
||||||
|
public:
|
||||||
|
virtual ~IOutput() = default;
|
||||||
|
|
||||||
|
virtual void write(const QString &title, const QString& desc) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Dispatch {
|
||||||
|
private:
|
||||||
|
QHash<quint64, std::pair<QString, Inlet::IRunbase*>> _cmds_map;
|
||||||
|
QHash<quint64, std::pair<QString, Inlet::IRunbase*>> _events_map;
|
||||||
|
|
||||||
|
QList<IOutput*> _output_list;
|
||||||
|
|
||||||
|
public:
|
||||||
|
QList<quint64> allCmds() const;
|
||||||
|
void registerCmd(quint64 addr, Inlet::IRunbase* unit, const QString& alias);
|
||||||
|
QString getCmdAlias(quint64 addr) const;
|
||||||
|
QString getCmdDefault(quint64 addr) const;
|
||||||
|
void runWith(Inlet::IRunbase* unit);
|
||||||
|
|
||||||
|
QList<quint64> allEvents() const;
|
||||||
|
void registerEvent(quint64 addr, Inlet::IRunbase* unit, const QString& alias);
|
||||||
|
QString getEventAlias(quint64 addr) const;
|
||||||
|
QString getEventDefault(quint64 addr) const;
|
||||||
|
QString notifyWith(Inlet::IRunbase* unit);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <qdebug.h>
|
||||||
|
|
||||||
|
#include "cmds_basic.h"
|
||||||
|
#include "dispatch.h"
|
||||||
|
#include "cmds.h"
|
||||||
|
|
||||||
|
dispatch::Dispatch c;
|
||||||
|
|
||||||
|
|
||||||
|
int vp(int c) {
|
||||||
|
qDebug() << c;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
cmds::T<int(int)>::Cmd<vp> entry(&c, "hello");
|
||||||
|
|
||||||
|
namespace xproc {
|
||||||
|
int xmp(int arg) {
|
||||||
|
qDebug() << "xmp";
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmds::T<int(int)>::Cmd<xmp> xvv(&c, "sfaf");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Inlet;
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
|
SignatureImpl<int, int> v(3);
|
||||||
|
v.execute(vp);
|
||||||
|
|
||||||
|
Callable<int, int> vptr = vp;
|
||||||
|
|
||||||
|
CmdsImpl<(void*) vp, int, int> exec;
|
||||||
|
exec.execute(5);
|
||||||
|
|
||||||
|
entry(50);
|
||||||
|
|
||||||
|
xproc::xvv(2);
|
||||||
|
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> void datas::dataSet<int>(IDataObject& object, const QString& key, int value) { }
|
||||||
|
template<> int datas::dataGet<int>(IDataObject& object, const QString& key) {
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue