GroveEngine/tests/modules/TankModule.h
StillHammer 98acb32c4c fix: Resolve deadlock in IntraIOManager + cleanup SEGFAULTs
- Fix critical deadlock in IntraIOManager using std::scoped_lock for
  multi-mutex acquisition (CrossSystemIntegration: 1901s → 4s)
- Add std::shared_mutex for read-heavy operations (TopicTree, IntraIOManager)
- Fix SEGFAULT in SequentialModuleSystem destructor (logger guard)
- Fix SEGFAULT in ModuleLoader (don't auto-unload when modules still alive)
- Fix iterator invalidation in DependencyTestEngine destructor
- Add TSan/Helgrind integration for deadlock detection
- Add coding guidelines for synchronization patterns

All 23 tests now pass (100%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 11:36:33 +08:00

50 lines
1.4 KiB
C++

#pragma once
#include "grove/IModule.h"
#include "grove/IDataNode.h"
#include <vector>
#include <random>
#include <memory>
#include <spdlog/spdlog.h>
namespace grove {
class TankModule : public IModule {
public:
struct Tank {
float x, y; // Position
float vx, vy; // Vélocité
float cooldown; // Temps avant prochain tir
float targetX, targetY; // Destination
int id; // Identifiant unique
};
// IModule interface
void process(const IDataNode& input) override;
void setConfiguration(const IDataNode& configNode, IIO* io, ITaskScheduler* scheduler) override;
const IDataNode& getConfiguration() override;
std::unique_ptr<IDataNode> getHealthStatus() override;
void shutdown() override;
std::unique_ptr<IDataNode> getState() override;
void setState(const IDataNode& state) override;
std::string getType() const override;
bool isIdle() const override { return true; }
private:
std::vector<Tank> tanks;
int frameCount = 0;
std::string moduleVersion = "v1.0";
std::shared_ptr<spdlog::logger> logger;
std::unique_ptr<IDataNode> config;
void updateTank(Tank& tank, float dt);
void spawnTanks(int count);
};
} // namespace grove
// Export symbols
extern "C" {
grove::IModule* createModule();
void destroyModule(grove::IModule* module);
}