1: <?php
2:
3: namespace Csim\Util;
4:
5: /**
6: * Some utility methods.
7: */
8: final class Util {
9:
10: const SYMBOL_PREFIX = "CSIM_";
11:
12: private function __construct() {
13:
14: }
15:
16: /**
17: * This function should be called first in any PHP page receiving a HTTP request.
18: */
19: public static function initRequest() {
20: spl_autoload_register(function ($class) {
21: include 'classes/' . \str_replace('\\', '/', $class) . '.php';
22: });
23:
24: session_start();
25: self::defineHttpParams();
26: }
27:
28: private static function defineHttpParams() {
29: self::defineHttpParam('ASSOC_KEY', 'associativity');
30: self::defineHttpParam('BLOCK_COUNT_KEY', 'blockCount');
31: self::defineHttpParam('BLOCK_SIZE_KEY', 'blockSize');
32: self::defineHttpParam('INSTR_KEY', 'instruction');
33: self::defineHttpParam('ADDR_KEY', 'address');
34: }
35:
36: private static function defineHttpParam($param, $value) {
37: define(self::SYMBOL_PREFIX . $param, $value);
38: }
39:
40: }
41: