InfoParamNodeClass.php
6.74 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
define ("INFOPARAM_TAGNAME", "info");
define ("INFOPARAM_NAME", "name");
define ("INFOPARAM_SHORTNAME", "short_name");
define ("INFOPARAM_COMPONENTS", "components");
define ("INFOPARAM_UNITS", "units");
define ("INFOPARAM_COORDSYS", "coordinates_system");
define ("INFOPARAM_TENSORORDER", "tensor_order");
define ("INFOPARAM_SICONV", "si_conversion");
define ("INFOPARAM_TABLE", "table");
define ("INFOPARAM_FILLVAL", "fill_value");
define ("INFOPARAM_UCD", "ucd");
//define ("INFOPARAM_STATUSDEF", "status_def");
define ("INFOPARAM_DATASETID", "dataset_id");
/**
*
*/
abstract class InfoParamTableTypeEnum
{
const BOUNDS = "Bounds";
const MINMAX = "MinMax";
const CENTER = "Center";
const CENTERWIDTH = "CenterWidth";
}
/**
* @class InfoParamNodeClass
* @brief Definition of information about a parameter
* @details
*/
class InfoParamNodeClass extends NodeClass
{
public function __construct()
{
parent::__construct(INFOPARAM_TAGNAME);
$this->getChildInstanceByName(INFOPARAM_NAME,true);
$this->getChildInstanceByName(INFOPARAM_SHORTNAME,true);
$this->getChildInstanceByName(INFOPARAM_COMPONENTS,true);
$this->getChildInstanceByName(INFOPARAM_UNITS,true);
$this->getChildInstanceByName(INFOPARAM_COORDSYS,true);
$this->getChildInstanceByName(INFOPARAM_TENSORORDER,true);
$this->getChildInstanceByName(INFOPARAM_SICONV,true);
$this->getChildInstanceByName(INFOPARAM_TABLE,true);
$this->getChildInstanceByName(INFOPARAM_FILLVAL,true);
$this->getChildInstanceByName(INFOPARAM_UCD,true);
//$this->getChildInstanceByName(INFOPARAM_STATUSDEF,true);
$this->getChildInstanceByName(INFOPARAM_DATASETID,true);
}
public function setName($name)
{
$node = $this->getChildInstanceByName(INFOPARAM_NAME,true);
$node->setValue($name);
}
public function setShortName($short_name)
{
$node = $this->getChildInstanceByName(INFOPARAM_SHORTNAME,true);
$node->setValue($short_name);
}
public function setComponents($components)
{
$node = $this->getChildInstanceByName(INFOPARAM_COMPONENTS,true);
$node->setValue($components);
}
public function setUnits($units)
{
$node = $this->getChildInstanceByName(INFOPARAM_UNITS,true);
$node->setValue($units);
}
public function setCoordSyst($coord_sys)
{
$node = $this->getChildInstanceByName(INFOPARAM_COORDSYS,true);
$node->setValue($coord_sys);
}
public function setTensorOrder($tensor_order)
{
$node = $this->getChildInstanceByName(INFOPARAM_TENSORORDER,true);
$node->setValue($tensor_order);
}
public function setSIConv($si_conv)
{
$node = $this->getChildInstanceByName(INFOPARAM_SICONV,true);
$node->setValue($si_conv);
}
public function setFillVal($fill)
{
$node = $this->getChildInstanceByName(INFOPARAM_FILLVAL,true);
$node->setValue($fill);
}
public function setUCD($ucd)
{
$node = $this->getChildInstanceByName(INFOPARAM_UCD,true);
$node->setValue($ucd);
}
public function setDatasetID($dataset_id)
{
$node = $this->getChildInstanceByName(INFOPARAM_DATASETID,true);
$node->setValue($dataset_id);
}
public function addTable($type, $name)
{
$node = $this->getTable();
switch ($type)
{
case InfoParamTableTypeEnum::BOUNDS :
$tableDef = new InfoParamTableDefBoundsNodeClass();
break;
case InfoParamTableTypeEnum::MINMAX :
$tableDef = new InfoParamTableDefMinMaxNodeClass();
break;
case InfoParamTableTypeEnum::CENTER :
$tableDef = new InfoParamTableDefCenterNodeClass();
break;
case InfoParamTableTypeEnum::CENTERWIDTH :
$tableDef = new InfoParamTableDefCenterWidthNodeClass();
break;
default :
//throw new Exception('Table definition node not implemented');
}
$tableDef->setTableName($name);
$node->addChild($tableDef);
return $tableDef;
}
public function getTable()
{
return $this->getChildInstanceByName(INFOPARAM_TABLE, true);
}
public function loadFromNode($xmlNode)
{
$nameXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_NAME);
if (isset($nameXmlNode))
$this->setName($this->getXmlNodeValue($nameXmlNode));
$shortnameXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_SHORTNAME);
if (isset($shortnameXmlNode))
$this->setShortName($this->getXmlNodeValue($shortnameXmlNode));
$componentsXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_COMPONENTS);
if (isset($componentsXmlNode))
$this->setComponents($this->getXmlNodeValue($componentsXmlNode));
$unitsXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_UNITS);
if (isset($unitsXmlNode))
$this->setUnits($this->getXmlNodeValue($unitsXmlNode));
$coordsysXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_COORDSYS);
if (isset($coordsysXmlNode))
$this->setCoordSyst($this->getXmlNodeValue($coordsysXmlNode));
$tensororderXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_TENSORORDER);
if (isset($tensororderXmlNode))
$this->setTensorOrder($this->getXmlNodeValue($tensororderXmlNode));
$siconvXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_SICONV);
if (isset($siconvXmlNode))
$this->setSIConv($this->getXmlNodeValue($siconvXmlNode));
$tableXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_TABLE);
if (isset($tableXmlNode)) {
foreach ($this->getXmlNodeChildren($tableXmlNode) as $tableDefXmlNode) {
switch ($this->getXmlNodeName($tableDefXmlNode)) {
case INFOPARAMTABLEDEFBOUNDS_TAGNAME :
$this->addTable(InfoParamTableTypeEnum::BOUNDS, "")->loadFromNode($tableDefXmlNode);
break;
case INFOPARAMTABLEDEFCENTER_TAGNAME :
$this->addTable(InfoParamTableTypeEnum::CENTER, "")->loadFromNode($tableDefXmlNode);
break;
case INFOPARAMTABLEDEFCENTERWIDTH_TAGNAME :
$this->addTable(InfoParamTableTypeEnum::CENTERWIDTH, "")->loadFromNode($tableDefXmlNode);
break;
case InfoParamTableDefMinMaxNodeClass :
$this->addTable(InfoParamTableTypeEnum::MINMAX, "")->loadFromNode($tableDefXmlNode);
break;
default :
//throw new Exception('Table definition node not implemented');
}
}
}
$fillvalXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_FILLVAL);
if (isset($fillvalXmlNode))
$this->setFillVal($this->getXmlNodeValue($fillvalXmlNode));
$ucdXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_UCD);
if (isset($ucdXmlNode))
$this->setUCD($this->getXmlNodeValue($ucdXmlNode));
$datasetidXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_DATASETID);
if (isset($datasetidXmlNode))
$this->setDatasetID($this->getXmlNodeValue($datasetidXmlNode));
}
}
?>