]> git.mxchange.org Git - hub.git/blob - application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php
Continued with hub:
[hub.git] / application / hub / main / template / dht / class_XmlDhtBootstrapTemplateEngine.php
1 <?php
2 /**
3  * An Bootstrap template engine class for XML templates
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.shipsimu.org
10  * @todo                This template engine does not make use of setTemplateType()
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
26         /**
27          * Some XML nodes must be available for later data extraction
28          */
29         const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data';
30         const DHT_BOOTSTRAP_DATA_SESSION_ID     = 'session-id';
31         const DHT_BOOTSTRAP_DATA_NODE_STATUS    = 'node-status';
32         const DHT_BOOTSTRAP_DATA_NODE_MODE      = 'node-mode';
33         const DHT_BOOTSTRAP_DATA_EXTERNAL_IP    = 'external-ip';
34         const DHT_BOOTSTRAP_DATA_INTERNAL_IP    = 'internal-ip';
35         const DHT_BOOTSTRAP_DATA_LISTEN_PORT    = 'listen-port';
36
37         /**
38          * Protected constructor
39          *
40          * @return      void
41          */
42         protected function __construct () {
43                 // Call parent constructor
44                 parent::__construct(__CLASS__);
45
46                 // Init array
47                 $this->subNodes = array(
48                         self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA,
49                         'listener',
50                         self::DHT_BOOTSTRAP_DATA_NODE_STATUS,
51                         self::DHT_BOOTSTRAP_DATA_NODE_MODE,
52                         self::DHT_BOOTSTRAP_DATA_LISTEN_PORT,
53                         self::DHT_BOOTSTRAP_DATA_SESSION_ID,
54                         self::DHT_BOOTSTRAP_DATA_EXTERNAL_IP,
55                         self::DHT_BOOTSTRAP_DATA_INTERNAL_IP
56                 );
57         }
58
59         /**
60          * Creates an instance of the class TemplateEngine and prepares it for usage
61          *
62          * @return      $templateInstance               An instance of TemplateEngine
63          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
64          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
65          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
66          *                                                                                      directory or not found
67          * @throws      BasePathReadProtectedException  If $templateBasePath is
68          *                                                                                      read-protected
69          */
70         public static final function createXmlDhtBootstrapTemplateEngine () {
71                 // Get a new instance
72                 $templateInstance = new XmlDhtBootstrapTemplateEngine();
73
74                 // Init template instance
75                 $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap');
76
77                 // Return the prepared instance
78                 return $templateInstance;
79         }
80
81         /**
82          * Currently not used
83          *
84          * @param       $resource               XML parser resource (currently ignored)
85          * @param       $characters             Characters to handle
86          * @return      void
87          */
88         public function characterHandler ($resource, $characters) {
89                 // Trim all spaces away
90                 $characters = trim($characters);
91
92                 // Is this string empty?
93                 if (empty($characters)) {
94                         // Then skip it silently
95                         return;
96                 } // END - if
97
98                 /*
99                  * Assign the found characters to variable and use the last entry from
100                  * stack as the name.
101                  */
102                 parent::assignVariable($this->getStackInstance()->getNamed('dht_bootstrap'), $characters);
103         }
104
105         /**
106          * Getter for cache file (FQFN)
107          *
108          * @return      $fqfn   Full-qualified file name of the menu cache
109          */
110         public function getMenuCacheFqfn () {
111                 $this->partialStub('Please implement this method.');
112         }
113
114         /**
115          * Starts the dht bootstrap
116          *
117          * @return      void
118          */
119         protected function startDhtBootstrap () {
120                 // Push the node name on the stacker
121                 $this->getStackInstance()->pushNamed('dht_bootstrap', 'dht-bootstrap');
122         }
123
124         /**
125          * Starts the dht bootstrap data
126          *
127          * @return      void
128          */
129         protected function startDhtBootstrapData () {
130                 // Push the node name on the stacker
131                 $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA);
132         }
133
134         /**
135          * Starts the node status
136          *
137          * @return      void
138          */
139         protected function startNodeStatus () {
140                 // Push the node name on the stacker
141                 $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_STATUS);
142         }
143
144         /**
145          * Starts the node-mode
146          *
147          * @return      void
148          */
149         protected function startNodeMode () {
150                 // Push the node name on the stacker
151                 $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_MODE);
152         }
153
154         /**
155          * Starts the listener
156          *
157          * @return      void
158          */
159         protected function startListener () {
160                 // Push the node name on the stacker
161                 $this->getStackInstance()->pushNamed('dht_bootstrap', 'listener');
162         }
163
164         /**
165          * Starts the TCP/UDP listen port
166          *
167          * @return      void
168          */
169         protected function startListenPort () {
170                 // Push the node name on the stacker
171                 $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_LISTEN_PORT);
172         }
173
174         /**
175          * Starts the public ip
176          *
177          * @return      void
178          */
179         protected function startExternalIp () {
180                 // Push the node name on the stacker
181                 $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_IP);
182         }
183
184         /**
185          * Starts the private ip
186          *
187          * @return      void
188          */
189         protected function startInternalIp () {
190                 // Push the node name on the stacker
191                 $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_IP);
192         }
193
194         /**
195          * Starts the session id
196          *
197          * @return      void
198          */
199         protected function startSessionId () {
200                 // Push the node name on the stacker
201                 $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_SESSION_ID);
202         }
203
204         /**
205          * Finishes the session id
206          *
207          * @return      void
208          */
209         protected function finishSessionId () {
210                 // Pop the last entry
211                 $this->getStackInstance()->popNamed('dht_bootstrap');
212         }
213
214         /**
215          * Finishes the private ip
216          *
217          * @return      void
218          */
219         protected function finishInternalIp () {
220                 // Pop the last entry
221                 $this->getStackInstance()->popNamed('dht_bootstrap');
222         }
223
224         /**
225          * Finishes the public ip
226          *
227          * @return      void
228          */
229         protected function finishExternalIp () {
230                 // Pop the last entry
231                 $this->getStackInstance()->popNamed('dht_bootstrap');
232         }
233
234         /**
235          * Finishes the TCP/UDP listen port
236          *
237          * @return      void
238          */
239         protected function finishListenPort () {
240                 // Pop the last entry
241                 $this->getStackInstance()->popNamed('dht_bootstrap');
242         }
243
244         /**
245          * Finishes the listener
246          *
247          * @return      void
248          */
249         protected function finishListener () {
250                 // Pop the last entry
251                 $this->getStackInstance()->popNamed('dht_bootstrap');
252         }
253
254         /**
255          * Finishes the node mode
256          *
257          * @return      void
258          */
259         protected function finishNodeMode () {
260                 // Pop the last entry
261                 $this->getStackInstance()->popNamed('dht_bootstrap');
262         }
263
264         /**
265          * Finishes the node status
266          *
267          * @return      void
268          */
269         protected function finishNodeStatus () {
270                 // Pop the last entry
271                 $this->getStackInstance()->popNamed('dht_bootstrap');
272         }
273
274         /**
275          * Finishes the dht bootstrap data
276          *
277          * @return      void
278          */
279         protected function finishDhtBootstrapData () {
280                 // Pop the last entry
281                 $this->getStackInstance()->popNamed('dht_bootstrap');
282         }
283
284         /**
285          * Finishes the dht bootstrap
286          *
287          * @return      void
288          */
289         protected function finishDhtBootstrap () {
290                 // Pop the last entry
291                 $this->getStackInstance()->popNamed('dht_bootstrap');
292         }
293 }
294
295 // [EOF]
296 ?>