Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestTimesNodeClass.php 2.38 KB
22521f1c   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php

define ("REQUESTTIMEINTERVAL_NAME", "interval");
define ("REQUESTTIMEINTERVAL_START", "startTime");
define ("REQUESTTIMEINTERVAL_DURATION", "timeInterval");

/**
 * @class RequestTimesIntervalNodeClass
 * @brief Definition of a request time interval node for AMDA_Kernel
 * @details
*/
class RequestTimesIntervalNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTTIMEINTERVAL_NAME);
	}

	public function setInterval($start, $duration)
	{
		$startNode = $this->getChildInstanceByName(REQUESTTIMEINTERVAL_START, true);
		$startNode->setValue($start);
		$durationNode = $this->getChildInstanceByName(REQUESTTIMEINTERVAL_DURATION, true);
		$durationNode->setValue($duration);
	}

	public function getStart()
	{
		$startNode = $this->getChildInstanceByName(REQUESTTIMEINTERVAL_START);
		if ($startNode == NULL)
			return "";
		return $startNode->getValue();
	}

	public function getDuration()
	{
		$durationNode = $this->getChildInstanceByName(REQUESTTIMEINTERVAL_DURATION);
		if ($durationNode == NULL)
			return "";
		return $durationNode->getValue();
	}
}

define ("REQUESTTIMETABLE_NAME", "timetable");
define ("REQUESTTIMETABLE_ID", "id");

/**
 * @class RequestTimesTimeTableNodeClass
 * @brief Definition of a request time table node for AMDA_Kernel
 * @details
*/
class RequestTimesTimeTableNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTTIMETABLE_NAME);
	}

	public function setId($id)
	{
		$this->setAttribute(REQUESTTIMETABLE_ID, $id);
	}

	public function getId()
	{
		return $this->getAttribute(REQUESTTIMETABLE_ID);
	}
}

define ("REQUESTTIMES_NAME", "times");

/**
 * @class RequestTimesNodeClass
 * @brief Definition of a request times node for AMDA_Kernel
 * @details
*/
class RequestTimesNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTTIMES_NAME);
	}

	public function addInterval($start, $duration)
	{
		$interval = new RequestTimesIntervalNodeClass();
		$interval->setInterval($start, $duration);
		$this->addChild($interval);
	}

	public function getIntervals()
	{
		return $this->getChildrenByName(REQUESTTIMEINTERVAL_NAME);
	}

	public function addTimeTable($id)
	{
		$timeTable = new RequestTimesTimeTableNodeClass();
		$timeTable->setId($id);
		$this->addChild($timeTable);
	}

	public function getTimeTables()
	{
		return $this->getChildrenByName(REQUESTTIMETABLE_NAME);
	}
}

?>