Implement modules lifecycle #2
+1
-8
@@ -1,16 +1,9 @@
|
||||
#include "engine/modules/test1/test1.hpp"
|
||||
#include <cstdio>
|
||||
#include <engine/core/engine.hpp>
|
||||
#include <memory>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
auto engine =
|
||||
std::make_unique<MscEngine>(std::vector<std::shared_ptr<MscEngineModule>>{
|
||||
std::make_shared<Test1Module>()});
|
||||
|
||||
printf("Hello, CMake, %p!\n", &engine);
|
||||
printf("Hello, engine!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,71 +1,70 @@
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
#include <engine/utils/rev_range.hpp>
|
||||
#include <engine/core/engine.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
|
||||
{
|
||||
public:
|
||||
std::string getName() const override
|
||||
{
|
||||
return "first_tmod";
|
||||
};
|
||||
std::string getName() const override { return "first_tmod"; };
|
||||
|
||||
std::uint16_t getRev() const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
std::uint16_t getRev() const override { 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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
std::string getName() const override
|
||||
{
|
||||
return "first_tmod";
|
||||
};
|
||||
std::string getName() const override { return "first_tmod"; };
|
||||
|
||||
std::uint16_t getRev() const override
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
std::uint16_t getRev() const override { 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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
std::string getName() const override
|
||||
{
|
||||
return "second_tmod";
|
||||
}
|
||||
std::string getName() const override { return "second_tmod"; }
|
||||
|
||||
std::uint16_t getRev() const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
std::uint16_t getRev() const override { 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}}};
|
||||
@@ -73,22 +72,24 @@ public:
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
std::string getName() const override
|
||||
{
|
||||
return "second_tmod";
|
||||
}
|
||||
std::string getName() const override { return "second_tmod"; }
|
||||
|
||||
std::uint16_t getRev() const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
std::uint16_t getRev() const override { 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}}};
|
||||
@@ -96,6 +97,13 @@ public:
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user