Add Director, director::CommandList, hk::Goal and fixups
* Simulator and Director are no longer singletons.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
#ifndef DIRECTOR_COMMANDLIST_H
|
||||
#define DIRECTOR_COMMANDLIST_H
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <mentalEntity.h>
|
||||
|
||||
namespace director {
|
||||
|
||||
/**
|
||||
* @brief Base class for all commands, storing a reference to a mental entity ID.
|
||||
*
|
||||
* Derived classes can extend this to include additional command-specific
|
||||
* data and behavior.
|
||||
*/
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
Command(const MentalEntity::Id menty) : menty(menty) {}
|
||||
|
||||
public:
|
||||
const MentalEntity::Id menty;
|
||||
};
|
||||
|
||||
class CommandList
|
||||
{
|
||||
public:
|
||||
CommandList() = default;
|
||||
|
||||
/**
|
||||
* @brief Used by Director to point to the currently executing command.
|
||||
*
|
||||
* director::Director maintains an internal cursor. As it executes commands
|
||||
* from its internal command list, it advances the cursor to the current
|
||||
* command before executing it.
|
||||
*/
|
||||
class Cursor
|
||||
{
|
||||
public:
|
||||
Cursor(CommandList& commandList)
|
||||
: commandList(commandList), iter(commandList.commands.begin())
|
||||
{}
|
||||
|
||||
void reset() { iter = commandList.commands.begin(); }
|
||||
bool hasNext() const { return iter != commandList.commands.end(); }
|
||||
Cursor next() { return Cursor(commandList, ++iter); }
|
||||
|
||||
private:
|
||||
Cursor(
|
||||
CommandList& commandList,
|
||||
std::vector<Command>::iterator iter)
|
||||
: commandList(commandList), iter(iter)
|
||||
{}
|
||||
|
||||
public:
|
||||
CommandList& commandList;
|
||||
std::vector<Command>::iterator iter;
|
||||
};
|
||||
|
||||
Cursor getCursor() { return Cursor(*this); }
|
||||
void addCommand(const Command& command)
|
||||
{
|
||||
commands.push_back(command);
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<Command> commands;
|
||||
};
|
||||
|
||||
} // namespace director
|
||||
|
||||
#endif // DIRECTOR_COMMANDLIST_H
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef DIRECTOR_H
|
||||
#define DIRECTOR_H
|
||||
|
||||
namespace director {
|
||||
|
||||
class Director {
|
||||
public:
|
||||
Director() = default;
|
||||
~Director() = default;
|
||||
};
|
||||
|
||||
} // namespace director
|
||||
|
||||
#endif // DIRECTOR_H
|
||||
Reference in New Issue
Block a user