diff options
author | <philippe colliot> | 2015-04-02 11:40:08 +0200 |
---|---|---|
committer | <philippe colliot> | 2015-04-02 11:40:08 +0200 |
commit | 00c03c5e03c85f82e158c860db9ff75398f8d79d (patch) | |
tree | 784d946c3f9402905d8ffc402ac13e1fa7b40a9e /src/poi-service | |
parent | 4ce01f648637ca50a65f0f25e9c6bf60245f178d (diff) | |
download | poi-service-00c03c5e03c85f82e158c860db9ff75398f8d79d.tar.gz |
Improvement of debug build
Diffstat (limited to 'src/poi-service')
-rw-r--r-- | src/poi-service/poi-manager-server/poi-manager-server-stub.cpp | 388 | ||||
-rw-r--r-- | src/poi-service/poi-manager-server/poi-manager-server-stub.h | 82 |
2 files changed, 366 insertions, 104 deletions
diff --git a/src/poi-service/poi-manager-server/poi-manager-server-stub.cpp b/src/poi-service/poi-manager-server/poi-manager-server-stub.cpp index edefd89..3f9de45 100644 --- a/src/poi-service/poi-manager-server/poi-manager-server-stub.cpp +++ b/src/poi-service/poi-manager-server/poi-manager-server-stub.cpp @@ -26,101 +26,29 @@ */ #include "poi-manager-server-stub.h" -// SQL requests -const char SQL_REQUEST_GET_AVAILABLE_CATEGORIES[] = "SELECT Id,name FROM poicategory WHERE Id IN (SELECT poicategory_Id FROM belongsto GROUP BY poicategory_Id);"; -const char SQL_REQUEST_GET_CATEGORY_ATTRIBUTES[] = "SELECT Id,name FROM poiattribute WHERE Id IN (SELECT poiattribute_Id FROM hasattribute WHERE poicategory_Id IS "; -static const char* SQL_REQUEST_GET_AVAILABLE_AREA = "SELECT leftlongitude,bottomlatitude,rightlongitude,toplatitude FROM availablearea;"; -static const char* SQL_REQUEST_GET_PARENT_CATEGORIES = "SELECT parentId FROM poicategorykinship WHERE childId IS "; -static const char* SQL_REQUEST_GET_CHILD_CATEGORIES = "SELECT childId FROM poicategorykinship WHERE parentId IS "; -static const char* SQL_REQUEST_GET_CATEGORY_ICONS = "SELECT url,format FROM iconset WHERE Id IS (SELECT iconset_Id FROM isdisplayedas WHERE poicategory_Id IS "; -// string conversion to numeric: the third parameter of fromString() should be one of std::hex, std::dec or std::oct -template <class T> -bool fromString(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) -{ - std::istringstream iss(s); - return !(iss >> f >> t).fail(); -} - - -PoiManagerServerStub::PoiManagerServerStub() { - m_version.versionMajor = 1; - m_version.versionMicro = 0; - m_version.versionMinor = 0; - m_version.date = "19-13-2015"; - m_rootCategory = ALL_CATEGORIES; //by default - m_languageCode = "eng"; - m_countryCode = "USA"; - m_scriptCode = "Latn"; - -} -PoiManagerServerStub::~PoiManagerServerStub() { -} - -void PoiManagerServerStub::getVersion(const std::shared_ptr<CommonAPI::ClientId> clientId, NavigationTypes::Version& version) +sqlRequest::sqlRequest() { - version = m_version; } -void PoiManagerServerStub::setLocale(const std::shared_ptr<CommonAPI::ClientId> clientId, std::string languageCode, std::string countryCode, std::string scriptCode) +sqlRequest::~sqlRequest() { - m_languageCode = languageCode; - m_countryCode = countryCode; - m_scriptCode = scriptCode; + delete mp_database; } -void PoiManagerServerStub::getLocale(const std::shared_ptr<CommonAPI::ClientId> clientId, std::string& languageCode, std::string& countryCode, std::string& scriptCode) -{ - languageCode = m_languageCode; - countryCode = m_countryCode; - scriptCode = m_scriptCode; -} - -void PoiManagerServerStub::getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::Locales>& localeList) -{ - POIServiceTypes::Locales en_US { "eng","USA", "Latn" }; - POIServiceTypes::Locales fr_FR { "fra","FRA", "Latn" }; - localeList.push_back(en_US); - localeList.push_back(fr_FR); -} - -void PoiManagerServerStub::getAvailableCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::CategoryAndName>& categories) -{ - POIServiceTypes::CategoryAndName category; - uint16_t index; - - // load categories from the embedded database - for (index = 0; index < m_availableCategories; index++) - { - category.uniqueId = m_availableCategoryTable[index].id; - category.topLevel = m_availableCategoryTable[index].top_level; - category.name = m_availableCategoryTable[index].name; - categories.push_back(category); - } - -} - - -void PoiManagerServerStub::getRootCategory(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID& category) -{ - category = m_rootCategory; -} - -bool PoiManagerServerStub::initDatabase(const char* poiDatabaseFileName) +sqlRequest::SQL_REQUEST_ERRORS sqlRequest::setDatabase(const char *poiDatabaseFileName) { mp_database = new Database(poiDatabaseFileName); - refreshCategoryList(); - return true; //maybe add some check of the file here + return sqlRequest::OK; //todo check if database OK } -void PoiManagerServerStub::onError() +void sqlRequest::onError() { } -// refresh the buffer that contains the categories related data, called each time a category is added or removed -void PoiManagerServerStub::refreshCategoryList() +vector<poi_category_common_t> sqlRequest::getAvailableCategories(POIServiceTypes::CategoryID &rootCategory) { std::string sqlQuery; //SQL request on database std::ostringstream strStream; //temporary stream used for transformation into string @@ -130,9 +58,12 @@ void PoiManagerServerStub::refreshCategoryList() categoryId_t value; categoryId_t parent,child; category_attribute_common_t attribute; + uint16_t availableCategories; + vector<poi_category_common_t> availableCategoryTable; + poi_category_common_t poiCategory; // retrieve the available categories (the ones that have at least one record) - query_result = mp_database->queryNotUTF(SQL_REQUEST_GET_AVAILABLE_CATEGORIES); + query_result = mp_database->queryNotUTF(m_SQL_REQUEST_GET_AVAILABLE_CATEGORIES); if (query_result.empty()) { onError(); //database is not well populated @@ -140,16 +71,16 @@ void PoiManagerServerStub::refreshCategoryList() } else { // Id,name - m_availableCategories = query_result.size(); //store the number of categories - for (index = 0; index < m_availableCategories; index++) + availableCategories = query_result.size(); //store the number of categories + for (index = 0; index < availableCategories; index++) { // read the result of the query and store it query_line = query_result.at(index); fromString<categoryId_t>(value,query_line[0], std::dec); - m_availableCategoryTable[index].id = value; + poiCategory.id = value; // retrieve the associated icons (for the moment, just one) - sqlQuery = SQL_REQUEST_GET_CATEGORY_ICONS; + sqlQuery = m_SQL_REQUEST_GET_CATEGORY_ICONS; strStream.str(""); strStream << value; sqlQuery += strStream.str(); @@ -163,15 +94,15 @@ void PoiManagerServerStub::refreshCategoryList() else { additionnal_query_line = additionnal_query_result.at(0); - m_availableCategoryTable[index].icon = additionnal_query_line[0] + '.' + additionnal_query_line[1]; + poiCategory.icon = additionnal_query_line[0] + '.' + additionnal_query_line[1]; } - m_availableCategoryTable[index].name = query_line[1]; + poiCategory.name = query_line[1]; // retrieve the associated attributes - sqlQuery = SQL_REQUEST_GET_CATEGORY_ATTRIBUTES; + sqlQuery = m_SQL_REQUEST_GET_CATEGORY_ATTRIBUTES; strStream.str(""); - strStream << m_availableCategoryTable[index].id; + strStream << poiCategory.id; sqlQuery += strStream.str(); sqlQuery += ");"; additionnal_query_result = mp_database->queryNotUTF(sqlQuery.c_str()); @@ -188,21 +119,23 @@ void PoiManagerServerStub::refreshCategoryList() fromString<attributeId_t>(attribute.id,additionnal_query_line[0], std::dec); attribute.name = additionnal_query_line[1]; attribute.isSearched = false; - m_availableCategoryTable[index].attributeList.push_back(attribute); + poiCategory.attributeList.push_back(attribute); } } - m_availableCategoryTable[index].top_level = true; //this POC only manages predefined categories - m_availableCategoryTable[index].isSearch = false; //for the moment no categories selected + poiCategory.top_level = true; //this POC only manages predefined categories + poiCategory.isSearch = false; //for the moment no categories selected + + availableCategoryTable.push_back(poiCategory); } } //retrieve the parents of the categories //root category is the only one that is its own parent - for (index = 0; index < m_availableCategories; index++) + for (index = 0; index < availableCategories; index++) { - sqlQuery = SQL_REQUEST_GET_PARENT_CATEGORIES; + sqlQuery = m_SQL_REQUEST_GET_PARENT_CATEGORIES; strStream.str(""); - strStream << m_availableCategoryTable[index].id; + strStream << availableCategoryTable.at(index).id; sqlQuery += strStream.str(); sqlQuery += ";"; query_result = mp_database->queryNotUTF(sqlQuery.c_str()); @@ -218,18 +151,18 @@ void PoiManagerServerStub::refreshCategoryList() query_line = query_result.at(parent); fromString<categoryId_t>(value,query_line[0], std::dec); if (index == value) - m_rootCategory = index; //child is parent, so it's the root - m_availableCategoryTable[index].parentList.push_back(value); + rootCategory = index; //child is parent, so it's the root + availableCategoryTable.at(index).parentList.push_back(value); } } } //retrieve the children of the categories - for (index = 0; index < m_availableCategories; index++) + for (index = 0; index < availableCategories; index++) { - sqlQuery = SQL_REQUEST_GET_CHILD_CATEGORIES; + sqlQuery = m_SQL_REQUEST_GET_CHILD_CATEGORIES; strStream.str(""); - strStream << m_availableCategoryTable[index].id; + strStream << availableCategoryTable.at(index).id; sqlQuery += strStream.str(); sqlQuery += ";"; query_result = mp_database->queryNotUTF(sqlQuery.c_str()); @@ -243,9 +176,264 @@ void PoiManagerServerStub::refreshCategoryList() { query_line = query_result.at(child); fromString<categoryId_t>(value,query_line[0], std::dec); - m_availableCategoryTable[index].childList.push_back(value); + availableCategoryTable.at(index).childList.push_back(value); } } } + return availableCategoryTable; +} + +void sqlRequest::getAvailableArea() +{ + vector<vector<string> > query_result; + vector<string > query_line; + + //retrieve the available area into the database + query_result = mp_database->queryNotUTF(m_SQL_REQUEST_GET_AVAILABLE_AREA); + if (query_result.empty()) + { + onError(); //database is not well populated + //todo something with table ? + } + else + { + // read the result of the query, for the moment only the first area ! + query_line = query_result.at(0); + fromString<double>(m_leftBottomLocation.latitude,query_line[0], std::dec); + fromString<double>(m_leftBottomLocation.longitude,query_line[1], std::dec); + fromString<double>(m_rightTopLocation.latitude,query_line[2], std::dec); + fromString<double>(m_rightTopLocation.longitude,query_line[3], std::dec); + } +} + +sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createCategory(POIServiceTypes::CAMCategory category, POIServiceTypes::CategoryID& unique_id) +{ + sqlRequest::SQL_REQUEST_ERRORS ret; + size_t index; + + //Check if all the parent categories exist + for (index=0;index < category.details.parentsId.size();index++) + { + ret = checkIfCategoryIdExist(category.details.parentsId.at(index)); + if (ret != OK) + return ret; + } + + //Check if the name doesn't exist into the database to avoid duplications + ret = checkIfCategoryNameDoesntExist(category.details.name); + if (ret == OK) + { + //Now create the new category and get the unique id + + + } + + return ret; +} + +sqlRequest::SQL_REQUEST_ERRORS sqlRequest::checkIfCategoryNameDoesntExist(std::string name) +{ + std::string sqlQuery; //SQL request on database + vector<vector<string> > query_result; + vector<string > query_line; + std::ostringstream strStream; //temporary stream used for transformation into string + sqlRequest::SQL_REQUEST_ERRORS ret; + bool retSqlRequest; + + sqlQuery = m_SQL_CHECK_IF_CATEGORY_NAME_EXIST; + strStream.str(""); + strStream << name; + sqlQuery += strStream.str(); + sqlQuery += m_SQL_RETURN_BOOL_VALUE; + query_result = mp_database->queryNotUTF(sqlQuery.c_str()); + if (query_result.empty()) + { + onError(); //database is not well populated + //todo something with table ? + ret = DATABASE_ACCESS_ERROR; + } + else + { + // read the result of the query + query_line = query_result.at(0); + fromString<bool>(retSqlRequest,query_line[0], std::dec); + if (retSqlRequest) + ret = CATEGORY_NAME_ALREADY_EXIST; + else + ret = OK; + } + return ret; +} + +sqlRequest::SQL_REQUEST_ERRORS sqlRequest::checkIfCategoryIdExist(POIServiceTypes::CategoryID unique_id) +{ + std::string sqlQuery; //SQL request on database + vector<vector<string> > query_result; + vector<string > query_line; + std::ostringstream strStream; //temporary stream used for transformation into string + sqlRequest::SQL_REQUEST_ERRORS ret; + bool retSqlRequest; + + sqlQuery = m_SQL_CHECK_IF_CATEGORY_ID_EXIST; + strStream.str(""); + strStream << unique_id; + sqlQuery += strStream.str(); + sqlQuery += m_SQL_RETURN_BOOL_VALUE; + query_result = mp_database->queryNotUTF(sqlQuery.c_str()); + if (query_result.empty()) + { + onError(); //database is not well populated + //todo something with table ? + ret = DATABASE_ACCESS_ERROR; + } + else + { + // read the result of the query + query_line = query_result.at(0); + fromString<bool>(retSqlRequest,query_line[0], std::dec); + if (retSqlRequest) + ret = OK; + else + ret = CATEGORY_ID_NOT_EXIST; + } + return ret; +} + +sqlRequest::SQL_REQUEST_ERRORS sqlRequest::removeCategory(POIServiceTypes::CategoryID unique_id) +{ + sqlRequest::SQL_REQUEST_ERRORS ret; + + return ret; + +} + + + + +PoiManagerServerStub::PoiManagerServerStub() { + m_version.versionMajor = 1; + m_version.versionMicro = 0; + m_version.versionMinor = 0; + m_version.date = "19-13-2015"; + m_rootCategory = ALL_CATEGORIES; //by default + m_languageCode = "eng"; + m_countryCode = "USA"; + m_scriptCode = "Latn"; + m_centerLocation.latitude = 48.85792; //by default center of Paris + m_centerLocation.longitude = 2.3383145; + m_centerLocation.altitude = 0; + + mp_sqlRequest = new sqlRequest; +} + +PoiManagerServerStub::~PoiManagerServerStub() { + delete mp_sqlRequest; +} + +void PoiManagerServerStub::getVersion(const std::shared_ptr<CommonAPI::ClientId> clientId, NavigationTypes::Version& version) +{ + version = m_version; +} + +void PoiManagerServerStub::setLocale(const std::shared_ptr<CommonAPI::ClientId> clientId, std::string languageCode, std::string countryCode, std::string scriptCode) +{ + m_languageCode = languageCode; + m_countryCode = countryCode; + m_scriptCode = scriptCode; +} + +void PoiManagerServerStub::getLocale(const std::shared_ptr<CommonAPI::ClientId> clientId, std::string& languageCode, std::string& countryCode, std::string& scriptCode) +{ + languageCode = m_languageCode; + countryCode = m_countryCode; + scriptCode = m_scriptCode; +} + +void PoiManagerServerStub::getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::Locales>& localeList) +{ + POIServiceTypes::Locales en_US { "eng","USA", "Latn" }; + POIServiceTypes::Locales fr_FR { "fra","FRA", "Latn" }; + localeList.push_back(en_US); + localeList.push_back(fr_FR); +} + +void PoiManagerServerStub::getAvailableCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::CategoryAndName>& categories) +{ + POIServiceTypes::CategoryAndName category; + uint16_t index; + + // load categories from the embedded database + for (index = 0; index < m_availableCategories; index++) + { + category.uniqueId = m_availableCategoryTable.at(index).id; + category.topLevel = m_availableCategoryTable.at(index).top_level; + category.name = m_availableCategoryTable.at(index).name; + categories.push_back(category); + } + +} + +void PoiManagerServerStub::getRootCategory(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID& category) +{ + category = m_rootCategory; +} + +void PoiManagerServerStub::getParentCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID category, std::vector<POIServiceTypes::CategoryAndLevel>& categories) +{ + uint16_t index; + POIServiceTypes::CategoryAndLevel categoryAndLevel; + for (index=0;index<m_availableCategoryTable.at(category).parentList.size();index++) + { + categoryAndLevel.uniqueId = m_availableCategoryTable.at(category).parentList[index]; + categoryAndLevel.topLevel = m_availableCategoryTable.at(categoryAndLevel.uniqueId).top_level; + categories.push_back(categoryAndLevel); + } +} + +void PoiManagerServerStub::getChildrenCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID category, std::vector<POIServiceTypes::CategoryAndLevel>& categories) +{ + uint16_t index; + POIServiceTypes::CategoryAndLevel categoryAndLevel; + for (index=0;index<m_availableCategoryTable.at(category).childList.size();index++) + { + categoryAndLevel.uniqueId = m_availableCategoryTable.at(category).childList[index]; + categoryAndLevel.topLevel = m_availableCategoryTable.at(categoryAndLevel.uniqueId).top_level; + categories.push_back(categoryAndLevel); + } +} + +void PoiManagerServerStub::createCategory(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CAMCategory category, POIServiceTypes::CategoryID& unique_id) +{ + +} + +void PoiManagerServerStub::removeCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::CategoryID> categories) +{ + +} + +void PoiManagerServerStub::addPOIs(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID unique_id, std::vector<POIServiceTypes::PoiAddedDetails> poiList) +{ + +} + +void PoiManagerServerStub::removePOIs(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::POI_ID> ids) +{ + +} + +bool PoiManagerServerStub::initDatabase(const char* poiDatabaseFileName) +{ + mp_sqlRequest->setDatabase(poiDatabaseFileName); + refreshCategoryList(); //read the database and buffer the category list locally + return true; //maybe add some check of the file here +} + +// refresh the buffer that contains the categories related data, called each time a category is added or removed +void PoiManagerServerStub::refreshCategoryList() +{ + m_availableCategoryTable.clear(); + m_availableCategoryTable = mp_sqlRequest->getAvailableCategories(m_rootCategory); + m_availableCategories = m_availableCategoryTable.size(); } diff --git a/src/poi-service/poi-manager-server/poi-manager-server-stub.h b/src/poi-service/poi-manager-server/poi-manager-server-stub.h index 42c0dc7..9880e31 100644 --- a/src/poi-service/poi-manager-server/poi-manager-server-stub.h +++ b/src/poi-service/poi-manager-server/poi-manager-server-stub.h @@ -35,11 +35,71 @@ #include "poi-common-data-model.h" +using namespace std; using namespace org; using namespace genivi; using namespace navigation; using namespace poiservice; +class sqlRequest +{ +public: + + typedef enum + { + CATEGORY_NOT_EXIST, + CATEGORY_NAME_ALREADY_EXIST, + CATEGORY_ID_NOT_EXIST, + PARENT_CATEGORY_NOT_EXIST, + DATABASE_ACCESS_ERROR, + OK + } SQL_REQUEST_ERRORS; + + sqlRequest(); + ~sqlRequest(); + SQL_REQUEST_ERRORS setDatabase(const char* poiDatabaseFileName); + vector<poi_category_common_t> getAvailableCategories(POIServiceTypes::CategoryID& rootCategory); + SQL_REQUEST_ERRORS createCategory(POIServiceTypes::CAMCategory category,POIServiceTypes::CategoryID& unique_id); + SQL_REQUEST_ERRORS removeCategory(POIServiceTypes::CategoryID unique_id); + +private: + const char* m_SQL_REQUEST_GET_AVAILABLE_CATEGORIES = "SELECT Id,name FROM poicategory WHERE Id IN (SELECT poicategory_Id FROM belongsto GROUP BY poicategory_Id);"; + const char* m_SQL_REQUEST_GET_CATEGORY_ATTRIBUTES = "SELECT Id,name FROM poiattribute WHERE Id IN (SELECT poiattribute_Id FROM hasattribute WHERE poicategory_Id IS "; + const char* m_SQL_REQUEST_GET_AVAILABLE_AREA = "SELECT leftlongitude,bottomlatitude,rightlongitude,toplatitude FROM availablearea;"; + const char* m_SQL_REQUEST_GET_PARENT_CATEGORIES = "SELECT parentId FROM poicategorykinship WHERE childId IS "; + const char* m_SQL_REQUEST_GET_CHILD_CATEGORIES = "SELECT childId FROM poicategorykinship WHERE parentId IS "; + const char* m_SQL_REQUEST_GET_CATEGORY_ICONS = "SELECT url,format FROM iconset WHERE Id IS (SELECT iconset_Id FROM isdisplayedas WHERE poicategory_Id IS "; + const char* m_SQL_REQUEST_GET_AVAILABLE_NEXT_FREE_CATEGORY_ID = "SELECT a.id+1 FROM poicategory a WHERE NOT EXISTS (SELECT * FROM poicategory b WHERE a.id+1 = b.id) ORDER BY a.id"; + const char* m_SQL_REQUEST_GET_AVAILABLE_NEXT_FREE_POI_ID = "SELECT a.id+1 FROM poi a WHERE NOT EXISTS (SELECT * FROM poi b WHERE a.id+1 = b.id) ORDER BY a.id"; + const char* m_SQL_INSERT_CATEGORY = "INSERT INTO poicategory VALUES ("; + const char* m_SQL_DELETE_CATEGORY = "DELETE from poicategory WHERE id = "; + const char* m_SQL_CHECK_IF_CATEGORY_ID_EXIST = "SELECT CASE WHEN EXISTS (SELECT * FROM poicategory WHERE id = "; + const char* m_SQL_CHECK_IF_CATEGORY_NAME_EXIST = "SELECT CASE WHEN EXISTS (SELECT * FROM poicategory WHERE name = "; + const char* m_SQL_RETURN_BOOL_VALUE = "THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END"; + + Database *mp_database; // database access + + // string conversion to numeric: the third parameter of fromString() should be one of std::hex, std::dec or std::oct + template <class T> + bool fromString(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) + { + std::istringstream iss(s); + return !(iss >> f >> t).fail(); + } + + void onError(); + + SQL_REQUEST_ERRORS checkIfCategoryNameDoesntExist(std::string name); + + SQL_REQUEST_ERRORS checkIfCategoryIdExist(POIServiceTypes::CategoryID unique_id); + + void getAvailableArea(); + + NavigationTypes::Coordinate2D m_leftBottomLocation,m_rightTopLocation; + +}; + + class PoiManagerServerStub: public org::genivi::navigation::poiservice::POIContentManagerStubDefault { public: @@ -51,20 +111,34 @@ public: void getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::Locales>& localeList); void getAvailableCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::CategoryAndName>& categories); void getRootCategory(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID& category); - + void getChildrenCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID category, std::vector<POIServiceTypes::CategoryAndLevel>& categories); + void getParentCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID category, std::vector<POIServiceTypes::CategoryAndLevel>& categories); + void createCategory(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CAMCategory category, POIServiceTypes::CategoryID& unique_id); + void removeCategories(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::CategoryID> categories); + void addPOIs(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID unique_id, std::vector<POIServiceTypes::PoiAddedDetails> poiList); + void removePOIs(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::POI_ID> ids); bool initDatabase(const char* poiDatabaseFileName); private: NavigationTypes::Version m_version; std::string m_languageCode, m_countryCode, m_scriptCode; - Database *mp_database; // database access uint16_t m_availableCategories; - poi_category_common_t m_availableCategoryTable[MAX_CATEGORIES]; + vector<poi_category_common_t> m_availableCategoryTable; POIServiceTypes::CategoryID m_rootCategory; + NavigationTypes::Coordinate3D m_centerLocation; + sqlRequest* mp_sqlRequest; void refreshCategoryList(); - void onError(); + + // string conversion to numeric: the third parameter of fromString() should be one of std::hex, std::dec or std::oct + template <class T> + bool fromString(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) + { + std::istringstream iss(s); + return !(iss >> f >> t).fail(); + } + }; #endif /* POIMANAGERSERVERSTUBIMPL_H_ */ |