Bundled Simulation and Renderer in ExecutionEnvironment.

This commit is contained in:
Chris Laurel 2001-04-27 07:04:41 +00:00
parent 7096a14752
commit 9066411c3e
3 changed files with 36 additions and 8 deletions

29
src/execenv.h Normal file
View file

@ -0,0 +1,29 @@
// execenv.h
//
// Copyright (C) 2001 Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
#ifndef _EXECENV_H_
#define _EXECENV_H_
#include <string>
#include "render.h"
#include "simulation.h"
class ExecutionEnvironment
{
public:
ExecutionEnvironment() {};
virtual inline Simulation* getSimulation() const = 0;
virtual inline Renderer* getRenderer() const = 0;
virtual void showText(std::string) = 0;
};
#endif // _EXECENV_H_

View file

@ -12,11 +12,10 @@
using namespace std;
Execution::Execution(CommandSequence& cmd, Simulation* s, Renderer* r) :
Execution::Execution(CommandSequence& cmd, ExecutionEnvironment& _env) :
currentCommand(cmd.begin()),
finalCommand(cmd.end()),
sim(s),
renderer(r),
env(_env),
commandTime(0.0)
{
}
@ -31,7 +30,7 @@ bool Execution::tick(double dt)
double timeLeft = cmd->getDuration() - commandTime;
if (dt >= timeLeft)
{
cmd->process(sim, renderer, cmd->getDuration(), timeLeft);
cmd->process(env, cmd->getDuration(), timeLeft);
dt -= timeLeft;
commandTime = 0.0;
currentCommand++;
@ -39,7 +38,7 @@ bool Execution::tick(double dt)
else
{
commandTime += dt;
cmd->process(sim, renderer, commandTime, dt);
cmd->process(env, commandTime, dt);
dt = 0.0;
}
}

View file

@ -10,21 +10,21 @@
#ifndef _EXECUTION_H_
#define _EXECUTION_H_
#include "execenv.h"
#include "command.h"
class Execution
{
public:
Execution(CommandSequence&, Simulation*, Renderer*);
Execution(CommandSequence&, ExecutionEnvironment&);
bool tick(double);
private:
CommandSequence::const_iterator currentCommand;
CommandSequence::const_iterator finalCommand;
Simulation* sim;
Renderer* renderer;
ExecutionEnvironment& env;
double commandTime;
};