From: Roland Haeder Date: Sat, 25 Jul 2015 19:19:56 +0000 (+0200) Subject: city_map was to generic, better devide the actual map into several layers: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0629a5a64c3ad497fa9f25617ee83064612444f4;p=city.git city_map was to generic, better devide the actual map into several layers: - city_sections : Contains section information about every part of the map - city_policies : Contains policy informations - city_foo : Maybe more? Signed-off-by: Roland Haeder --- diff --git a/application/city/config.php b/application/city/config.php index 9f83710..aea8d54 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -49,8 +49,8 @@ $cfg->setConfigEntry('region_info_db_wrapper_class', 'RegionInformationDatabaseW // CFG: REGION-MAP-DB-WRAPPER-CLASS $cfg->setConfigEntry('region_map_db_wrapper_class', 'RegionMapDatabaseWrapper'); -// CFG: CITY-MAP-DB-WRAPPER-CLASS -$cfg->setConfigEntry('city_map_db_wrapper_class', 'CityMapDatabaseWrapper'); +// CFG: CITY-SECTIONS-DB-WRAPPER-CLASS +$cfg->setConfigEntry('city_sections_db_wrapper_class', 'CitySectionsDatabaseWrapper'); // CFG: CITY-INIT-STATE-CLASS $cfg->setConfigEntry('city_init_state_class', 'CityInitState'); diff --git a/application/city/interfaces/database/frontend/city_map/.htaccess b/application/city/interfaces/database/frontend/city_map/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/interfaces/database/frontend/city_map/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/interfaces/database/frontend/city_map/class_CityMapWrapper.php b/application/city/interfaces/database/frontend/city_map/class_CityMapWrapper.php deleted file mode 100644 index a7017dc..0000000 --- a/application/city/interfaces/database/frontend/city_map/class_CityMapWrapper.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @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 . - */ -interface CityMapWrapper extends DatabaseWrapper { -} - -// [EOF] -?> diff --git a/application/city/interfaces/database/frontend/city_sections/.htaccess b/application/city/interfaces/database/frontend/city_sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/database/frontend/city_sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/database/frontend/city_sections/class_CitySectionsWrapper.php b/application/city/interfaces/database/frontend/city_sections/class_CitySectionsWrapper.php new file mode 100644 index 0000000..3d83212 --- /dev/null +++ b/application/city/interfaces/database/frontend/city_sections/class_CitySectionsWrapper.php @@ -0,0 +1,28 @@ + + * @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 . + */ +interface CitySectionsWrapper extends DatabaseWrapper { +} + +// [EOF] +?> diff --git a/application/city/main/database/frontend/city_map/.htaccess b/application/city/main/database/frontend/city_map/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/application/city/main/database/frontend/city_map/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/city/main/database/frontend/city_map/class_CityMapDatabaseWrapper.php b/application/city/main/database/frontend/city_map/class_CityMapDatabaseWrapper.php deleted file mode 100644 index 657a86a..0000000 --- a/application/city/main/database/frontend/city_map/class_CityMapDatabaseWrapper.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @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 . - */ -class CityMapDatabaseWrapper extends BaseDatabaseWrapper implements CityMapWrapper, Registerable { - // Constants for database table names - const DB_TABLE_CITY_MAP = 'city_map'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createCityMapDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new CityMapDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_CITY_MAP); - - // Return the instance - return $wrapperInstance; - } -} - -// [EOF] -?> diff --git a/application/city/main/database/frontend/city_sections/.htaccess b/application/city/main/database/frontend/city_sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/database/frontend/city_sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/database/frontend/city_sections/class_CitySectionsDatabaseWrapper.php b/application/city/main/database/frontend/city_sections/class_CitySectionsDatabaseWrapper.php new file mode 100644 index 0000000..0ba967d --- /dev/null +++ b/application/city/main/database/frontend/city_sections/class_CitySectionsDatabaseWrapper.php @@ -0,0 +1,60 @@ + + * @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 . + */ +class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySectionsWrapper, Registerable { + // Constants for database table names + const DB_TABLE_CITY_SECTIONS = 'city_sections'; + + // Constants for database column names + const DB_COLUMN_SECTION_ID = 'city_section_id'; + const DB_COLUMN_CITY_ID = 'city_id'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createCitySectionsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new CitySectionsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_CITY_SECTIONS); + + // Return the instance + return $wrapperInstance; + } +} + +// [EOF] +?> diff --git a/application/city/main/database/frontend/region/class_RegionMapDatabaseWrapper.php b/application/city/main/database/frontend/region/class_RegionMapDatabaseWrapper.php deleted file mode 100644 index a2d215b..0000000 --- a/application/city/main/database/frontend/region/class_RegionMapDatabaseWrapper.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @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 . - */ -class RegionMapDatabaseWrapper extends BaseDatabaseWrapper implements RegionMapWrapper, Registerable { - // Constants for database table names - const DB_TABLE_REGION_MAP = 'region_map'; - - // Constants for database column names - const DB_COLUMN_REGION_ID = 'region_id'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createRegionMapDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new RegionMapDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_REGION_MAP); - - // Return the instance - return $wrapperInstance; - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - public function removeNonPublicDataFromArray(array $data) { - // Currently call only inner method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGION-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); - $data = parent::removeNonPublicDataFromArray($data); - - // Return cleaned data - return $data; - } - - /** - * Creates a region by given name - * - * @return void - */ - public function createRegionByName () { - // Pre-check - die(__METHOD__ . ': Unfinshed!'); - assert(!$this->ifRegionExists($regionName)); - - // Get user instance - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Get a dataset instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_REGION_MAP)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_REGION_ID); - - // Add region name and assign user id - $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_ID , ($this->countTotalRows() + 1)); - - // "Insert" this dataset instance completely into the database - $this->queryInsertDataSet($dataSetInstance); - - // Post-check name - assert($this->ifRegionExists($regionName)); - } -} - -// [EOF] -?> diff --git a/application/city/main/database/frontend/region_map/.htaccess b/application/city/main/database/frontend/region_map/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/database/frontend/region_map/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/database/frontend/region_map/class_RegionMapDatabaseWrapper.php b/application/city/main/database/frontend/region_map/class_RegionMapDatabaseWrapper.php new file mode 100644 index 0000000..a2d215b --- /dev/null +++ b/application/city/main/database/frontend/region_map/class_RegionMapDatabaseWrapper.php @@ -0,0 +1,103 @@ + + * @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 . + */ +class RegionMapDatabaseWrapper extends BaseDatabaseWrapper implements RegionMapWrapper, Registerable { + // Constants for database table names + const DB_TABLE_REGION_MAP = 'region_map'; + + // Constants for database column names + const DB_COLUMN_REGION_ID = 'region_id'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createRegionMapDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new RegionMapDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_REGION_MAP); + + // Return the instance + return $wrapperInstance; + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray(array $data) { + // Currently call only inner method + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGION-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); + $data = parent::removeNonPublicDataFromArray($data); + + // Return cleaned data + return $data; + } + + /** + * Creates a region by given name + * + * @return void + */ + public function createRegionByName () { + // Pre-check + die(__METHOD__ . ': Unfinshed!'); + assert(!$this->ifRegionExists($regionName)); + + // Get user instance + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get a dataset instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_REGION_MAP)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_REGION_ID); + + // Add region name and assign user id + $dataSetInstance->addCriteria(self::DB_COLUMN_REGION_ID , ($this->countTotalRows() + 1)); + + // "Insert" this dataset instance completely into the database + $this->queryInsertDataSet($dataSetInstance); + + // Post-check name + assert($this->ifRegionExists($regionName)); + } +} + +// [EOF] +?> diff --git a/application/city/main/manager/city_map/class_CityMapManager.php b/application/city/main/manager/city_map/class_CityMapManager.php index 576c76e..43f5438 100644 --- a/application/city/main/manager/city_map/class_CityMapManager.php +++ b/application/city/main/manager/city_map/class_CityMapManager.php @@ -42,7 +42,7 @@ class CityMapManager extends BaseFrameworkSystem implements ManageableCityMap, R $managerInstance = new CityMapManager(); // Get database wrapper - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_map_db_wrapper_class'); + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_sections_db_wrapper_class'); // And set it here $managerInstance->setWrapperInstance($wrapperInstance); diff --git a/db/city_map/.htaccess b/db/city_map/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/db/city_map/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/db/city_sections/.htaccess b/db/city_sections/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/db/city_sections/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/docs/mindmaps/Simple City Growth Simulation.mm b/docs/mindmaps/Simple City Growth Simulation.mm index ef85a36..a9c6355 100644 --- a/docs/mindmaps/Simple City Growth Simulation.mm +++ b/docs/mindmaps/Simple City Growth Simulation.mm @@ -50,7 +50,7 @@ - + @@ -134,6 +134,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -209,8 +254,8 @@ - + @@ -252,9 +297,9 @@ - - + + @@ -262,8 +307,8 @@ - + @@ -281,8 +326,8 @@ - + @@ -305,8 +350,8 @@ - + @@ -430,8 +475,8 @@ - + @@ -621,34 +666,34 @@ - + - + - + - + - + - + @@ -1001,8 +1046,8 @@ - + @@ -1073,12 +1118,12 @@ - + - + @@ -1840,23 +1885,23 @@ - + + - - + - + @@ -1867,8 +1912,8 @@ - + @@ -1897,12 +1942,12 @@ - + - +