1: <?php
2:
3: namespace Csim\Controller;
4:
5: /**
6: * The application's only controller. All calls to the model pass through here.
7: */
8:
9: class Controller {
10:
11: private $cache;
12:
13: /**
14: * Creates a cache with the specified layout.
15: *
16: * @param \Csim\Model\CacheLayout $layout The layout of the cache that shall be created.
17: * @return \Csim\Model\SimulationState The state of the newly created, empty, cahce.
18: */
19: public function defineCache(\Csim\Model\CacheLayout $layout) {
20: $this->cache = new \Csim\Model\Cache($layout);
21: return $this->cache->getState();
22: }
23:
24: /**
25: * Simulates the specified instruction.
26: *
27: * @param type $instruction The instruction that shall be simulated.
28: * @return \Csim\Model\SimulationState The state after simulating the specified instruction.
29: */
30: public function simulateInstruction(\Csim\Model\Instruction $instruction) {
31: return $this->cache->simulate($instruction);
32: }
33:
34: }
35: