]> git.mxchange.org Git - city.git/commitdiff
Renamed some more files city -> city_daemon to avoid confusion as these classes
authorRoland Haeder <roland@mxchange.org>
Sun, 28 Jun 2015 19:45:00 +0000 (21:45 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 28 Jun 2015 19:45:00 +0000 (21:45 +0200)
are only for the daemon and not for any frontends.

Signed-off-by: Roland Haeder <roland@mxchange.org>
31 files changed:
application/city/config.php
application/city/interfaces/database/frontend/city/class_CityInformationWrapper.php
application/city/interfaces/helper/city/class_CityHelper.php
application/city/main/city/.htaccess [deleted file]
application/city/main/city/class_ [deleted file]
application/city/main/city/class_BaseCity.php [deleted file]
application/city/main/city/testing/.htaccess [deleted file]
application/city/main/city/testing/class_SimulationTestingCity.php [deleted file]
application/city/main/city_daemon/.htaccess [new file with mode: 0644]
application/city/main/city_daemon/class_ [new file with mode: 0644]
application/city/main/city_daemon/class_BaseCityDaemon.php [new file with mode: 0644]
application/city/main/city_daemon/testing/.htaccess [new file with mode: 0644]
application/city/main/city_daemon/testing/class_SimulationTestingCityDaemon.php [new file with mode: 0644]
application/city/main/commands/console/class_CityConsoleDaemonCommand.php
application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php
application/city/main/factories/city/class_CityDaemonObjectFactory.php [new file with mode: 0644]
application/city/main/factories/city/class_CityObjectFactory.php [deleted file]
application/city/main/factories/states/city/class_CityStateFactory.php
application/city/main/filter/bootstrap/.htaccess [new file with mode: 0644]
application/city/main/filter/bootstrap/class_CityDaemonBootstrap [new file with mode: 0644]
application/city/main/filter/bootstrap/init/.htaccess [new file with mode: 0644]
application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php [new file with mode: 0644]
application/city/main/filter/city_daemon/class_CityDaemonInitializationFilter.php
application/city/main/filter/city_daemon/class_CityDaemonWelcomeTeaserFilter.php
application/city/main/filter/shutdown/city/class_CityDaemonShutdownCityFilter.php
application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php
application/city/main/states/city/active/class_CityActiveState.php
application/city/main/states/city/class_
application/city/main/states/city/init/class_CityInitState.php
application/city/main/states/city/virgin/class_CityVirginState.php
core

index 527502cc0124bf16e0edfe0eb3d546e49743fa43..ab67804f6d5528712cd0de237b9dd25b284a5f80 100644 (file)
@@ -52,6 +52,9 @@ $cfg->setConfigEntry('region_map_db_wrapper_class', 'RegionMapDatabaseWrapper');
 // CFG: CITY-INIT-STATE-CLASS
 $cfg->setConfigEntry('city_init_state_class', 'CityInitState');
 
+// CFG: CITY-VIRGIN-STATE-CLASS
+$cfg->setConfigEntry('city_virgin_state_class', 'CityVirginState');
+
 /******************************************************************************
  *                                HTML client                                 *
  ******************************************************************************/
@@ -510,6 +513,9 @@ $cfg->setConfigEntry('city_daemon_activation_task_handler_initializer_filter', '
 // CFG: CITY-DAEMON-WELCOME-TEASER-FILTER
 $cfg->setConfigEntry('city_daemon_welcome_teaser_filter', 'CityDaemonWelcomeTeaserFilter');
 
+// CFG: CITY-DAEMON-BOOTSTRAP-INIT-DAEMON-FILTER
+$cfg->setConfigEntry('city_daemon_bootstrap_init_daemon_filter', 'CityDaemonBootstrapInitDaemonFilter');
+
 // CFG: CITY-DAEMON-SHUTDOWN-TASK-HANDLER-FILTER
 $cfg->setConfigEntry('city_daemon_shutdown_task_handler_filter', 'CityDaemonShutdownTaskHandlerFilter');
 
index 948406520400520657e493303ebe6a0334e8f03d..7c45cf01a2c17c054cb554cff90cd2ef95f6a791 100644 (file)
@@ -30,7 +30,7 @@ interface CityInformationWrapper extends DatabaseWrapper {
         * @param       $requestInstance        An instance of a Requestable class
         * @return      void
         */
-       function registerCityId (BaseCity $cityInstance, Requestable $requestInstance);
+       function registerCityId (BaseCityDaemon $cityInstance, Requestable $requestInstance);
 
        /**
         * Checks whether there is an entry for given city instance
index 7f3e0e36cf079907d3e125ed7b151668fef8c71c..bf4a413f36984686d6bd9b4c289e4a19a2daaf28 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface CityHelper extends Helper, AddableCriteria {
+       /**
+        * Initializes the city daemon
+        *
+        * @return      void
+        */
+       function bootstrapInitCityDaemon ();
+
        /**
         * Method to "bootstrap" the city. This step does also apply provided
         * command-line arguments stored in the request instance. You should now
diff --git a/application/city/main/city/.htaccess b/application/city/main/city/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/city/main/city/class_ b/application/city/main/city/class_
deleted file mode 100644 (file)
index 19410ec..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-/**
- * A hub-node class for the '???' mode
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2015 City Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Simulation???City extends BaseCity implements CityHelper, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this hub-node class
-        *
-        * @param       $requestInstance        An instance of a Requestable class
-        * @return      $nodeInstance           An instance of this hub-node class
-        */
-       public final static function createCity???City (Requestable $requestInstance) {
-               // Get a new instance
-               $nodeInstance = new City???City();
-
-               // Set the request instance
-               $nodeInstance->setRequestInstance($requestInstance);
-
-               // Return the instance
-               return $nodeInstance;
-       }
-
-       /**
-        * Method to "bootstrap" the node. This step does also apply provided
-        * command-line arguments stored in the request instance. The regular node
-        * should communicate with the bootstrap-nodes at this point.
-        *
-        * @return      void
-        * @todo        Implement this method
-        */
-       public function doBootstrapping () {
-               // Call generic (parent) bootstrapping method first
-               parent::doGenericBootstrapping();
-               $this->partialStub('Please implement this method.');
-       }
-
-       /**
-        * Initializes hub-specific queues
-        *
-        * @return      void
-        * @todo        Implement this method
-        */
-       public function initQueues () {
-               $this->partialStub('Please implement this method.');
-       }
-
-       /**
-        * Add some node-specific filters
-        *
-        * @return      void
-        */
-       public function addExtraCityFilters () {
-               // Add some filters here
-       }
-
-       /**
-        * Adds extra tasks to the given handler for this node
-        *
-        * @param       $handlerInstance        An instance of a HandleableTask class
-        * @return      void
-        * @todo        0% done
-        */
-       public function addExtraTasks (HandleableTask $handlerInstance) {
-               $this->partialStub('Please add some tasks or empty this method.');
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/city/main/city/class_BaseCity.php b/application/city/main/city/class_BaseCity.php
deleted file mode 100644 (file)
index e6243f5..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-<?php
-/**
- * A general City class
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2015 City Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class BaseCity extends BaseCitySystem implements Updateable, AddableCriteria {
-       /**
-        * City types
-        */
-       const CITY_TYPE_TESTING = 'testing';
-
-       /**
-        * Whether this City is active (default: FALSE)
-        */
-       private $isActive = FALSE;
-
-       /**
-        * Protected constructor
-        *
-        * @param       $className      Name of the class
-        * @return      void
-        */
-       protected function __construct ($className) {
-               // Call parent constructor
-               parent::__construct($className);
-
-               // Get a wrapper instance
-               $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
-
-               // Set it here
-               $this->setWrapperInstance($wrapperInstance);
-
-               // Get a crypto instance
-               $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
-
-               // Set it here
-               $this->setCryptoInstance($cryptoInstance);
-
-               // Init state which sets the state to 'init'
-               $this->initState();
-       }
-
-       /**
-        * Initializes the City's state which sets it to 'init'
-        *
-        * @return      void
-        */
-       private function initState() {
-               // Get the state factory and create the initial state.
-               CityStateFactory::createCityStateInstanceByName('init', $this);
-       }
-
-       /**
-        * Outputs the console teaser. This should only be executed on startup or
-        * full restarts. This method generates some space around the teaser.
-        *
-        * @return      void
-        */
-       public function outputConsoleTeaser () {
-               // Get the app instance (for shortening our code)
-               $app = $this->getApplicationInstance();
-
-               // Output all lines
-               self::createDebugInstance(__CLASS__)->debugOutput(' ');
-               self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' daemon starting');
-               self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2015 City Developer Team');
-               self::createDebugInstance(__CLASS__)->debugOutput(' ');
-               self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
-               self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain');
-               self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.');
-               self::createDebugInstance(__CLASS__)->debugOutput(' ');
-       }
-
-       /**
-        * Adds City data elements to a given dataset instance
-        *
-        * @param       $criteriaInstance       An instance of a storeable criteria
-        * @param       $requestInstance        An instance of a Requestable class
-        * @return      void
-        */
-       public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) {
-               // Make sure the request instance is set as it is not optional.
-               assert($requestInstance instanceof Requestable);
-
-               // Add City number and type
-               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID  , 1);
-               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $requestInstance->getRequestElement('mode'));
-
-               // Add the City id
-               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID, $this->getCityId());
-
-               // Add the session id if acquired
-               if ($this->getSessionId() != '') {
-                       $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId());
-               } // END - if
-
-               // Add the private key if acquired
-               if ($this->getPrivateKey() != '') {
-                       $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
-                       $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash());
-               } // END - if
-
-               // Add own external and internal addresses as UNLs
-               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, CityTools::determineOwnInternalAddress());
-               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, CityTools::determineOwnExternalAddress());
-       }
-
-       /**
-        * Updates a given field with new value
-        *
-        * @param       $fieldName              Field to update
-        * @param       $fieldValue             New value to store
-        * @return      void
-        * @throws      DatabaseUpdateSupportException  If this class does not support database updates
-        * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
-        */
-       public function updateDatabaseField ($fieldName, $fieldValue) {
-               // Unfinished
-               $this->partialStub('Unfinished!');
-               return;
-
-               // Get a critieria instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Add search criteria
-               $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
-               $searchInstance->setLimit(1);
-
-               // Now get another criteria
-               $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
-
-               // Add criteria entry which we shall update
-               $updateInstance->addCriteria($fieldName, $fieldValue);
-
-               // Add the search criteria for searching for the right entry
-               $updateInstance->setSearchInstance($searchInstance);
-
-               // Set wrapper class name
-               $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
-
-               // Remember the update in database result
-               $this->getResultInstance()->add2UpdateQueue($updateInstance);
-       }
-
-       /**
-        * Activates the City by doing some final preparation and setting
-        * $CityIsActive to TRUE.
-        *
-        * @param       $requestInstance        A Requestable class
-        * @param       $responseInstance       A Responseable class
-        * @return      void
-        */
-       public function activateCity (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the controller here
-               $controllerInstance = Registry::getRegistry()->getInstance('controller');
-
-               // Run all filters for the City activation
-               $controllerInstance->executeActivationFilters($requestInstance, $responseInstance);
-
-               // Make sure the city's state is 'virigin'
-               assert($this->getStateInstance()->validateCityStateIsVirgin() === TRUE);
-
-               // ----------------------- Last step from here ------------------------
-               // Activate the City. This is ALWAYS the last step in this method
-               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getStateInstance()->__toString());
-               $this->getStateInstance()->citySimulationIsActivated();
-               // ---------------------- Last step until here ------------------------
-       }
-
-       /**
-        * Getter for isActive attribute
-        *
-        * @return      $isActive       Whether the City is active
-        */
-       public final function isCityActive () {
-               return $this->isActive;
-       }
-
-       /**
-        * Enables (default) or disables isActive flag
-        *
-        * @param       $isActive       Whether the City is active
-        * @return      void
-        */
-       public final function enableIsActive ($isActive = TRUE) {
-               $this->isActive = (bool) $isActive;
-       }
-
-       /**
-        * Updates/refreshes City data (e.g. status).
-        *
-        * @return      void
-        * @todo        Find more to do here
-        */
-       public function updateCityData () {
-               // Set some dummy configuration entries, e.g. city_status
-               $this->getConfigInstance()->setConfigEntry('city_status', $this->getStateInstance()->getStateName());
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $CityData                       An array with valid City data
-        * @return      void
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $cityData) {
-               // Add all data the array provides
-               foreach (CityInformationDatabaseWrapper::getAllElements() as $element) {
-                       // Is the element there?
-                       if (isset($cityData[$element])) {
-                               // Add it
-                               $dataSetInstance->addCriteria($element, $cityData[$element]);
-                       } else {
-                               // Output warning message
-                               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in CityData array.');
-                       }
-               } // END - foreac
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/city/main/city/testing/.htaccess b/application/city/main/city/testing/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/city/main/city/testing/class_SimulationTestingCity.php b/application/city/main/city/testing/class_SimulationTestingCity.php
deleted file mode 100644 (file)
index 798e3de..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-/**
- * A city class for testing purposes
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2015 City Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class SimulationTestingCity extends BaseCity implements CityHelper, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this hub-node class
-        *
-        * @param       $requestInstance        An instance of a Requestable class
-        * @return      $nodeInstance           An instance of this hub-node class
-        */
-       public static final function createSimulationTestingCity (Requestable $requestInstance) {
-               // Get a new instance
-               $nodeInstance = new SimulationTestingCity();
-
-               // Set the request instance
-               $nodeInstance->setRequestInstance($requestInstance);
-
-               // Return the instance
-               return $nodeInstance;
-       }
-
-       /**
-        * Method to "bootstrap" the node. This step does also apply provided
-        * command-line arguments stored in the request instance. The regular node
-        * should communicate with the bootstrap-nodes at this point.
-        *
-        * @return      void
-        * @todo        Implement this method
-        */
-       public function doBootstrapping () {
-               $this->partialStub();
-       }
-
-       /**
-        * Add some node-specific filters
-        *
-        * @return      void
-        */
-       public function addExtraCityFilters () {
-               // Get the application instance from registry
-               $applicationInstance = Registry::getRegistry()->getInstance('app');
-
-               // Get the controller from the application
-               $controllerInstance = $applicationInstance->getControllerInstance();
-
-               // Foo task
-               // @TODO $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_foo_task_filter'));
-
-               // @TODO Add some filters here
-               $this->partialStub('Add some filters here.');
-       }
-
-       /**
-        * Adds extra tasks to the given handler for this node
-        *
-        * @param       $handlerInstance        An instance of a HandleableTask class
-        * @return      void
-        * @todo        0% done
-        */
-       public function addExtraTasks (HandleableTask $handlerInstance) {
-               $this->partialStub('Please add some tasks or empty this method.');
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/city/main/city_daemon/.htaccess b/application/city/main/city_daemon/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/main/city_daemon/class_ b/application/city/main/city_daemon/class_
new file mode 100644 (file)
index 0000000..94302a2
--- /dev/null
@@ -0,0 +1,98 @@
+<?php
+/**
+ * A hub-node class for the '???' mode
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015 City Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Simulation???CityDaemon extends BaseCity implements CityHelper, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this hub-node class
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      $nodeInstance           An instance of this hub-node class
+        */
+       public final static function createSimulation???CityDaemon (Requestable $requestInstance) {
+               // Get a new instance
+               $nodeInstance = new Simulation???CityDaemon();
+
+               // Set the request instance
+               $nodeInstance->setRequestInstance($requestInstance);
+
+               // Return the instance
+               return $nodeInstance;
+       }
+
+       /**
+        * Method to "bootstrap" the node. This step does also apply provided
+        * command-line arguments stored in the request instance. The regular node
+        * should communicate with the bootstrap-nodes at this point.
+        *
+        * @return      void
+        * @todo        Implement this method
+        */
+       public function doBootstrapping () {
+               // Call generic (parent) bootstrapping method first
+               parent::doGenericBootstrapping();
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Initializes hub-specific queues
+        *
+        * @return      void
+        * @todo        Implement this method
+        */
+       public function initQueues () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Add some node-specific filters
+        *
+        * @return      void
+        */
+       public function addExtraCityFilters () {
+               // Add some filters here
+       }
+
+       /**
+        * Adds extra tasks to the given handler for this node
+        *
+        * @param       $handlerInstance        An instance of a HandleableTask class
+        * @return      void
+        * @todo        0% done
+        */
+       public function addExtraTasks (HandleableTask $handlerInstance) {
+               $this->partialStub('Please add some tasks or empty this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/city/main/city_daemon/class_BaseCityDaemon.php b/application/city/main/city_daemon/class_BaseCityDaemon.php
new file mode 100644 (file)
index 0000000..661c613
--- /dev/null
@@ -0,0 +1,256 @@
+<?php
+/**
+ * A general City class
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015 City Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseCityDaemon extends BaseCitySystem implements Updateable, AddableCriteria {
+       /**
+        * City types
+        */
+       const CITY_TYPE_TESTING = 'testing';
+
+       /**
+        * Whether this City is active (default: FALSE)
+        */
+       private $isActive = FALSE;
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Get a wrapper instance
+               $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class');
+
+               // Set it here
+               $this->setWrapperInstance($wrapperInstance);
+
+               // Get a crypto instance
+               $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+
+               // Set it here
+               $this->setCryptoInstance($cryptoInstance);
+
+               // Add own instance to registry
+               Registry::getRegistry()->addInstance('city', $this);
+
+               // Init state which sets the state to 'init'
+               $this->initState();
+       }
+
+       /**
+        * Initializes the City's state which sets it to 'init'
+        *
+        * @return      void
+        */
+       private function initState() {
+               // Get the state factory and create the initial state.
+               CityStateFactory::createCityStateInstanceByName('init');
+       }
+
+       /**
+        * Outputs the console teaser. This should only be executed on startup or
+        * full restarts. This method generates some space around the teaser.
+        *
+        * @return      void
+        */
+       public function outputConsoleTeaser () {
+               // Get the app instance (for shortening our code)
+               $app = $this->getApplicationInstance();
+
+               // Output all lines
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
+               self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' daemon starting');
+               self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2015 City Developer Team');
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
+               self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
+               self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain');
+               self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.');
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
+       }
+
+       /**
+        * Adds City data elements to a given dataset instance
+        *
+        * @param       $criteriaInstance       An instance of a storeable criteria
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      void
+        */
+       public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) {
+               // Make sure the request instance is set as it is not optional.
+               assert($requestInstance instanceof Requestable);
+
+               // Add City number and type
+               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID  , 1);
+               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $requestInstance->getRequestElement('mode'));
+
+               // Add the City id
+               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID, $this->getCityId());
+
+               // Add the session id if acquired
+               if ($this->getSessionId() != '') {
+                       $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId());
+               } // END - if
+
+               // Add the private key if acquired
+               if ($this->getPrivateKey() != '') {
+                       $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
+                       $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash());
+               } // END - if
+
+               // Add own external and internal addresses as UNLs
+               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, CityTools::determineOwnInternalAddress());
+               $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, CityTools::determineOwnExternalAddress());
+       }
+
+       /**
+        * Updates a given field with new value
+        *
+        * @param       $fieldName              Field to update
+        * @param       $fieldValue             New value to store
+        * @return      void
+        * @throws      DatabaseUpdateSupportException  If this class does not support database updates
+        * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
+        */
+       public function updateDatabaseField ($fieldName, $fieldValue) {
+               // Unfinished
+               $this->partialStub('Unfinished!');
+               return;
+
+               // Get a critieria instance
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Add search criteria
+               $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+               $searchInstance->setLimit(1);
+
+               // Now get another criteria
+               $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
+
+               // Add criteria entry which we shall update
+               $updateInstance->addCriteria($fieldName, $fieldValue);
+
+               // Add the search criteria for searching for the right entry
+               $updateInstance->setSearchInstance($searchInstance);
+
+               // Set wrapper class name
+               $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
+
+               // Remember the update in database result
+               $this->getResultInstance()->add2UpdateQueue($updateInstance);
+       }
+
+       /**
+        * Activates the City by doing some final preparation and setting
+        * $CityIsActive to TRUE.
+        *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
+        * @return      void
+        */
+       public function activateCity (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the controller here
+               $controllerInstance = Registry::getRegistry()->getInstance('controller');
+
+               // Run all filters for the City activation
+               $controllerInstance->executeActivationFilters($requestInstance, $responseInstance);
+
+               // Make sure the city's state is 'virigin'
+               $this->getStateInstance()->validateCityStateIsVirgin();
+
+               // ----------------------- Last step from here ------------------------
+               // Activate the City. This is ALWAYS the last step in this method
+               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getStateInstance()->__toString());
+               $this->getStateInstance()->citySimulationIsActivated();
+               // ---------------------- Last step until here ------------------------
+       }
+
+       /**
+        * Getter for isActive attribute
+        *
+        * @return      $isActive       Whether the City is active
+        */
+       public final function isCityActive () {
+               return $this->isActive;
+       }
+
+       /**
+        * Enables (default) or disables isActive flag
+        *
+        * @param       $isActive       Whether the City is active
+        * @return      void
+        */
+       public final function enableIsActive ($isActive = TRUE) {
+               $this->isActive = (bool) $isActive;
+       }
+
+       /**
+        * Updates/refreshes City data (e.g. status).
+        *
+        * @return      void
+        * @todo        Find more to do here
+        */
+       public function updateCityData () {
+               // Set some dummy configuration entries, e.g. city_status
+               $this->getConfigInstance()->setConfigEntry('city_status', $this->getStateInstance()->getStateName());
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $CityData                       An array with valid City data
+        * @return      void
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $cityData) {
+               // Add all data the array provides
+               foreach (CityInformationDatabaseWrapper::getAllElements() as $element) {
+                       // Is the element there?
+                       if (isset($cityData[$element])) {
+                               // Add it
+                               $dataSetInstance->addCriteria($element, $cityData[$element]);
+                       } else {
+                               // Output warning message
+                               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in CityData array.');
+                       }
+               } // END - foreac
+       }
+
+       /**
+        * Initializes the city daemon
+        *
+        * @return      void
+        */
+       public function bootstrapInitCityDaemon () {
+               $this->partialStub('Please add something here.');
+
+               // Daemon has been fully initialized, so change state to 'virgin'
+               $this->getStateInstance()->daemonHasInitialized();
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/city/main/city_daemon/testing/.htaccess b/application/city/main/city_daemon/testing/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/main/city_daemon/testing/class_SimulationTestingCityDaemon.php b/application/city/main/city_daemon/testing/class_SimulationTestingCityDaemon.php
new file mode 100644 (file)
index 0000000..4931779
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+/**
+ * A city class for testing purposes
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015 City Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class SimulationTestingCityDaemon extends BaseCityDaemon implements CityHelper, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this hub-node class
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      $nodeInstance           An instance of this hub-node class
+        */
+       public static final function createSimulationTestingCityDaemon (Requestable $requestInstance) {
+               // Get a new instance
+               $nodeInstance = new SimulationTestingCityDaemon();
+
+               // Set the request instance
+               $nodeInstance->setRequestInstance($requestInstance);
+
+               // Return the instance
+               return $nodeInstance;
+       }
+
+       /**
+        * Method to "bootstrap" the city simulation. This step does also apply
+        * provided command-line arguments stored in the request instance.
+        *
+        * @return      void
+        * @todo        Implement this method
+        */
+       public function doBootstrapping () {
+               $this->partialStub();
+       }
+
+       /**
+        * Add some node-specific filters
+        *
+        * @return      void
+        */
+       public function addExtraCityFilters () {
+               // Get the application instance from registry
+               $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+               // Get the controller from the application
+               $controllerInstance = $applicationInstance->getControllerInstance();
+
+               // Foo task
+               // @TODO $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_foo_task_filter'));
+
+               // @TODO Add some filters here
+               $this->partialStub('Add some filters here.');
+       }
+
+       /**
+        * Adds extra tasks to the given handler for this node
+        *
+        * @param       $handlerInstance        An instance of a HandleableTask class
+        * @return      void
+        * @todo        0% done
+        */
+       public function addExtraTasks (HandleableTask $handlerInstance) {
+               $this->partialStub('Please add some tasks or empty this method.');
+       }
+}
+
+// [EOF]
+?>
index 80c369166a9257b0b5ce762244cd98507afe0954..a49d86d2f3af57cc482a670bb49983f6e49af7ad 100644 (file)
@@ -72,7 +72,7 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable {
                self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
 
                // Get city instance
-               $cityInstance = CityObjectFactory::createCityInstance();
+               $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance();
 
                // Add some city-specific filters, e.g. announcement
                $cityInstance->addExtraCityFilters();
@@ -120,7 +120,7 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable {
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_welcome_teaser_filter'));
 
                // Add bootstrap filters
-               //$controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_generate_cityid_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_init_daemon_filter'));
 
                // Add city activation filters
                $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_activation_task_handler_initializer_filter'));
index 932228052356ec01de3f5478313e9396f942603a..6bebe8f2dc23f91550a5a8c3ea8088fafeb0ac50 100644 (file)
@@ -94,7 +94,7 @@ class CityInformationDatabaseWrapper extends BaseDatabaseWrapper implements City
         * @param       $requestInstance        An instance of a Requestable class
         * @return      void
         */
-       public function registerCityId (BaseCity $cityInstance, Requestable $requestInstance) {
+       public function registerCityId (BaseCityDaemon $cityInstance, Requestable $requestInstance) {
                // Get a dataset instance
                $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_INFORMATION));
 
diff --git a/application/city/main/factories/city/class_CityDaemonObjectFactory.php b/application/city/main/factories/city/class_CityDaemonObjectFactory.php
new file mode 100644 (file)
index 0000000..0acfe5f
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/**
+ * A factory class for cities
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015 City Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class CityDaemonObjectFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Returns a singleton (registry-based) CityHelper instance
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      $cityInstance           An instance of a CityHelper class
+        * @throws      FactoryRequiredParameterException       If not all parameters are set and no instance 'city' is set.
+        */
+       public static final function createCityDaemonInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) {
+               // Get new factory instance
+               $factoryInstance = new CityDaemonObjectFactory();
+
+               // If there is no handler?
+               if (Registry::getRegistry()->instanceExists('city')) {
+                       // Get handler from registry
+                       $cityInstance = Registry::getRegistry()->getInstance('city');
+               } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) {
+                       // The default city-mode is from our configuration
+                       $cityMode = $factoryInstance->getConfigInstance()->getConfigEntry('city_default_mode');
+
+                       // Is the city 'mode' parameter set?
+                       if ($requestInstance->isRequestElementSet('mode')) {
+                               // Then use this which overrides the config entry temporarily
+                               $cityMode = $requestInstance->getRequestElement('mode');
+                       } else {
+                               // Set it for easier re-usage
+                               $requestInstance->setRequestElement('mode', $cityMode);
+                       }
+
+                       // Now convert the city-mode in a class name
+                       $className = 'Simulation' . $factoryInstance->convertToClassName($cityMode) . 'CityDaemon';
+
+                       // Get the city instance
+                       $cityInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
+
+                       // Get a registry
+                       $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+                       // Set the app instance
+                       $cityInstance->setApplicationInstance($applicationInstance);
+
+                       // Add city-specific filters
+                       $cityInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
+               } else {
+                       // Throw an exception here
+                       throw new FactoryRequiredParameterException($factoryInstance, self::EXCEPTION_FACTORY_REQUIRE_PARAMETER);
+               }
+
+               // Return the instance
+               return $cityInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/city/main/factories/city/class_CityObjectFactory.php b/application/city/main/factories/city/class_CityObjectFactory.php
deleted file mode 100644 (file)
index a4be719..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-/**
- * A factory class for cities
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2015 City Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class CityObjectFactory extends ObjectFactory {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Returns a singleton (registry-based) CityHelper instance
-        *
-        * @param       $requestInstance        An instance of a class with an Requestable interface
-        * @param       $responseInstance       An instance of a class with an Responseable interface
-        * @return      $cityInstance           An instance of a CityHelper class
-        * @throws      FactoryRequiredParameterException       If not all parameters are set and no instance 'city' is set.
-        */
-       public static final function createCityInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) {
-               // Get new factory instance
-               $factoryInstance = new CityObjectFactory();
-
-               // If there is no handler?
-               if (Registry::getRegistry()->instanceExists('city')) {
-                       // Get handler from registry
-                       $cityInstance = Registry::getRegistry()->getInstance('city');
-               } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) {
-                       // The default city-mode is from our configuration
-                       $cityMode = $factoryInstance->getConfigInstance()->getConfigEntry('city_default_mode');
-
-                       // Is the city 'mode' parameter set?
-                       if ($requestInstance->isRequestElementSet('mode')) {
-                               // Then use this which overrides the config entry temporarily
-                               $cityMode = $requestInstance->getRequestElement('mode');
-                       } else {
-                               // Set it for easier re-usage
-                               $requestInstance->setRequestElement('mode', $cityMode);
-                       }
-
-                       // Now convert the city-mode in a class name
-                       $className = 'Simulation' . $factoryInstance->convertToClassName($cityMode) . 'City';
-
-                       // Get the city instance
-                       $cityInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
-
-                       // Get a registry
-                       $applicationInstance = Registry::getRegistry()->getInstance('app');
-
-                       // Set the app instance
-                       $cityInstance->setApplicationInstance($applicationInstance);
-
-                       // Add city-specific filters
-                       $cityInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
-
-                       // Add it to the registry
-                       Registry::getRegistry()->addInstance('city', $cityInstance);
-               } else {
-                       // Throw an exception here
-                       throw new FactoryRequiredParameterException($factoryInstance, self::EXCEPTION_FACTORY_REQUIRE_PARAMETER);
-               }
-
-               // Return the instance
-               return $cityInstance;
-       }
-}
-
-// [EOF]
-?>
index 8c8fffe47b33a7a8ae6c7789e72e04d19801a0f2..6a7794a7e75b56f24ad3cda77ce9c9c05806a35c 100644 (file)
@@ -37,15 +37,17 @@ class CityStateFactory extends ObjectFactory {
         * given city instance.
         *
         * @param       $stateName              Name of the state
-        * @param       $cityInstance   A CityHelper class instance
         * @return      $stateInstance  A Stateable class instance
         */
-       public static final function createCityStateInstanceByName ($stateName, CityHelper $cityInstance) {
+       public static final function createCityStateInstanceByName ($stateName) {
                // Then construct the class' configuraton entry
                $className = 'city_' . $stateName . '_state_class';
 
                // Get a class from that configuration entry
-               $stateInstance = self::createObjectByConfiguredName($className, array($cityInstance));
+               $stateInstance = self::createObjectByConfiguredName($className);
+
+               // Get city instance
+               $cityInstance = Registry::getRegistry()->getInstance('city');
 
                // Debug message
                self::createDebugInstance(__CLASS__)->debugOutput('CITY-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: City state has changed from ' . $cityInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
diff --git a/application/city/main/filter/bootstrap/.htaccess b/application/city/main/filter/bootstrap/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/main/filter/bootstrap/class_CityDaemonBootstrap b/application/city/main/filter/bootstrap/class_CityDaemonBootstrap
new file mode 100644 (file)
index 0000000..9ac5ede
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/**
+ * A bootstrap ??? filter for daemon
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015 City Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class CityDaemonBootstrap???Filter extends BaseCityFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createCityDaemonBootstrap???Filter () {
+               // Get a new instance
+               $filterInstance = new CityDaemonBootstrap???Filter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @throws      FilterChainException    If $cityInstance is null (no NullPointerException here)
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get city instance
+               $cityInstance = Registry::getRegistry()->getInstance('city');
+
+               // Now do something
+               $this->partialStub('Please implement this step.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/city/main/filter/bootstrap/init/.htaccess b/application/city/main/filter/bootstrap/init/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php b/application/city/main/filter/bootstrap/init/class_CityDaemonBootstrapInitDaemonFilter.php
new file mode 100644 (file)
index 0000000..842f620
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/**
+ * A bootstrap InitDaemon filter for daemon
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015 City Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class CityDaemonBootstrapInitDaemonFilter extends BaseCityFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createCityDaemonBootstrapInitDaemonFilter () {
+               // Get a new instance
+               $filterInstance = new CityDaemonBootstrapInitDaemonFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @throws      FilterChainException    If $cityInstance is null (no NullPointerException here)
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get city instance
+               $cityInstance = Registry::getRegistry()->getInstance('city');
+
+               // Now bootstrap the daemon
+               $cityInstance->bootstrapInitCityDaemon();
+       }
+}
+
+// [EOF]
+?>
index 73a78a09afb42b0bf053cef105b0fc7dc874e2a6..108b6c5a4e21f4bc5291334a575e35bb8a64f20e 100644 (file)
@@ -56,16 +56,15 @@ class CityDaemonInitializationFilter extends BaseCityFilter implements Filterabl
                // Try to instance it by using a factory
                try {
                        // Get an instance
-                       $cityInstance = CityObjectFactory::createCityInstance($requestInstance, $responseInstance);
+                       $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance($requestInstance, $responseInstance);
                } catch (ClassNotFoundException $e) {
                        // This exception means, the city mode is invalid.
                        // @TODO Can we rewrite this to app_exit() ?
                        $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']:  city mode ' . $cityMode . ' is invalid.');
                }
 
-               // Set the city instance in registry
-               Registry::getRegistry()->addInstance('city', $cityInstance);
-               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: City ' . $cityMode . ' has been added to registry.');
+               // Debug message
+               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: City daemon ' . $cityMode . ' has been added to registry.');
        }
 }
 
index 936980c7140a70f07d1d2c034990a7009eed8bb9..caf11ed424467fc4a0707d7c915466500be1cd78 100644 (file)
@@ -56,7 +56,7 @@ class CityDaemonWelcomeTeaserFilter extends BaseCityFilter implements Filterable
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get city instance
-               $cityInstance = CityObjectFactory::createCityInstance();
+               $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance();
 
                // Now output the teaser
                $cityInstance->outputConsoleTeaser();
index 624d2f2bab3d22b097948290b333e650e5b4064a..9a0faed8169ef3e550d97dcdb09ede5c91b3b010 100644 (file)
@@ -57,7 +57,7 @@ class CityDaemonShutdownCityFilter extends BaseCityFilter implements Filterable
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get city instance
-               $cityInstance = CityObjectFactory::createCityInstance();
+               $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance();
 
                // Shutdown the city. This should be the last line
                $cityInstance->doShutdown();
index 542aa27eed89f2a9c5c278fe13d6bcbf85707117..bf6fff1e27b697360eed2bbda9013424bb7c7603 100644 (file)
@@ -56,7 +56,7 @@ class CityDaemonTaskHandlerInitializerFilter extends BaseCityFilter implements F
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get city instance
-               $cityInstance = CityObjectFactory::createCityInstance();
+               $cityInstance = CityDaemonObjectFactory::createCityDaemonInstance();
 
                // Get a new task handler instance
                $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class');
index 1a1b74589eee079b77e3a82820d4f2bf781782a5..b3956da0adf02ef792472429d7670546e3ea653e 100644 (file)
@@ -38,15 +38,14 @@ class CityActiveState extends BaseCityState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $cityInstance   An instance of a CityHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createCityActiveState (CityHelper $cityInstance) {
+       public static final function createCityActiveState () {
                // Get new instance
                $stateInstance = new CityActiveState();
 
                // Get city instance and set 'active' flag
-               CityObjectFactory::createCityInstance()->enableIsActive();
+               CityDaemonObjectFactory::createCityDaemonInstance()->enableIsActive();
 
                // Return the prepared instance
                return $stateInstance;
index 250c39dfd542ecb1a771a3cd719ecbfb191eaf7d..a1f38ca3358cdbdd3020e62dde0cd5472f258ff7 100644 (file)
@@ -38,16 +38,12 @@ class City???State extends BaseCityState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $cityInstance   An instance of a CityHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public final static function createCity???State (CityHelper $cityInstance) {
+       public final static function createCity???State () {
                // Get new instance
                $stateInstance = new City???State();
 
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY-STATE: Has changed from ' . $cityInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
                // Return the prepared instance
                return $stateInstance;
        }
index ea9d5b8bace4e0bcaef0ccce24baf92153f643ba..e5765b2b4df3755b2feeef70fe758a52c7657932 100644 (file)
@@ -38,16 +38,36 @@ class CityInitState extends BaseCityState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $cityInstance   An instance of a CityHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createCityInitState (CityHelper $cityInstance) {
+       public static final function createCityInitState () {
                // Get new instance
                $stateInstance = new CityInitState();
 
                // Return the prepared instance
                return $stateInstance;
        }
+
+       /**
+        * Executes the state with given Executor instance
+        *
+        * @param       $executorInstance       An instance of a Executor class
+        * @return      void
+        */
+       public function executeState (Executor $executorInstance) {
+               // Initialize the daemon
+               $executorInstance->initializeDaemon($this);
+       }
+
+       /**
+        * The daemon has been fully initialized so change the state to 'virgin'.
+        *
+        * @return      void
+        */
+       public function daemonHasInitialized () {
+               // Change the state now to 'virgin'
+               CityStateFactory::createCityStateInstanceByName('virgin');
+       }
 }
 
 // [EOF]
index 9a43b87f36a5b754827b3525f6e3b3927de76c3a..a86b73fee43e0db05c8968c46a4fb92b864813bb 100644 (file)
@@ -38,10 +38,9 @@ class CityVirginState extends BaseCityState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $cityInstance   An instance of a CityHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createCityVirginState (CityHelper $cityInstance) {
+       public static final function createCityVirginState () {
                // Get new instance
                $stateInstance = new CityVirginState();
 
diff --git a/core b/core
index c33ae28f2865cdcfb330dbbc6e8159b1d17b9ce0..1c6401b0efc57aaf1735d05c260be92499cc6e32 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit c33ae28f2865cdcfb330dbbc6e8159b1d17b9ce0
+Subproject commit 1c6401b0efc57aaf1735d05c260be92499cc6e32