fix: compilation errors
This commit is contained in:
+100
-92
@@ -1,149 +1,157 @@
|
||||
#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
|
||||
{
|
||||
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
||||
return deps;
|
||||
}
|
||||
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 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
|
||||
{
|
||||
static const std::unordered_map<std::string, MscRevisionRange> deps{};
|
||||
return deps;
|
||||
}
|
||||
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 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
|
||||
{
|
||||
static const std::unordered_map<std::string, MscRevisionRange> deps{
|
||||
{"first_tmod", MscRevisionRange{1, 1}}};
|
||||
return deps;
|
||||
}
|
||||
const std::unordered_map<std::string, MscRevisionRange> &
|
||||
getDependencies() const override
|
||||
{
|
||||
static const std::unordered_map<std::string, MscRevisionRange> 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
|
||||
{
|
||||
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
|
||||
{
|
||||
static const std::unordered_map<std::string, MscRevisionRange> deps{
|
||||
{"first_tmod", MscRevisionRange{1, 2}}};
|
||||
return deps;
|
||||
}
|
||||
const std::unordered_map<std::string, MscRevisionRange> &
|
||||
getDependencies() const override
|
||||
{
|
||||
static const std::unordered_map<std::string, MscRevisionRange> 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()
|
||||
{
|
||||
MscEngine engine({std::make_shared<FirstTestModuleR1>(),
|
||||
std::make_shared<SecondTestModuleE1>()});
|
||||
MscEngine engine({std::make_shared<FirstTestModuleR1>(),
|
||||
std::make_shared<SecondTestModuleE1>()});
|
||||
}
|
||||
|
||||
void testDuplicatedModules()
|
||||
{
|
||||
try
|
||||
{
|
||||
MscEngine engine({
|
||||
std::make_shared<FirstTestModuleR1>(),
|
||||
std::make_shared<FirstTestModuleR2>(),
|
||||
});
|
||||
assert(false);
|
||||
}
|
||||
catch (const std::runtime_error &error)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
MscEngine engine({
|
||||
std::make_shared<FirstTestModuleR1>(),
|
||||
std::make_shared<FirstTestModuleR2>(),
|
||||
});
|
||||
assert(false);
|
||||
}
|
||||
catch (const std::runtime_error &error)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void testUnsatisfiedModules()
|
||||
{
|
||||
try
|
||||
{
|
||||
MscEngine engine({std::make_shared<FirstTestModuleR2>(),
|
||||
std::make_shared<SecondTestModuleE1>()});
|
||||
assert(false);
|
||||
}
|
||||
catch (const std::runtime_error &error)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
MscEngine engine({std::make_shared<FirstTestModuleR2>(),
|
||||
std::make_shared<SecondTestModuleE1>()});
|
||||
assert(false);
|
||||
}
|
||||
catch (const std::runtime_error &error)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void testSatisfiedMultiversionModule()
|
||||
{
|
||||
MscEngine engine({std::make_shared<FirstTestModuleR2>(),
|
||||
std::make_shared<SecondTestModuleE2>()});
|
||||
MscEngine engine({std::make_shared<FirstTestModuleR2>(),
|
||||
std::make_shared<SecondTestModuleE2>()});
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
testSatisfiedModules();
|
||||
testDuplicatedModules();
|
||||
testUnsatisfiedModules();
|
||||
testSatisfiedMultiversionModule();
|
||||
testSatisfiedModules();
|
||||
testDuplicatedModules();
|
||||
testUnsatisfiedModules();
|
||||
testSatisfiedMultiversionModule();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user