Compare commits
5
Commits
master
...
1a2722da57
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a2722da57 | ||
|
|
12deed7aee | ||
|
|
33941a823c | ||
|
|
ca7db648f8 | ||
|
|
7a158a0bf8 |
@@ -0,0 +1,3 @@
|
|||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 2
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
!/tests
|
!/tests
|
||||||
|
|
||||||
# Include files
|
# Include files
|
||||||
|
!/.clang-format
|
||||||
!/.gitignore
|
!/.gitignore
|
||||||
!/CMakeLists.txt
|
!/CMakeLists.txt
|
||||||
!/Makefile
|
!/Makefile
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef __MCS_ENGINE_HPP__
|
#ifndef __MCS_ENGINE_HPP__
|
||||||
#define __MCS_ENGINE_HPP__
|
#define __MCS_ENGINE_HPP__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <engine/core/engine_db_provider.hpp>
|
||||||
#include <engine/core/engine_module.hpp>
|
#include <engine/core/engine_module.hpp>
|
||||||
#include <engine/core/engine_module_api.hpp>
|
#include <engine/core/engine_module_api.hpp>
|
||||||
#include <engine/core/engine_db_provider.hpp>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -12,21 +12,37 @@
|
|||||||
class MscEngine : public IMscEngineModuleAPI
|
class MscEngine : public IMscEngineModuleAPI
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/// Loaded modules list
|
/// @brief Loaded modules list
|
||||||
std::vector<std::shared_ptr<MscEngineModule>> _modules;
|
std::vector<std::shared_ptr<MscEngineModule>> _modules;
|
||||||
|
|
||||||
|
/// @brief Common event bus
|
||||||
MscEventBus _bus;
|
MscEventBus _bus;
|
||||||
|
|
||||||
|
/// @brief Is engine running rn
|
||||||
|
bool _isRunning = false;
|
||||||
|
|
||||||
|
/// @brief Last update time
|
||||||
|
clock::time_point _lastUpdate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Actual version
|
/// Actual version
|
||||||
static uint16_t REV;
|
static uint16_t REV;
|
||||||
|
|
||||||
MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules);
|
MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules);
|
||||||
|
|
||||||
|
/// @brief Start engine
|
||||||
|
void start();
|
||||||
|
|
||||||
|
/// @brief Stop engine
|
||||||
|
void stop();
|
||||||
|
|
||||||
MscEventBus &getBus() override;
|
MscEventBus &getBus() override;
|
||||||
std::unordered_map<std::string, std::uint16_t> getLoadedModules() const override;
|
std::unordered_map<std::string, std::uint16_t>
|
||||||
|
getLoadedModules() const override;
|
||||||
MscEngineModule &getModule(const std::string &name) override;
|
MscEngineModule &getModule(const std::string &name) override;
|
||||||
std::unique_ptr<MscEngineDBProvider> createDBProvider() override;
|
std::unique_ptr<MscEngineDBProvider> createDBProvider() override;
|
||||||
std::unique_ptr<MscEngineDBProvider> createDBProvider(const std::string &filepath) override;
|
std::unique_ptr<MscEngineDBProvider>
|
||||||
|
createDBProvider(const std::string &filepath) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __MCS_ENGINE_HPP__
|
#endif // __MCS_ENGINE_HPP__
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef __MCS_ENGINE_MODULE_HPP__
|
#ifndef __MCS_ENGINE_MODULE_HPP__
|
||||||
#define __MCS_ENGINE_MODULE_HPP__
|
#define __MCS_ENGINE_MODULE_HPP__
|
||||||
|
|
||||||
#include "engine/utils/rev_range.hpp"
|
|
||||||
#include "engine/core/engine_module_api.hpp"
|
#include "engine/core/engine_module_api.hpp"
|
||||||
|
#include "engine/utils/rev_range.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -23,8 +23,27 @@ public:
|
|||||||
virtual const std::unordered_map<std::string, MscRevisionRange> &
|
virtual const std::unordered_map<std::string, MscRevisionRange> &
|
||||||
getDependencies() const = 0;
|
getDependencies() const = 0;
|
||||||
|
|
||||||
/// Module initialization phase
|
/// @brief Module initialization
|
||||||
|
/// @param engine engine public API for modules
|
||||||
virtual void onInitialize(IMscEngineModuleAPI &engine) = 0;
|
virtual void onInitialize(IMscEngineModuleAPI &engine) = 0;
|
||||||
|
|
||||||
|
/// @brief Engine start event handler
|
||||||
|
/// @param engine engine public API for modules
|
||||||
|
virtual void onStart(IMscEngineModuleAPI &engine) = 0;
|
||||||
|
|
||||||
|
/// @brief Engine update cycle step
|
||||||
|
/// @param engine engine public API for modules
|
||||||
|
/// @param dt loop delta
|
||||||
|
virtual void onUpdate(IMscEngineModuleAPI &engine,
|
||||||
|
IMscEngineModuleAPI::clock::duration dt) = 0;
|
||||||
|
|
||||||
|
/// @brief Engine stop event handler
|
||||||
|
/// @param engine engine public API for modules
|
||||||
|
virtual void onStop(IMscEngineModuleAPI &engine) = 0;
|
||||||
|
|
||||||
|
/// @brief Module destroying
|
||||||
|
/// @param engine engine public API for modules
|
||||||
|
virtual void onDestory(IMscEngineModuleAPI &engine) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __MCS_ENGINE_MODULE_HPP__
|
#endif // __MCS_ENGINE_MODULE_HPP__
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
#ifndef __MSC_ENGINE_MODULE_API_HPP__
|
#ifndef __MSC_ENGINE_MODULE_API_HPP__
|
||||||
#define __MSC_ENGINE_MODULE_API_HPP__
|
#define __MSC_ENGINE_MODULE_API_HPP__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <engine/core/engine_bus.hpp>
|
#include <engine/core/engine_bus.hpp>
|
||||||
#include <engine/core/engine_db_provider.hpp>
|
#include <engine/core/engine_db_provider.hpp>
|
||||||
#include <cstdint>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class MscEngineModule;
|
class MscEngineModule;
|
||||||
|
|
||||||
class IMscEngineModuleAPI
|
class IMscEngineModuleAPI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using clock = std::chrono::steady_clock;
|
||||||
|
|
||||||
virtual ~IMscEngineModuleAPI() = default;
|
virtual ~IMscEngineModuleAPI() = default;
|
||||||
|
|
||||||
/// @brief Get access to engine event bus
|
/// @brief Get access to engine event bus
|
||||||
virtual MscEventBus &getBus() = 0;
|
virtual MscEventBus &getBus() = 0;
|
||||||
|
|
||||||
/// @brief Get access to loaded module list
|
/// @brief Get access to loaded module list
|
||||||
virtual std::unordered_map<std::string, std::uint16_t> getLoadedModules() const = 0;
|
virtual std::unordered_map<std::string, std::uint16_t>
|
||||||
|
getLoadedModules() const = 0;
|
||||||
|
|
||||||
/// @brief Access module by its name
|
/// @brief Access module by its name
|
||||||
virtual MscEngineModule &getModule(const std::string &name) = 0;
|
virtual MscEngineModule &getModule(const std::string &name) = 0;
|
||||||
@@ -28,7 +31,8 @@ public:
|
|||||||
virtual std::unique_ptr<MscEngineDBProvider> createDBProvider() = 0;
|
virtual std::unique_ptr<MscEngineDBProvider> createDBProvider() = 0;
|
||||||
|
|
||||||
/// @brief Create database provider with file database
|
/// @brief Create database provider with file database
|
||||||
virtual std::unique_ptr<MscEngineDBProvider> createDBProvider(const std::string &filepath) = 0;
|
virtual std::unique_ptr<MscEngineDBProvider>
|
||||||
|
createDBProvider(const std::string &filepath) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __MSC_ENGINE_MODULE_API_HPP__
|
#endif // __MSC_ENGINE_MODULE_API_HPP__
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
#ifndef __MSC_TEST_1_MODULE_HPP__
|
|
||||||
#define __MSC_TEST_1_MODULE_HPP__
|
|
||||||
|
|
||||||
#include "engine/core/engine_module.hpp"
|
|
||||||
#include "engine/core/engine_module_api.hpp"
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class Test1Module : public MscEngineModule
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
~Test1Module() = default;
|
|
||||||
|
|
||||||
std::string getName() const override;
|
|
||||||
uint16_t getRev() const override;
|
|
||||||
const std::unordered_map<std::string, MscRevisionRange> &
|
|
||||||
getDependencies() const override;
|
|
||||||
|
|
||||||
void onInitialize(IMscEngineModuleAPI &engine) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __MSC_TEST_1_MODULE_HPP__
|
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
|
#include "engine/core/engine_module_api.hpp"
|
||||||
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <engine/core/engine.hpp>
|
#include <engine/core/engine.hpp>
|
||||||
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
uint16_t MscEngine::REV = 0;
|
std::uint16_t MscEngine::REV = 1;
|
||||||
|
|
||||||
MscEngine::MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules)
|
MscEngine::MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules)
|
||||||
{
|
{
|
||||||
@@ -49,17 +53,71 @@ MscEngine::MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules)
|
|||||||
std::to_string(current_rev));
|
std::to_string(current_rev));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.get()->onInitialize(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
_modules = std::move(modules);
|
_modules = std::move(modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
MscEventBus &MscEngine::getBus()
|
void MscEngine::start()
|
||||||
{
|
{
|
||||||
return _bus;
|
if (_isRunning)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isRunning = true;
|
||||||
|
_lastUpdate = clock::now();
|
||||||
|
|
||||||
|
for (auto &m : _modules)
|
||||||
|
m->onStart(*this);
|
||||||
|
|
||||||
|
constexpr auto tickDuration = std::chrono::milliseconds(50);
|
||||||
|
auto nextTick = clock::now();
|
||||||
|
|
||||||
|
using UpdateFn = std::function<void(IMscEngineModuleAPI & engine,
|
||||||
|
IMscEngineModuleAPI::clock::duration dt)>;
|
||||||
|
std::vector<UpdateFn> updateFns;
|
||||||
|
updateFns.reserve(_modules.size());
|
||||||
|
|
||||||
|
for (auto &m : _modules)
|
||||||
|
updateFns.emplace_back([m](IMscEngineModuleAPI &engine,
|
||||||
|
IMscEngineModuleAPI::clock::duration dt)
|
||||||
|
{ m->onUpdate(engine, dt); });
|
||||||
|
|
||||||
|
while (_isRunning)
|
||||||
|
{
|
||||||
|
nextTick += tickDuration;
|
||||||
|
const auto currentTick = clock::now();
|
||||||
|
const auto dt = currentTick - _lastUpdate;
|
||||||
|
|
||||||
|
// TODO: process
|
||||||
|
|
||||||
|
for (auto upd : updateFns)
|
||||||
|
upd(*this, dt);
|
||||||
|
|
||||||
|
_lastUpdate = currentTick;
|
||||||
|
|
||||||
|
std::this_thread::sleep_until(nextTick);
|
||||||
|
if (clock::now() > nextTick + std::chrono::seconds(1))
|
||||||
|
nextTick = clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &m : _modules)
|
||||||
|
m->onStop(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<std::string, std::uint16_t> MscEngine::getLoadedModules() const
|
void MscEngine::stop()
|
||||||
|
{
|
||||||
|
if (!_isRunning)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MscEventBus &MscEngine::getBus() { return _bus; }
|
||||||
|
|
||||||
|
std::unordered_map<std::string, std::uint16_t>
|
||||||
|
MscEngine::getLoadedModules() const
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, std::uint16_t> result;
|
std::unordered_map<std::string, std::uint16_t> result;
|
||||||
for (const auto &module : _modules)
|
for (const auto &module : _modules)
|
||||||
@@ -90,7 +148,8 @@ std::unique_ptr<MscEngineDBProvider> MscEngine::createDBProvider()
|
|||||||
return std::make_unique<MscEngineDBProvider>();
|
return std::make_unique<MscEngineDBProvider>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MscEngineDBProvider> MscEngine::createDBProvider(const std::string &filepath)
|
std::unique_ptr<MscEngineDBProvider>
|
||||||
|
MscEngine::createDBProvider(const std::string &filepath)
|
||||||
{
|
{
|
||||||
return std::make_unique<MscEngineDBProvider>(filepath);
|
return std::make_unique<MscEngineDBProvider>(filepath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
#include "engine/modules/test1/test1.hpp"
|
|
||||||
#include "engine/core/engine_module_api.hpp"
|
|
||||||
#include "engine/utils/rev_range.hpp"
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
std::string Test1Module::getName() const { return "test1"; }
|
|
||||||
|
|
||||||
uint16_t Test1Module::getRev() const { return 1; }
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, MscRevisionRange> &
|
|
||||||
Test1Module::getDependencies() const
|
|
||||||
{
|
|
||||||
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
|
||||||
return deps;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test1Module::onInitialize(IMscEngineModuleAPI &engine)
|
|
||||||
{
|
|
||||||
(void)(engine);
|
|
||||||
}
|
|
||||||
+1
-8
@@ -1,16 +1,9 @@
|
|||||||
#include "engine/modules/test1/test1.hpp"
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <engine/core/engine.hpp>
|
#include <engine/core/engine.hpp>
|
||||||
#include <memory>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
auto engine =
|
printf("Hello, engine!\n");
|
||||||
std::make_unique<MscEngine>(std::vector<std::shared_ptr<MscEngineModule>>{
|
|
||||||
std::make_shared<Test1Module>()});
|
|
||||||
|
|
||||||
printf("Hello, CMake, %p!\n", &engine);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+100
-92
@@ -1,149 +1,157 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <engine/utils/rev_range.hpp>
|
|
||||||
#include <engine/core/engine.hpp>
|
#include <engine/core/engine.hpp>
|
||||||
#include <engine/core/engine_module.hpp>
|
#include <engine/core/engine_module.hpp>
|
||||||
|
#include <engine/utils/rev_range.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
class FirstTestModuleR1 : public MscEngineModule
|
class FirstTestModuleR1 : public MscEngineModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string getName() const override
|
std::string getName() const override { return "first_tmod"; };
|
||||||
{
|
|
||||||
return "first_tmod";
|
|
||||||
};
|
|
||||||
|
|
||||||
std::uint16_t getRev() const override
|
std::uint16_t getRev() const override { return 1; }
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, MscRevisionRange> &getDependencies() const override
|
const std::unordered_map<std::string, MscRevisionRange> &
|
||||||
{
|
getDependencies() const override
|
||||||
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
{
|
||||||
return deps;
|
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
||||||
}
|
return deps;
|
||||||
|
}
|
||||||
|
|
||||||
void onInitialize(IMscEngineModuleAPI &engine) override {}
|
void onInitialize(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onStart(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onUpdate(IMscEngineModuleAPI &engine,
|
||||||
|
IMscEngineModuleAPI::clock::duration dt) override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void onStop(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onDestory(IMscEngineModuleAPI &engine) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FirstTestModuleR2 : public MscEngineModule
|
class FirstTestModuleR2 : public MscEngineModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string getName() const override
|
std::string getName() const override { return "first_tmod"; };
|
||||||
{
|
|
||||||
return "first_tmod";
|
|
||||||
};
|
|
||||||
|
|
||||||
std::uint16_t getRev() const override
|
std::uint16_t getRev() const override { return 2; }
|
||||||
{
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, MscRevisionRange> &getDependencies() const override
|
const std::unordered_map<std::string, MscRevisionRange> &
|
||||||
{
|
getDependencies() const override
|
||||||
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
{
|
||||||
return deps;
|
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
||||||
}
|
return deps;
|
||||||
|
}
|
||||||
|
|
||||||
void onInitialize(IMscEngineModuleAPI &engine) override {}
|
void onInitialize(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onStart(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onUpdate(IMscEngineModuleAPI &engine,
|
||||||
|
IMscEngineModuleAPI::clock::duration dt) override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void onStop(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onDestory(IMscEngineModuleAPI &engine) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SecondTestModuleE1 : public MscEngineModule
|
class SecondTestModuleE1 : public MscEngineModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string getName() const override
|
std::string getName() const override { return "second_tmod"; }
|
||||||
{
|
|
||||||
return "second_tmod";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::uint16_t getRev() const override
|
std::uint16_t getRev() const override { return 1; }
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, MscRevisionRange> &getDependencies() const override
|
const std::unordered_map<std::string, MscRevisionRange> &
|
||||||
{
|
getDependencies() const override
|
||||||
static const std::unordered_map<std::string, MscRevisionRange> deps{
|
{
|
||||||
{"first_tmod", MscRevisionRange{1, 1}}};
|
static const std::unordered_map<std::string, MscRevisionRange> deps{
|
||||||
return deps;
|
{"first_tmod", MscRevisionRange{1, 1}}};
|
||||||
}
|
return deps;
|
||||||
|
}
|
||||||
|
|
||||||
void onInitialize(IMscEngineModuleAPI &engine) override {}
|
void onInitialize(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onStart(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onUpdate(IMscEngineModuleAPI &engine,
|
||||||
|
IMscEngineModuleAPI::clock::duration dt) override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void onStop(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onDestory(IMscEngineModuleAPI &engine) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SecondTestModuleE2 : public MscEngineModule
|
class SecondTestModuleE2 : public MscEngineModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string getName() const override
|
std::string getName() const override { return "second_tmod"; }
|
||||||
{
|
|
||||||
return "second_tmod";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::uint16_t getRev() const override
|
std::uint16_t getRev() const override { return 1; }
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, MscRevisionRange> &getDependencies() const override
|
const std::unordered_map<std::string, MscRevisionRange> &
|
||||||
{
|
getDependencies() const override
|
||||||
static const std::unordered_map<std::string, MscRevisionRange> deps{
|
{
|
||||||
{"first_tmod", MscRevisionRange{1, 2}}};
|
static const std::unordered_map<std::string, MscRevisionRange> deps{
|
||||||
return deps;
|
{"first_tmod", MscRevisionRange{1, 2}}};
|
||||||
}
|
return deps;
|
||||||
|
}
|
||||||
|
|
||||||
void onInitialize(IMscEngineModuleAPI &engine) override {}
|
void onInitialize(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onStart(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onUpdate(IMscEngineModuleAPI &engine,
|
||||||
|
IMscEngineModuleAPI::clock::duration dt) override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void onStop(IMscEngineModuleAPI &engine) override {}
|
||||||
|
void onDestory(IMscEngineModuleAPI &engine) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
void testSatisfiedModules()
|
void testSatisfiedModules()
|
||||||
{
|
{
|
||||||
MscEngine engine({std::make_shared<FirstTestModuleR1>(),
|
MscEngine engine({std::make_shared<FirstTestModuleR1>(),
|
||||||
std::make_shared<SecondTestModuleE1>()});
|
std::make_shared<SecondTestModuleE1>()});
|
||||||
}
|
}
|
||||||
|
|
||||||
void testDuplicatedModules()
|
void testDuplicatedModules()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MscEngine engine({
|
MscEngine engine({
|
||||||
std::make_shared<FirstTestModuleR1>(),
|
std::make_shared<FirstTestModuleR1>(),
|
||||||
std::make_shared<FirstTestModuleR2>(),
|
std::make_shared<FirstTestModuleR2>(),
|
||||||
});
|
});
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
catch (const std::runtime_error &error)
|
catch (const std::runtime_error &error)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testUnsatisfiedModules()
|
void testUnsatisfiedModules()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MscEngine engine({std::make_shared<FirstTestModuleR2>(),
|
MscEngine engine({std::make_shared<FirstTestModuleR2>(),
|
||||||
std::make_shared<SecondTestModuleE1>()});
|
std::make_shared<SecondTestModuleE1>()});
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
catch (const std::runtime_error &error)
|
catch (const std::runtime_error &error)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSatisfiedMultiversionModule()
|
void testSatisfiedMultiversionModule()
|
||||||
{
|
{
|
||||||
MscEngine engine({std::make_shared<FirstTestModuleR2>(),
|
MscEngine engine({std::make_shared<FirstTestModuleR2>(),
|
||||||
std::make_shared<SecondTestModuleE2>()});
|
std::make_shared<SecondTestModuleE2>()});
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
testSatisfiedModules();
|
testSatisfiedModules();
|
||||||
testDuplicatedModules();
|
testDuplicatedModules();
|
||||||
testUnsatisfiedModules();
|
testUnsatisfiedModules();
|
||||||
testSatisfiedMultiversionModule();
|
testSatisfiedMultiversionModule();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user