*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
* @todo This template engine does not make use of setTemplateType()
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class XmlAnnouncementTemplateEngine extends BaseTemplateEngine implements CompileableTemplate, Registerable {
+ /**
+ * Some XML nodes must be available for later data extraction
+ */
+ const ANNOUNCEMENT_DATA_SESSION_ID = 'session-id';
+ const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status';
+ const ANNOUNCEMENT_DATA_EXTERNAL_IP = 'external-ip';
+ const ANNOUNCEMENT_DATA_TCP_PORT = 'tcp-port';
+ const ANNOUNCEMENT_DATA_UDP_PORT = 'udp-port';
+
/**
* Main nodes in the XML tree
*/
/**
* Sub nodes in the XML tree
*/
- private $subNodes = array(
- 'announcement-data',
- 'listener',
- 'hub-listener',
- 'client-listener',
- 'node-id',
- 'node-status',
- 'tcp-port',
- 'udp-port',
- 'session-id',
- 'object-type-list',
- );
+ private $subNodes = array();
/**
* Current main node
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+
+ // Init array
+ $this->subNodes = array(
+ 'announcement-data',
+ 'listener',
+ self::ANNOUNCEMENT_DATA_NODE_STATUS,
+ self::ANNOUNCEMENT_DATA_TCP_PORT,
+ self::ANNOUNCEMENT_DATA_UDP_PORT,
+ self::ANNOUNCEMENT_DATA_SESSION_ID,
+ self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
+ 'object-type-list',
+ );
}
/**
} // END - if
}
+ /**
+ * Read announcement variables by calling readVariable() with 'general' as
+ * variable stack.
+ *
+ * @param $key Key to read from
+ * @return $value Value from variable
+ */
+ public function readAnnouncementData ($key) {
+ // Read the variable
+ $value = parent::readVariable($key, 'general');
+
+ // Return value
+ return $value;
+ }
+
/**
* Getter for cache file (FQFN)
*
$this->getStackerInstance()->pushNamed('announcement', 'announcement-data');
}
- /**
- * Starts the node id
- *
- * @return void
- */
- private function startNodeId () {
- // Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement', 'node-id');
- }
-
/**
* Starts the node status
*
*/
private function startNodeStatus () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement', 'node-status');
+ $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_NODE_STATUS);
}
/**
}
/**
- * Starts the client listener
- *
- * @return void
- */
- private function startClientListener () {
- // Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement', 'client-listener');
- }
-
- /**
- * Starts the hub listener
+ * Starts the TCP port
*
* @return void
*/
- private function startHubListener () {
+ private function startTcpPort () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement', 'hub-listener');
+ $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_TCP_PORT);
}
/**
- * Starts the TCP port
+ * Starts the UDP port
*
* @return void
*/
- private function startTcpPort () {
+ private function startUdpPort () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement', 'tcp-port');
+ $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_UDP_PORT);
}
/**
- * Starts the UDP port
+ * Starts the session id
*
* @return void
*/
- private function startUdpPort () {
+ private function startSessionId () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement', 'udp-port');
+ $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_SESSION_ID);
}
/**
- * Starts the session id
+ * Starts the public ip
*
* @return void
*/
- private function startSessionId () {
+ private function startExternalIp () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('announcement', 'session-id');
+ $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
}
/**
}
/**
- * Finishes the UDP port
- *
- * @return void
- */
- private function finishUdpPort () {
- // Pop the last entry
- $this->getStackerInstance()->popNamed('announcement');
- }
-
- /**
- * Finishes the TCP port
+ * Finishes the public ip
*
* @return void
*/
- private function finishTcpPort () {
+ private function finishExternalIp () {
// Pop the last entry
$this->getStackerInstance()->popNamed('announcement');
}
/**
- * Finishes the hub listener
+ * Finishes the UDP port
*
* @return void
*/
- private function finishHubListener () {
+ private function finishUdpPort () {
// Pop the last entry
$this->getStackerInstance()->popNamed('announcement');
}
/**
- * Finishes the client listener
+ * Finishes the TCP port
*
* @return void
*/
- private function finishClientListener () {
+ private function finishTcpPort () {
// Pop the last entry
$this->getStackerInstance()->popNamed('announcement');
}
$this->getStackerInstance()->popNamed('announcement');
}
- /**
- * Finishes the node id
- *
- * @return void
- */
- private function finishNodeId () {
- // Pop the last entry
- $this->getStackerInstance()->popNamed('announcement');
- }
-
/**
* Finishes the announcement data
*