From 67e1a16e2bc085cd8cf8d5adadbb77fa23801ecc Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 1 Jul 2015 03:19:52 +0200 Subject: [PATCH] Added initial database frontend class for city maps + its interface. Signed-off-by: Roland Haeder --- application/city/config.php | 3 + .../frontend/city_map}/.htaccess | 0 .../city_map/class_CityMapWrapper.php} | 4 +- .../interfaces/manager/city_map/.htaccess | 1 + .../city_map/class_ManageableCityMap.php | 34 +++++++++++ .../main/city_daemon/class_BaseCityDaemon.php | 3 +- .../main/database/frontend/city_map/.htaccess | 1 + .../city_map/class_CityMapDatabaseWrapper.php | 56 +++++++++++++++++++ .../manager/city_map/class_CityMapManager.php | 20 ++++++- db/city_map/.htaccess | 1 + 10 files changed, 118 insertions(+), 5 deletions(-) rename application/city/interfaces/{manager/map => database/frontend/city_map}/.htaccess (100%) rename application/city/interfaces/{manager/map/class_ManageableMap.php => database/frontend/city_map/class_CityMapWrapper.php} (89%) create mode 100644 application/city/interfaces/manager/city_map/.htaccess create mode 100644 application/city/interfaces/manager/city_map/class_ManageableCityMap.php create mode 100644 application/city/main/database/frontend/city_map/.htaccess create mode 100644 application/city/main/database/frontend/city_map/class_CityMapDatabaseWrapper.php create mode 100644 db/city_map/.htaccess diff --git a/application/city/config.php b/application/city/config.php index 5e98a6a..9f83710 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -49,6 +49,9 @@ $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-INIT-STATE-CLASS $cfg->setConfigEntry('city_init_state_class', 'CityInitState'); diff --git a/application/city/interfaces/manager/map/.htaccess b/application/city/interfaces/database/frontend/city_map/.htaccess similarity index 100% rename from application/city/interfaces/manager/map/.htaccess rename to application/city/interfaces/database/frontend/city_map/.htaccess diff --git a/application/city/interfaces/manager/map/class_ManageableMap.php b/application/city/interfaces/database/frontend/city_map/class_CityMapWrapper.php similarity index 89% rename from application/city/interfaces/manager/map/class_ManageableMap.php rename to application/city/interfaces/database/frontend/city_map/class_CityMapWrapper.php index fdea29d..a7017dc 100644 --- a/application/city/interfaces/manager/map/class_ManageableMap.php +++ b/application/city/interfaces/database/frontend/city_map/class_CityMapWrapper.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface ManageableMap extends FrameworkInterface { +interface CityMapWrapper extends DatabaseWrapper { } // [EOF] diff --git a/application/city/interfaces/manager/city_map/.htaccess b/application/city/interfaces/manager/city_map/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/manager/city_map/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/manager/city_map/class_ManageableCityMap.php b/application/city/interfaces/manager/city_map/class_ManageableCityMap.php new file mode 100644 index 0000000..dc7172c --- /dev/null +++ b/application/city/interfaces/manager/city_map/class_ManageableCityMap.php @@ -0,0 +1,34 @@ + + * @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 ManageableCityMap extends FrameworkInterface { + /** + * Checks whether at least one map requires expansion + * + * @return $requiresExpansion Whether a map requires expansion + */ + function isMapPendingExpansion (); +} + +// [EOF] +?> diff --git a/application/city/main/city_daemon/class_BaseCityDaemon.php b/application/city/main/city_daemon/class_BaseCityDaemon.php index 3aeadce..ed5f327 100644 --- a/application/city/main/city_daemon/class_BaseCityDaemon.php +++ b/application/city/main/city_daemon/class_BaseCityDaemon.php @@ -260,7 +260,8 @@ class BaseCityDaemon extends BaseCitySystem implements Updateable, AddableCriter // Get map manager $mapInstance = ManagerFactory::createManagerByType('city_map'); - $this->partialStub('Please add something here.'); + // Call it's method and return value + return $mapInstance->isMapPendingExpansion(); } } diff --git a/application/city/main/database/frontend/city_map/.htaccess b/application/city/main/database/frontend/city_map/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/database/frontend/city_map/.htaccess @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000..657a86a --- /dev/null +++ b/application/city/main/database/frontend/city_map/class_CityMapDatabaseWrapper.php @@ -0,0 +1,56 @@ + + * @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/manager/city_map/class_CityMapManager.php b/application/city/main/manager/city_map/class_CityMapManager.php index 2b5cbe1..cfee707 100644 --- a/application/city/main/manager/city_map/class_CityMapManager.php +++ b/application/city/main/manager/city_map/class_CityMapManager.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class CityMapManager extends BaseFrameworkSystem implements ManageableMap, Registerable { +class CityMapManager extends BaseFrameworkSystem implements ManageableCityMap, Registerable { /** * Protected constructor * @@ -35,15 +35,31 @@ class CityMapManager extends BaseFrameworkSystem implements ManageableMap, Regis /** * Creates an instance of this class * - * @return $managerInstance An instance of a ManageableMap class + * @return $managerInstance An instance of a ManageableCityMap class */ public final static function createCityMapManager () { // Get new instance $managerInstance = new CityMapManager(); + // Get database wrapper + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('city_map_db_wrapper_class'); + + // And set it here + $managerInstance->setWrapperInstance($wrapperInstance); + // Return the prepared instance return $managerInstance; } + + /** + * Checks whether at least one map requires expansion + * + * @return $requiresExpansion Whether a map requires expansion + * @todo 0% done + */ + public function isMapPendingExpansion () { + $this->partialStub('Please implement this method.'); + } } // [EOF] diff --git a/db/city_map/.htaccess b/db/city_map/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/db/city_map/.htaccess @@ -0,0 +1 @@ +Deny from all -- 2.39.5