Implement modules lifecycle #2
+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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +1,70 @@
|
|||||||
#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{};
|
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
||||||
return 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{};
|
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
||||||
return 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{
|
static const std::unordered_map<std::string, MscRevisionRange> deps{
|
||||||
{"first_tmod", MscRevisionRange{1, 1}}};
|
{"first_tmod", MscRevisionRange{1, 1}}};
|
||||||
@@ -73,22 +72,24 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
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{
|
static const std::unordered_map<std::string, MscRevisionRange> deps{
|
||||||
{"first_tmod", MscRevisionRange{1, 2}}};
|
{"first_tmod", MscRevisionRange{1, 2}}};
|
||||||
@@ -96,6 +97,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user