From 3bee0cdfe0146e3222ebe91c72012cfd8508a9a2 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Fri, 3 Oct 2025 13:55:19 +0200 Subject: [PATCH 01/15] =?UTF-8?q?Export=20de=20CurlPool=20de=20Cache=20ver?= =?UTF-8?q?s=20son=20propre=20fichier=20et=20changement=20des=20imports=20?= =?UTF-8?q?impliqu=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/utils/Cache.h | 79 -------------------------- include/rok4/utils/CurlPool.h | 101 ++++++++++++++++++++++++++++++++++ src/storage/S3Context.cpp | 6 -- src/storage/S3Context.h | 1 + src/storage/SwiftContext.cpp | 3 - src/storage/SwiftContext.h | 1 + src/utils/CurlPool.cpp | 68 +++++++++++++++++++++++ 7 files changed, 171 insertions(+), 88 deletions(-) create mode 100644 include/rok4/utils/CurlPool.h create mode 100644 src/utils/CurlPool.cpp diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h index 811a7d0e..45277d95 100644 --- a/include/rok4/utils/Cache.h +++ b/include/rok4/utils/Cache.h @@ -70,85 +70,6 @@ #define ROK4_STYLES_DIRECTORY "ROK4_STYLES_DIRECTORY" #define ROK4_STYLES_NO_CACHE "ROK4_STYLES_NO_CACHE" -/** - * \author Institut national de l'information géographique et forestière - * \~french - * \brief Création d'un pool d'environnement Curl - * \details Cette classe est prévue pour être utilisée sans instance - */ -class CurlPool { - -private: - - /** - * \~french \brief Annuaire des objet Curl - * \details La clé est l'identifiant du thread - * \~english \brief Curl object book - * \details Key is the thread's ID - */ - static std::map pool; - - /** - * \~french - * \brief Constructeur - * \~english - * \brief Constructeur - */ - CurlPool(){}; - -public: - - /** - * \~french - * \brief Destructeur - * \~english - * \brief Destructor - */ - ~CurlPool(){}; - - /** - * \~french \brief Retourne un objet Curl propre au thread appelant - * \details Si il n'existe pas encore d'objet curl pour ce tread, on le crée et on l'initialise - * \~english \brief Get the curl object specific to the calling thread - * \details If curl object doesn't exist for this thread, it is created and initialized - */ - static CURL* get_curl_env() { - pthread_t i = pthread_self(); - - std::map::iterator it = pool.find ( i ); - if ( it == pool.end() ) { - CURL* c = curl_easy_init(); - pool.insert ( std::pair(i,c) ); - return c; - } else { - curl_easy_reset(it->second); - return it->second; - } - } - - /** - * \~french \brief Affiche le nombre d'objet curl dans l'annuaire - * \~english \brief Print the number of curl objects in the book - */ - static void print_curls_count () { - BOOST_LOG_TRIVIAL(info) << "Nombre de contextes curl : " << pool.size(); - } - - /** - * \~french \brief Nettoie tous les objets curl dans l'annuaire et le vide - * \~english \brief Clean all curl objects in the book and empty it - */ - static void clean_curls () { - std::map::iterator it; - for (it = pool.begin(); it != pool.end(); ++it) { - curl_easy_cleanup(it->second); - } - pool.clear(); - } - -}; - - /** * \author Institut national de l'information géographique et forestière * \~french diff --git a/include/rok4/utils/CurlPool.h b/include/rok4/utils/CurlPool.h new file mode 100644 index 00000000..0f239b18 --- /dev/null +++ b/include/rok4/utils/CurlPool.h @@ -0,0 +1,101 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +#pragma once + +#include +#include +#include +#include + +/** + * \author Institut national de l'information géographique et forestière + * \~french + * \brief Création d'un pool d'environnement Curl + * \details Cette classe est prévue pour être utilisée sans instance + */ +class CurlPool { + +private: + + /** + * \~french \brief Annuaire des objet Curl + * \details La clé est l'identifiant du thread + * \~english \brief Curl object book + * \details Key is the thread's ID + */ + static std::map pool; + + /** + * \~french + * \brief Constructeur + * \~english + * \brief Constructeur + */ + CurlPool(){}; + +public: + + /** + * \~french + * \brief Destructeur + * \~english + * \brief Destructor + */ + ~CurlPool(); + + /** + * \~french \brief Retourne un objet Curl propre au thread appelant + * \details Si il n'existe pas encore d'objet curl pour ce tread, on le crée et on l'initialise + * \~english \brief Get the curl object specific to the calling thread + * \details If curl object doesn't exist for this thread, it is created and initialized + */ + static CURL* get_curl_env(); + + /** + * \~french \brief Affiche le nombre d'objet curl dans l'annuaire + * \~english \brief Print the number of curl objects in the book + */ + static void print_curls_count (); + + /** + * \~french \brief Nettoie tous les objets curl dans l'annuaire et le vide + * \~english \brief Clean all curl objects in the book and empty it + */ + static void clean_curls (); + +}; diff --git a/src/storage/S3Context.cpp b/src/storage/S3Context.cpp index c956d4d4..4261c985 100644 --- a/src/storage/S3Context.cpp +++ b/src/storage/S3Context.cpp @@ -49,16 +49,10 @@ #include "storage/S3Context.h" -#include #include -#include #include #include -#include "S3Context.h" -#include "utils/Cache.h" -#include "utils/LibcurlStruct.h" - std::vector S3Context::env_hosts; std::vector S3Context::env_keys; std::vector S3Context::env_secret_keys; diff --git a/src/storage/S3Context.h b/src/storage/S3Context.h index e2827e07..e49bc152 100644 --- a/src/storage/S3Context.h +++ b/src/storage/S3Context.h @@ -53,6 +53,7 @@ #include #include "storage/Context.h" #include "utils/LibcurlStruct.h" +#include "utils/CurlPool.h" #define ROK4_S3_URL "ROK4_S3_URL" #define ROK4_S3_KEY "ROK4_S3_KEY" diff --git a/src/storage/SwiftContext.cpp b/src/storage/SwiftContext.cpp index c50f9ac8..8c557d41 100644 --- a/src/storage/SwiftContext.cpp +++ b/src/storage/SwiftContext.cpp @@ -48,10 +48,7 @@ */ #include "storage/SwiftContext.h" -#include "utils/LibcurlStruct.h" -#include #include -#include "utils/Cache.h" #include SwiftContext::SwiftContext (std::string cont) : Context(), ssl_no_verify(false), keystone_auth(false), container_name(cont), use_token_from_file(true) { diff --git a/src/storage/SwiftContext.h b/src/storage/SwiftContext.h index e3b02e96..ffb30706 100644 --- a/src/storage/SwiftContext.h +++ b/src/storage/SwiftContext.h @@ -54,6 +54,7 @@ #include "storage/Context.h" #include "utils/LibcurlStruct.h" #include +#include "utils/CurlPool.h" #define ROK4_SWIFT_AUTHURL "ROK4_SWIFT_AUTHURL" diff --git a/src/utils/CurlPool.cpp b/src/utils/CurlPool.cpp new file mode 100644 index 00000000..78a7d958 --- /dev/null +++ b/src/utils/CurlPool.cpp @@ -0,0 +1,68 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +#include "utils/CurlPool.h" + +CurlPool::~CurlPool(){ + +} + +CURL *CurlPool::get_curl_env() { + pthread_t i = pthread_self(); + + std::map::iterator it = pool.find ( i ); + if ( it == pool.end() ) { + CURL* c = curl_easy_init(); + pool.insert ( std::pair(i,c) ); + return c; + } else { + curl_easy_reset(it->second); + return it->second; + } +} + +void CurlPool::print_curls_count() { + BOOST_LOG_TRIVIAL(info) << "Nombre de contextes curl : " << pool.size(); +} + +void CurlPool::clean_curls() { + std::map::iterator it; + for (it = pool.begin(); it != pool.end(); ++it) { + curl_easy_cleanup(it->second); + } + pool.clear(); +} From 515aebbdf6463670801dc69a3a5c20c885093ada Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Fri, 3 Oct 2025 15:59:17 +0200 Subject: [PATCH 02/15] ajout documentation manquante --- src/utils/CurlPool.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/CurlPool.cpp b/src/utils/CurlPool.cpp index 78a7d958..4e3f5e5d 100644 --- a/src/utils/CurlPool.cpp +++ b/src/utils/CurlPool.cpp @@ -35,6 +35,14 @@ * knowledge of the CeCILL-C license and that you accept its terms. */ + /** + * \file CurlPool.cpp + ** \~french + * \brief Implémentation de la classe CurlPool + ** \~english + * \brief Implements classe CurlPool + */ + #include "utils/CurlPool.h" CurlPool::~CurlPool(){ From bfaae02a9a606f8a3aee5c3a623c4a0e5a217e48 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Fri, 3 Oct 2025 17:58:08 +0200 Subject: [PATCH 03/15] Export de ProjPool en dehors de Cache --- include/rok4/processors/Grid.h | 1 + include/rok4/utils/CRS.h | 4 ++ include/rok4/utils/Cache.h | 80 +-------------------------- include/rok4/utils/ProjPool.h | 99 ++++++++++++++++++++++++++++++++++ src/processors/Grid.cpp | 2 - src/utils/CRS.cpp | 5 -- src/utils/Cache.cpp | 1 + src/utils/ProjPool.cpp | 79 +++++++++++++++++++++++++++ 8 files changed, 185 insertions(+), 86 deletions(-) create mode 100644 include/rok4/utils/ProjPool.h create mode 100644 src/utils/ProjPool.cpp diff --git a/include/rok4/processors/Grid.h b/include/rok4/processors/Grid.h index 06dabe0c..cbfc36bd 100644 --- a/include/rok4/processors/Grid.h +++ b/include/rok4/processors/Grid.h @@ -49,6 +49,7 @@ #include "rok4/utils/CRS.h" #include #include +#include "rok4/utils/ProjPool.h" /** * \author Institut national de l'information géographique et forestière diff --git a/include/rok4/utils/CRS.h b/include/rok4/utils/CRS.h index ab29e51e..2cf8d0ea 100644 --- a/include/rok4/utils/CRS.h +++ b/include/rok4/utils/CRS.h @@ -47,7 +47,11 @@ #pragma once #include +#include +#include #include "rok4/utils/BoundingBox.h" +#include "rok4/utils/ProjPool.h" +#include "rok4/utils/Utils.h" /** * \~french \brief Code utilisé en cas de non correspondance avec les référentiel de Proj diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h index 45277d95..553760fa 100644 --- a/include/rok4/utils/Cache.h +++ b/include/rok4/utils/Cache.h @@ -65,90 +65,12 @@ #include "rok4/utils/CRS.h" #include "rok4/storage/Context.h" + #define ROK4_TMS_DIRECTORY "ROK4_TMS_DIRECTORY" #define ROK4_TMS_NO_CACHE "ROK4_TMS_NO_CACHE" #define ROK4_STYLES_DIRECTORY "ROK4_STYLES_DIRECTORY" #define ROK4_STYLES_NO_CACHE "ROK4_STYLES_NO_CACHE" -/** - * \author Institut national de l'information géographique et forestière - * \~french - * \brief Création d'un pool de contextes Proj - * \details Cette classe est prévue pour être utilisée sans instance - */ -class ProjPool { - -private: - - /** - * \~french \brief Annuaire des contextes Proj - * \details La clé est l'identifiant du thread - * \~english \brief Proj contexts book - * \details Key is the thread's ID - */ - static std::map pool; - - /** - * \~french - * \brief Constructeur - * \~english - * \brief Constructeur - */ - ProjPool(){}; - -public: - - /** - * \~french - * \brief Destructeur - * \~english - * \brief Destructor - */ - ~ProjPool(){}; - - /** - * \~french \brief Retourne un contexte Proj propre au thread appelant - * \details Si il n'existe pas encore de contexte Proj pour ce tread, on le crée et on l'initialise - * \~english \brief Get the Proj context specific to the calling thread - * \details If Proj context doesn't exist for this thread, it is created and initialized - */ - static PJ_CONTEXT* get_proj_env() { - pthread_t i = pthread_self(); - - std::map::iterator it = pool.find ( i ); - if ( it == pool.end() ) { - PJ_CONTEXT* pjc = proj_context_create(); - proj_log_level(pjc, PJ_LOG_NONE); - pool.insert ( std::pair(i,pjc) ); - return pjc; - } else { - return it->second; - } - } - - /** - * \~french \brief Affiche le nombre de contextes proj dans l'annuaire - * \~english \brief Print the number of proj contexts in the book - */ - static void print_projs_count () { - BOOST_LOG_TRIVIAL(info) << "Nombre de contextes proj : " << pool.size() ; - } - - /** - * \~french \brief Nettoie tous les contextes proj dans l'annuaire et le vide - * \~english \brief Clean all proj objects in the book and empty it - */ - static void clean_projs () { - std::map::iterator it; - for (it = pool.begin(); it != pool.end(); ++it) { - proj_context_destroy(it->second); - } - pool.clear(); - } - -}; - - /** * \author Institut national de l'information géographique et forestière * \~french diff --git a/include/rok4/utils/ProjPool.h b/include/rok4/utils/ProjPool.h new file mode 100644 index 00000000..71a83385 --- /dev/null +++ b/include/rok4/utils/ProjPool.h @@ -0,0 +1,99 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +#pragma once + +#include +#include +#include + +/** + * \author Institut national de l'information géographique et forestière + * \~french + * \brief Création d'un pool de contextes Proj + * \details Cette classe est prévue pour être utilisée sans instance + */ +class ProjPool { + +private: + + /** + * \~french \brief Annuaire des contextes Proj + * \details La clé est l'identifiant du thread + * \~english \brief Proj contexts book + * \details Key is the thread's ID + */ + static std::map pool; + + /** + * \~french + * \brief Constructeur + * \~english + * \brief Constructeur + */ + ProjPool(); + +public: + + /** + * \~french + * \brief Destructeur + * \~english + * \brief Destructor + */ + ~ProjPool(); + + /** + * \~french \brief Retourne un contexte Proj propre au thread appelant + * \details Si il n'existe pas encore de contexte Proj pour ce tread, on le crée et on l'initialise + * \~english \brief Get the Proj context specific to the calling thread + * \details If Proj context doesn't exist for this thread, it is created and initialized + */ + static PJ_CONTEXT* get_proj_env(); + + /** + * \~french \brief Affiche le nombre de contextes proj dans l'annuaire + * \~english \brief Print the number of proj contexts in the book + */ + static void print_projs_count (); + + /** + * \~french \brief Nettoie tous les contextes proj dans l'annuaire et le vide + * \~english \brief Clean all proj objects in the book and empty it + */ + static void clean_projs (); +}; diff --git a/src/processors/Grid.cpp b/src/processors/Grid.cpp index 0a6d8b34..bb99d8fa 100644 --- a/src/processors/Grid.cpp +++ b/src/processors/Grid.cpp @@ -48,8 +48,6 @@ #include "processors/Grid.h" #include -#include "utils/Cache.h" - #include #include diff --git a/src/utils/CRS.cpp b/src/utils/CRS.cpp index 187acf0f..e4268e1a 100644 --- a/src/utils/CRS.cpp +++ b/src/utils/CRS.cpp @@ -43,12 +43,7 @@ * \brief implement the reference systems handler */ -#include -#include - #include "utils/CRS.h" -#include "utils/Cache.h" -#include "utils/Utils.h" CRS CRS::epsg4326; diff --git a/src/utils/Cache.cpp b/src/utils/Cache.cpp index fb4fdf8f..91ebdd8d 100644 --- a/src/utils/Cache.cpp +++ b/src/utils/Cache.cpp @@ -44,6 +44,7 @@ */ #include "utils/Cache.h" +#include "rok4/utils/ProjPool.h" #include "storage/FileContext.h" #include "storage/SwiftContext.h" #include "storage/S3Context.h" diff --git a/src/utils/ProjPool.cpp b/src/utils/ProjPool.cpp new file mode 100644 index 00000000..3bd63b22 --- /dev/null +++ b/src/utils/ProjPool.cpp @@ -0,0 +1,79 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file ProjPool.cpp + ** \~french + * \brief Implémentation de la classe ProjPool + ** \~english + * \brief Implements classe ProjPool + */ + + +#include "rok4/utils/ProjPool.h" + +ProjPool::ProjPool(){ +} + +ProjPool::~ProjPool(){ +} + +PJ_CONTEXT *ProjPool::get_proj_env() { + pthread_t i = pthread_self(); + + std::map::iterator it = pool.find ( i ); + if ( it == pool.end() ) { + PJ_CONTEXT* pjc = proj_context_create(); + proj_log_level(pjc, PJ_LOG_NONE); + pool.insert ( std::pair(i,pjc) ); + return pjc; + } else { + return it->second; + } +} + +void ProjPool::print_projs_count() { + BOOST_LOG_TRIVIAL(info) << "Nombre de contextes proj : " << pool.size() ; +} + +void ProjPool::clean_projs() { + std::map::iterator it; + for (it = pool.begin(); it != pool.end(); ++it) { + proj_context_destroy(it->second); + } + pool.clear(); +} From bad30bce6adb4e276b2e9048799f5ee216b2029a Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 6 Oct 2025 16:36:08 +0200 Subject: [PATCH 04/15] Export de StoragePool en dehors de la classe Cache --- include/rok4/style/Style.h | 1 + include/rok4/utils/Cache.h | 141 ------------------------------- include/rok4/utils/StoragePool.h | 131 ++++++++++++++++++++++++++++ src/datasource/StoreDataSource.h | 1 + src/style/Style.cpp | 1 - src/utils/StoragePool.cpp | 114 +++++++++++++++++++++++++ 6 files changed, 247 insertions(+), 142 deletions(-) create mode 100644 include/rok4/utils/StoragePool.h create mode 100644 src/utils/StoragePool.cpp diff --git a/include/rok4/style/Style.h b/include/rok4/style/Style.h index 766a22d6..33bc9556 100644 --- a/include/rok4/style/Style.h +++ b/include/rok4/style/Style.h @@ -57,6 +57,7 @@ class Style; #include "rok4/style/Aspect.h" #include "rok4/enums/Interpolation.h" #include "rok4/utils/Configuration.h" +#include "rok4/utils/StoragePool.h" #include "rok4/enums/Format.h" /** diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h index 553760fa..c6fec8b3 100644 --- a/include/rok4/utils/Cache.h +++ b/include/rok4/utils/Cache.h @@ -71,147 +71,6 @@ #define ROK4_STYLES_DIRECTORY "ROK4_STYLES_DIRECTORY" #define ROK4_STYLES_NO_CACHE "ROK4_STYLES_NO_CACHE" -/** - * \author Institut national de l'information géographique et forestière - * \~french - * \brief Création d'un pool de contextes de stockage - * \details Cette classe est prévue pour être utilisée sans instance - */ -class StoragePool { - -private: - - /** - * \~french - * \brief Constructeur - * \~english - * \brief Constructeur - */ - StoragePool(){}; - - /** - * \~french \brief Annuaire de contextes - * \details La clé est une paire composée du type de stockage et du contenant du contexte - * \~english \brief Book of contexts - * \details Key is a pair composed of type of storage and the context's bucket - */ - static std::map,Context*> pool; - - -public: - - - /** - * \~french \brief Retourne une chaîne de caracère décrivant l'annuaire - * \~english \brief Return a string describing the pool - */ - static std::string to_string() { - std::ostringstream oss; - oss.setf ( std::ios::fixed,std::ios::floatfield ); - oss << "------ Context pool -------" << std::endl; - oss << "\t- context number = " << pool.size() << std::endl; - - std::map, Context*>::iterator it = pool.begin(); - while (it != pool.end()) { - std::pair key = it->first; - oss << "\t\t- pot = " << key.first << "/" << key.second << std::endl; - oss << it->second->to_string() << std::endl; - it++; - } - - return oss.str() ; - } - - /** - * \~french - * \brief Récupère un contexte de stockage - * \details Si un contexte existe déjà pour ce nom de contenant, on ne crée pas de nouveau contexte et on retourne celui déjà existant. Le nouveau contexte n'est pas connecté. - * \param[in] type type de stockage pour lequel on veut créer un contexte - * \param[in] tray Nom du contenant pour lequel on veut créer un contexte - * \param[in] reference_context Contexte de stockage de référence - - * \brief Get a context storage - * \details If a context already exists for this tray's name, we don't create a new one and the existing is returned. New context is not connected. - * \param[in] type Storage Type for which context is created - * \param[in] tray Tray's name for which context is created - * \param[in] reference_context Reference storage context - - */ - static Context * get_context(ContextType::eContextType type,std::string tray, Context* reference_context = 0) ; - - - /** - * \~french \brief Retourne le nombre de contextes de stockage dans l'annuaire par type - * \param[out] file_count Nombre de contexte de stockage fichier - * \param[out] s3_count Nombre de contexte de stockage S3 - * \param[out] ceph_count Nombre de contexte de stockage Ceph - * \param[out] swift_count Nombre de contexte de stockage Swift - * \~english \brief Return the number of storage contexts in the book per type - * \param[out] file_count File storage context count - * \param[out] s3_count S3 storage context count - * \param[out] ceph_count Ceph storage context count - * \param[out] swift_count Swift storage context count - */ - static void get_storages_count (int& file_count, int& s3_count, int& ceph_count, int& swift_count) { - file_count = 0; - s3_count = 0; - ceph_count = 0; - swift_count = 0; - std::map, Context*>::iterator it = pool.begin(); - while (it != pool.end()) { - std::pair key = it->first; - switch(key.first) { -#if CEPH_ENABLED - case ContextType::CEPHCONTEXT: - ceph_count++; - break; -#endif - case ContextType::SWIFTCONTEXT: - swift_count++; - break; - case ContextType::S3CONTEXT: - s3_count++; - break; - case ContextType::FILECONTEXT: - file_count++; - break; - } - it++; - } - } - - /** - * \~french \brief Obtient l'annuaire de contextes - * \details La clé est une paire composée du type de stockage et du contenant du contexte - * \~english \brief Get book of contexts - * \details Key is a pair composed of type of storage and the context's bucket - */ - static std::map,Context*> get_pool() { - return pool; - } - - /** - * \~french - * \brief Destructeur - * \~english - * \brief Destructor - */ - ~StoragePool() {}; - - /** - * \~french \brief Nettoie tous les contextes de stockage dans l'annuaire et le vide - * \~english \brief Clean all storage context objects in the book and empty it - */ - static void clean_storages () { - std::map,Context*>::iterator it; - for (it=pool.begin(); it!=pool.end(); ++it) { - delete it->second; - it->second = NULL; - } - } - -}; - /** * \author Institut national de l'information géographique et forestière diff --git a/include/rok4/utils/StoragePool.h b/include/rok4/utils/StoragePool.h new file mode 100644 index 00000000..ce3fb524 --- /dev/null +++ b/include/rok4/utils/StoragePool.h @@ -0,0 +1,131 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +#pragma once + +#include "rok4/storage/Context.h" + +/** + * \author Institut national de l'information géographique et forestière + * \~french + * \brief Création d'un pool de contextes de stockage + * \details Cette classe est prévue pour être utilisée sans instance + */ +class StoragePool { + +private: + + /** + * \~french + * \brief Constructeur + * \~english + * \brief Constructeur + */ + StoragePool(); + + /** + * \~french \brief Annuaire de contextes + * \details La clé est une paire composée du type de stockage et du contenant du contexte + * \~english \brief Book of contexts + * \details Key is a pair composed of type of storage and the context's bucket + */ + static std::map,Context*> pool; + + +public: + + + /** + * \~french \brief Retourne une chaîne de caracère décrivant l'annuaire + * \~english \brief Return a string describing the pool + */ + static std::string to_string(); + + /** + * \~french + * \brief Récupère un contexte de stockage + * \details Si un contexte existe déjà pour ce nom de contenant, on ne crée pas de nouveau contexte et on retourne celui déjà existant. Le nouveau contexte n'est pas connecté. + * \param[in] type type de stockage pour lequel on veut créer un contexte + * \param[in] tray Nom du contenant pour lequel on veut créer un contexte + * \param[in] reference_context Contexte de stockage de référence + + * \brief Get a context storage + * \details If a context already exists for this tray's name, we don't create a new one and the existing is returned. New context is not connected. + * \param[in] type Storage Type for which context is created + * \param[in] tray Tray's name for which context is created + * \param[in] reference_context Reference storage context + + */ + static Context * get_context(ContextType::eContextType type,std::string tray, Context* reference_context = 0) ; + + + /** + * \~french \brief Retourne le nombre de contextes de stockage dans l'annuaire par type + * \param[out] file_count Nombre de contexte de stockage fichier + * \param[out] s3_count Nombre de contexte de stockage S3 + * \param[out] ceph_count Nombre de contexte de stockage Ceph + * \param[out] swift_count Nombre de contexte de stockage Swift + * \~english \brief Return the number of storage contexts in the book per type + * \param[out] file_count File storage context count + * \param[out] s3_count S3 storage context count + * \param[out] ceph_count Ceph storage context count + * \param[out] swift_count Swift storage context count + */ + static void get_storages_count (int& file_count, int& s3_count, int& ceph_count, int& swift_count); + + /** + * \~french \brief Obtient l'annuaire de contextes + * \details La clé est une paire composée du type de stockage et du contenant du contexte + * \~english \brief Get book of contexts + * \details Key is a pair composed of type of storage and the context's bucket + */ + static std::map,Context*> get_pool(); + + /** + * \~french + * \brief Destructeur + * \~english + * \brief Destructor + */ + ~StoragePool(); + + /** + * \~french \brief Nettoie tous les contextes de stockage dans l'annuaire et le vide + * \~english \brief Clean all storage context objects in the book and empty it + */ + static void clean_storages (); +}; \ No newline at end of file diff --git a/src/datasource/StoreDataSource.h b/src/datasource/StoreDataSource.h index 79e916e0..d6d44c86 100644 --- a/src/datasource/StoreDataSource.h +++ b/src/datasource/StoreDataSource.h @@ -54,6 +54,7 @@ #include "datasource/DataSource.h" #include "storage/Context.h" +#include "rok4/utils/StoragePool.h" /** * \author Institut national de l'information géographique et forestière diff --git a/src/style/Style.cpp b/src/style/Style.cpp index fd2c65c2..4962dc81 100644 --- a/src/style/Style.cpp +++ b/src/style/Style.cpp @@ -50,7 +50,6 @@ #include #include #include -#include "utils/Cache.h" #include "storage/Context.h" diff --git a/src/utils/StoragePool.cpp b/src/utils/StoragePool.cpp new file mode 100644 index 00000000..c2fc3ce7 --- /dev/null +++ b/src/utils/StoragePool.cpp @@ -0,0 +1,114 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + + /** + * \file StoragePool.cpp + ** \~french + * \brief Implémentation de la classe StoragePool + ** \~english + * \brief Implements classe StoragePool + */ + +#include "utils/StoragePool.h" + +StoragePool::StoragePool(){ + +} + +std::string StoragePool::to_string() { + std::ostringstream oss; + oss.setf ( std::ios::fixed,std::ios::floatfield ); + oss << "------ Context pool -------" << std::endl; + oss << "\t- context number = " << pool.size() << std::endl; + + std::map, Context*>::iterator it = pool.begin(); + while (it != pool.end()) { + std::pair key = it->first; + oss << "\t\t- pot = " << key.first << "/" << key.second << std::endl; + oss << it->second->to_string() << std::endl; + it++; + } + + return oss.str() ; + } + + + +void StoragePool::get_storages_count (int& file_count, int& s3_count, int& ceph_count, int& swift_count) { + file_count = 0; + s3_count = 0; + ceph_count = 0; + swift_count = 0; + std::map, Context*>::iterator it = pool.begin(); + while (it != pool.end()) { + std::pair key = it->first; + switch(key.first) { + #if CEPH_ENABLED + case ContextType::CEPHCONTEXT: + ceph_count++; + break; + #endif + case ContextType::SWIFTCONTEXT: + swift_count++; + break; + case ContextType::S3CONTEXT: + s3_count++; + break; + case ContextType::FILECONTEXT: + file_count++; + break; + } + it++; + } + } + +std::map,Context*> StoragePool::get_pool() { + return pool; + } + +StoragePool::~StoragePool(){ + +} + + +void StoragePool::clean_storages () { + std::map,Context*>::iterator it; + for (it=pool.begin(); it!=pool.end(); ++it) { + delete it->second; + it->second = NULL; + } +} \ No newline at end of file From 1e53d5d95725dd9ac5076759ff643d294ea5fb53 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 7 Oct 2025 11:13:56 +0200 Subject: [PATCH 05/15] Export de la classe IndexCache --- include/rok4/utils/Cache.h | 203 -------------------------------- include/rok4/utils/IndexCache.h | 182 ++++++++++++++++++++++++++++ src/utils/IndexCache.cpp | 149 +++++++++++++++++++++++ 3 files changed, 331 insertions(+), 203 deletions(-) create mode 100644 include/rok4/utils/IndexCache.h create mode 100644 src/utils/IndexCache.cpp diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h index c6fec8b3..5dcb289d 100644 --- a/include/rok4/utils/Cache.h +++ b/include/rok4/utils/Cache.h @@ -141,209 +141,6 @@ friend class IndexCache; }; }; -/** - * \author Institut national de l'information géographique et forestière - * \~french - * \brief Création d'un cache des index de dalle - * \details Cette classe est prévue pour être utilisée sans instance - */ -class IndexCache { - -private: - - /** - * \~french \brief Liste des éléments en cache - * \~english \brief Cache elements list - */ - static std::list cache; - /** - * \~french \brief Map d'index des éléments du cache - * \~english \brief Cache element index map - */ - static std::unordered_map::iterator> map; - /** - * \~french \brief Taille du cache en nombre d'élément - * \details 100 par défaut - * \~english \brief Cache size - * \details Default value : 100 - */ - static int size; - /** - * \~french \brief Durée de validité en seconde d'un élément du cache - * \details 300 par défaut (5 minutes) - * \~english \brief Cache element's validity period, in seconds - * \details Default value : 300 (5 minutes) - */ - static int validity; - - /** - * \~french \brief Exclusion mutuelle - * \details Pour éviter les modifications concurrentes du cache des index - * \~english \brief Mutual exclusion - * \details To avoid concurrent index cache updates - */ - static std::mutex mtx; - - /** - * \~french - * \brief Constructeur - * \~english - * \brief Constructeur - */ - IndexCache(){}; - -public: - - /** - * \~french - * \brief Destructeur - * \~english - * \brief Destructor - */ - ~IndexCache(){}; - - /** \~french - * \brief Définit la taille du cache - * \param[in] s taille du cache - ** \~english - * \brief Define cache size - * \param[in] s cache size - */ - static void setCacheSize(int s) { - size = s; - }; - - /** \~french - * \brief Définit la durée de validité - * \param[in] s durée de validité du cache, en secondes - ** \~english - * \brief Define cache validity - * \param[in] s cache validity, in seconds - */ - static void set_validity(int v) { - validity = v; - }; - - /** \~french - * \brief Ajoute un élément au cache - * \param[in] origin_slab_name nom d'interrogation de la dalle - * \param[in] data_context contexte de stockage de la dalle de donnée - * \param[in] data_slab_name nom de la dalle réelle contenant les données - * \param[in] tiles_number nombre de tuiles dans la dalles - * \param[in] os offsets bruts des tuiles - * \param[in] ss tailles brutes des tuiles - ** \~english - * \brief Add element to cache - * \param[in] origin_slab_name Slab request name - * \param[in] data_context data slab storage context - * \param[in] data_slab_name data slab name - * \param[in] tiles_number tiles number - * \param[in] os raw tiles' offsets - * \param[in] ss raw tiles' sizes - */ - static void add_slab_infos(std::string origin_slab_name, Context* data_context, std::string data_slab_name, int tiles_number, uint8_t* offsets, uint8_t* sizes) { - // On utilise le nom original de la dalle (celle à lire a priori) comme clé dans la map - // Potentiellement ce nom est différent de la vraie dalle contenant la donnée (dans le cas d'une dalle symbolique) - // mais c'est via cette dalle symbolique que la donnée est a priori requêtée - // donc c'est ce nom qu'on utilisera pour l'interrogation du cache - - mtx.lock(); - - IndexElement* elem = new IndexElement(origin_slab_name, data_context, data_slab_name, tiles_number, offsets, sizes); - - // L'information n'est a priori pas dans le cache car - // Soit elle était dans le cache et valide, alors on aurait utilisé ce cache et on n'aurait pas fait appel à cet ajout - // Soit elle était dans le cache mais obsolète, alors on l'aurait déjà supprimé du cache - - if (cache.size() == size) { - // On récupère le dernier élément du cache - IndexElement* last = cache.back(); - // On le vire du cache - cache.pop_back(); - // On le déréférence de la map d'accès - map.erase(last->key); - delete last; - } - - // update reference - cache.push_front(elem); - map[origin_slab_name] = cache.begin(); - - mtx.unlock(); - }; - - /** \~french - * \brief Demande un élément du cache - * \param[in] key nom d'interrogation de la dalle - * \param[in] tile_number numéro de la tuile voulue - * \param[out] data_context contexte de stockage de la dalle de donnée - * \param[out] data_slab_name nom de la dalle contenant les données - * \param[out] offset offset de la tuile - * \param[out] size taille de la tuile - ** \~english - * \brief Ask element from cache - * \param[in] key Slab request name - * \param[in] tile_number tile indice - * \param[out] data_context data slab storage context - * \param[out] data_slab_name Real data slab - * \param[out] offset tile's offset - * \param[out] size tile's size - */ - static bool get_slab_infos(std::string key, int tile_number, Context** data_context, std::string* data_slab_name, uint32_t* offset, uint32_t* size) { - std::unordered_map::iterator>::iterator it = map.find ( key ); - if ( it == map.end() ) { - return false; - } else { - // Gestion de la péremption du cache (une heure max) - std::time_t now = std::time(NULL); - if (now - (*(it->second))->date > validity) { - mtx.lock(); - - // on le cherche à nouveau pour vérifier qu'il n'a pas déjà été supprimé par un thread concurrent - it = map.find ( key ); - - if ( it != map.end() ) { - delete *(it->second); - cache.erase(it->second); - map.erase(it); - } - - mtx.unlock(); - - return false; - } - - *data_slab_name = (*(it->second))->name; - *data_context = (*(it->second))->context; - *offset = (*(it->second))->offsets.at(tile_number); - *size = (*(it->second))->sizes.at(tile_number); - - // On fait le choix de ne pas remettre en tête du cache cet élément, même s'il vient d'être accéder - // C'est parce qu'en plus d'avoir une taille limite, les élément cachés ont une date de péromption - // Il serait donc dommage de remettre en avant (donc plus loin d'une suppression par taille de cache atteinte) - // un élément qui va de toute manière finir par être obsolète. - // C'est une différence avec une cache LRU classique - - return true; - } - }; - - /** - * \~french \brief Nettoie tous les objets dans le cache - * \~english \brief Clean all element from the cache - */ - static void clean_indexes () { - mtx.lock(); - std::list::iterator it; - for (it = cache.begin(); it != cache.end(); ++it) { - delete *it; - } - cache.clear(); - mtx.unlock(); - } -}; - - /** * \author Institut national de l'information géographique et forestière * \~french diff --git a/include/rok4/utils/IndexCache.h b/include/rok4/utils/IndexCache.h new file mode 100644 index 00000000..54b3d6ae --- /dev/null +++ b/include/rok4/utils/IndexCache.h @@ -0,0 +1,182 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file IndexCache.h + ** \~french + * \brief Définition de la classes IndexCache + ** \~english + * \brief Define classe IndexCache + */ + +#pragma once + +#include // pour uint8_t +#include +#include +#include +#include +#include +#include +#include + +#include "rok4/utils/Cache.h" +#include "rok4/storage/Context.h" + +/** + * \author Institut national de l'information géographique et forestière + * \~french + * \brief Création d'un cache des index de dalle + * \details Cette classe est prévue pour être utilisée sans instance + */ +class IndexCache { + +private: + + /** + * \~french \brief Liste des éléments en cache + * \~english \brief Cache elements list + */ + static std::list cache; + /** + * \~french \brief Map d'index des éléments du cache + * \~english \brief Cache element index map + */ + static std::unordered_map::iterator> map; + /** + * \~french \brief Taille du cache en nombre d'élément + * \details 100 par défaut + * \~english \brief Cache size + * \details Default value : 100 + */ + static int size; + /** + * \~french \brief Durée de validité en seconde d'un élément du cache + * \details 300 par défaut (5 minutes) + * \~english \brief Cache element's validity period, in seconds + * \details Default value : 300 (5 minutes) + */ + static int validity; + + /** + * \~french \brief Exclusion mutuelle + * \details Pour éviter les modifications concurrentes du cache des index + * \~english \brief Mutual exclusion + * \details To avoid concurrent index cache updates + */ + static std::mutex mtx; + + /** + * \~french + * \brief Constructeur + * \~english + * \brief Constructeur + */ + IndexCache(); + +public: + + /** + * \~french + * \brief Destructeur + * \~english + * \brief Destructor + */ + ~IndexCache(); + + /** \~french + * \brief Définit la taille du cache + * \param[in] s taille du cache + ** \~english + * \brief Define cache size + * \param[in] s cache size + */ + static void setCacheSize(int s); + + /** \~french + * \brief Définit la durée de validité + * \param[in] s durée de validité du cache, en secondes + ** \~english + * \brief Define cache validity + * \param[in] s cache validity, in seconds + */ + static void set_validity(int v); + + /** \~french + * \brief Ajoute un élément au cache + * \param[in] origin_slab_name nom d'interrogation de la dalle + * \param[in] data_context contexte de stockage de la dalle de donnée + * \param[in] data_slab_name nom de la dalle réelle contenant les données + * \param[in] tiles_number nombre de tuiles dans la dalles + * \param[in] os offsets bruts des tuiles + * \param[in] ss tailles brutes des tuiles + ** \~english + * \brief Add element to cache + * \param[in] origin_slab_name Slab request name + * \param[in] data_context data slab storage context + * \param[in] data_slab_name data slab name + * \param[in] tiles_number tiles number + * \param[in] os raw tiles' offsets + * \param[in] ss raw tiles' sizes + */ + static void add_slab_infos(std::string origin_slab_name, Context* data_context, std::string data_slab_name, int tiles_number, uint8_t* offsets, uint8_t* sizes); + + /** \~french + * \brief Demande un élément du cache + * \param[in] key nom d'interrogation de la dalle + * \param[in] tile_number numéro de la tuile voulue + * \param[out] data_context contexte de stockage de la dalle de donnée + * \param[out] data_slab_name nom de la dalle contenant les données + * \param[out] offset offset de la tuile + * \param[out] size taille de la tuile + ** \~english + * \brief Ask element from cache + * \param[in] key Slab request name + * \param[in] tile_number tile indice + * \param[out] data_context data slab storage context + * \param[out] data_slab_name Real data slab + * \param[out] offset tile's offset + * \param[out] size tile's size + */ + static bool get_slab_infos(std::string key, int tile_number, Context** data_context, std::string* data_slab_name, uint32_t* offset, uint32_t* size); + + /** + * \~french \brief Nettoie tous les objets dans le cache + * \~english \brief Clean all element from the cache + */ + static void clean_indexes (); +}; \ No newline at end of file diff --git a/src/utils/IndexCache.cpp b/src/utils/IndexCache.cpp new file mode 100644 index 00000000..0019f3e0 --- /dev/null +++ b/src/utils/IndexCache.cpp @@ -0,0 +1,149 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file IndexCache.cpp + ** \~french + * \brief Implémentation de la classe IndexCache + ** \~english + * \brief Implements classe IndexCache + */ + +#include "rok4/utils/IndexCache.h" +#include "IndexCache.h" + +IndexCache::IndexCache() { + +} + +IndexCache::~IndexCache() { + +} + +void IndexCache::setCacheSize(int s) { + size = s; +} + +void IndexCache::set_validity(int v) { + validity = v; +} + +void IndexCache::add_slab_infos(std::string origin_slab_name, Context *data_context, std::string data_slab_name, int tiles_number, uint8_t *offsets, uint8_t *sizes) { + // On utilise le nom original de la dalle (celle à lire a priori) comme clé dans la map + // Potentiellement ce nom est différent de la vraie dalle contenant la donnée (dans le cas d'une dalle symbolique) + // mais c'est via cette dalle symbolique que la donnée est a priori requêtée + // donc c'est ce nom qu'on utilisera pour l'interrogation du cache + + mtx.lock(); + + IndexElement *elem = new IndexElement(origin_slab_name, data_context, data_slab_name, tiles_number, offsets, sizes); + + // L'information n'est a priori pas dans le cache car + // Soit elle était dans le cache et valide, alors on aurait utilisé ce cache et on n'aurait pas fait appel à cet ajout + // Soit elle était dans le cache mais obsolète, alors on l'aurait déjà supprimé du cache + + if (cache.size() == size) + { + // On récupère le dernier élément du cache + IndexElement *last = cache.back(); + // On le vire du cache + cache.pop_back(); + // On le déréférence de la map d'accès + map.erase(last->key); + delete last; + } + + // update reference + cache.push_front(elem); + map[origin_slab_name] = cache.begin(); + + mtx.unlock(); +} + +bool IndexCache::get_slab_infos(std::string key, int tile_number, Context **data_context, std::string *data_slab_name, uint32_t *offset, uint32_t *size) { + std::unordered_map::iterator>::iterator it = map.find(key); + if (it == map.end()) + { + return false; + } + else + { + // Gestion de la péremption du cache (une heure max) + std::time_t now = std::time(NULL); + if (now - (*(it->second))->date > validity) + { + mtx.lock(); + + // on le cherche à nouveau pour vérifier qu'il n'a pas déjà été supprimé par un thread concurrent + it = map.find(key); + + if (it != map.end()) + { + delete *(it->second); + cache.erase(it->second); + map.erase(it); + } + + mtx.unlock(); + + return false; + } + + *data_slab_name = (*(it->second))->name; + *data_context = (*(it->second))->context; + *offset = (*(it->second))->offsets.at(tile_number); + *size = (*(it->second))->sizes.at(tile_number); + + // On fait le choix de ne pas remettre en tête du cache cet élément, même s'il vient d'être accéder + // C'est parce qu'en plus d'avoir une taille limite, les élément cachés ont une date de péromption + // Il serait donc dommage de remettre en avant (donc plus loin d'une suppression par taille de cache atteinte) + // un élément qui va de toute manière finir par être obsolète. + // C'est une différence avec une cache LRU classique + + return true; + } +} + +void IndexCache::clean_indexes() { + mtx.lock(); + std::list::iterator it; + for (it = cache.begin(); it != cache.end(); ++it) { + delete *it; + } + cache.clear(); + mtx.unlock(); +} From c4a186a92b43bd071353da8405c099d6a0197279 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 7 Oct 2025 14:31:47 +0200 Subject: [PATCH 06/15] Export de la classe IndexElement en dehors de Cache et adaptation au niveau de IndexCache --- include/rok4/utils/Cache.h | 71 +------------------ include/rok4/utils/IndexCache.h | 2 +- include/rok4/utils/IndexElement.h | 112 ++++++++++++++++++++++++++++++ src/datasource/StoreDataSource.h | 1 + src/utils/IndexCache.cpp | 1 - src/utils/IndexElement.cpp | 57 +++++++++++++++ 6 files changed, 172 insertions(+), 72 deletions(-) create mode 100644 include/rok4/utils/IndexElement.h create mode 100644 src/utils/IndexElement.cpp diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h index 5dcb289d..c3c61c81 100644 --- a/include/rok4/utils/Cache.h +++ b/include/rok4/utils/Cache.h @@ -63,6 +63,7 @@ #include "rok4/style/Style.h" #include "rok4/utils/Utils.h" #include "rok4/utils/CRS.h" +#include "rok4/utils/IndexCache.h" #include "rok4/storage/Context.h" @@ -71,76 +72,6 @@ #define ROK4_STYLES_DIRECTORY "ROK4_STYLES_DIRECTORY" #define ROK4_STYLES_NO_CACHE "ROK4_STYLES_NO_CACHE" - -/** - * \author Institut national de l'information géographique et forestière - * \~french - * \brief Élément du cache des index de dalle - */ -class IndexElement { -friend class IndexCache; - -protected: - /** - * \~french \brief Date d'enregistrement dans le cache - * \~english \brief Cache date - */ - std::time_t date; - /** - * \~french \brief Clé sous laquelle l'élément est enregistré dans le cache - * \~english \brief Cache key - */ - std::string key; - /** - * \~french \brief Nom de la dalle dans laquelle lire la donnée - * \~english \brief Data slab to read - */ - std::string name; - /** - * \~french \brief Contexte de stockage de la dalle de donnée - * \~english \brief Data slab storage context - */ - Context* context; - /** - * \~french \brief Offsets des tuiles dans la dalle - * \~english \brief Tiles' offsets - */ - std::vector offsets; - /** - * \~french \brief Tailles des tuiles dans la dalle - * \~english \brief Tiles' sizes - */ - std::vector sizes; - - /** \~french - * \brief Constructeur - * \param[in] k clé d'enregistrement dans le cache - * \param[in] s nom de la dalle - * \param[in] c contexte de stockage de la dalle - * \param[in] tiles_number nombre de tuiles dans la dalles - * \param[in] os offsets bruts des tuiles - * \param[in] ss tailles brutes des tuiles - ** \~english - * \brief Constructor - * \param[in] k cache key - * \param[in] s data slab name - * \param[in] c data slab storage context - * \param[in] tiles_number tiles number - * \param[in] os raw tiles' offsets - * \param[in] ss raw tiles' sizes - */ - IndexElement(std::string k, Context* c, std::string n, int tiles_number, uint8_t* os, uint8_t* ss) { - key = k; - context = c; - name = n; - date = std::time(NULL); - for (int i = 0; i < tiles_number; i++) { - offsets.push_back(*((uint32_t*) (os + i*4))); - sizes.push_back(*((uint32_t*) (ss + i*4))); - } - }; -}; - /** * \author Institut national de l'information géographique et forestière * \~french diff --git a/include/rok4/utils/IndexCache.h b/include/rok4/utils/IndexCache.h index 54b3d6ae..37080b9f 100644 --- a/include/rok4/utils/IndexCache.h +++ b/include/rok4/utils/IndexCache.h @@ -54,7 +54,7 @@ #include #include -#include "rok4/utils/Cache.h" +#include "rok4/utils/IndexElement.h" #include "rok4/storage/Context.h" /** diff --git a/include/rok4/utils/IndexElement.h b/include/rok4/utils/IndexElement.h new file mode 100644 index 00000000..591619cb --- /dev/null +++ b/include/rok4/utils/IndexElement.h @@ -0,0 +1,112 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file IndexElement.h + ** \~french + * \brief Définition de la classe IndexElement + ** \~english + * \brief Define classe IndexElement + */ + +#pragma once + +#include +#include +#include + +#include "rok4/storage/Context.h" + +/** + * \author Institut national de l'information géographique et forestière + * \~french + * \brief Élément du cache des index de dalle + */ +class IndexElement { +friend class IndexCache; + +protected: + /** + * \~french \brief Date d'enregistrement dans le cache + * \~english \brief Cache date + */ + std::time_t date; + /** + * \~french \brief Clé sous laquelle l'élément est enregistré dans le cache + * \~english \brief Cache key + */ + std::string key; + /** + * \~french \brief Nom de la dalle dans laquelle lire la donnée + * \~english \brief Data slab to read + */ + std::string name; + /** + * \~french \brief Contexte de stockage de la dalle de donnée + * \~english \brief Data slab storage context + */ + Context* context; + /** + * \~french \brief Offsets des tuiles dans la dalle + * \~english \brief Tiles' offsets + */ + std::vector offsets; + /** + * \~french \brief Tailles des tuiles dans la dalle + * \~english \brief Tiles' sizes + */ + std::vector sizes; + + /** \~french + * \brief Constructeur + * \param[in] k clé d'enregistrement dans le cache + * \param[in] s nom de la dalle + * \param[in] c contexte de stockage de la dalle + * \param[in] tiles_number nombre de tuiles dans la dalles + * \param[in] os offsets bruts des tuiles + * \param[in] ss tailles brutes des tuiles + ** \~english + * \brief Constructor + * \param[in] k cache key + * \param[in] s data slab name + * \param[in] c data slab storage context + * \param[in] tiles_number tiles number + * \param[in] os raw tiles' offsets + * \param[in] ss raw tiles' sizes + */ + IndexElement(std::string k, Context* c, std::string n, int tiles_number, uint8_t* os, uint8_t* ss); +}; \ No newline at end of file diff --git a/src/datasource/StoreDataSource.h b/src/datasource/StoreDataSource.h index d6d44c86..0421fc9e 100644 --- a/src/datasource/StoreDataSource.h +++ b/src/datasource/StoreDataSource.h @@ -55,6 +55,7 @@ #include "datasource/DataSource.h" #include "storage/Context.h" #include "rok4/utils/StoragePool.h" +#include "rok4/utils/IndexCache.h" /** * \author Institut national de l'information géographique et forestière diff --git a/src/utils/IndexCache.cpp b/src/utils/IndexCache.cpp index 0019f3e0..cef722dc 100644 --- a/src/utils/IndexCache.cpp +++ b/src/utils/IndexCache.cpp @@ -44,7 +44,6 @@ */ #include "rok4/utils/IndexCache.h" -#include "IndexCache.h" IndexCache::IndexCache() { diff --git a/src/utils/IndexElement.cpp b/src/utils/IndexElement.cpp new file mode 100644 index 00000000..ab09b029 --- /dev/null +++ b/src/utils/IndexElement.cpp @@ -0,0 +1,57 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file IndexElement.cpp + ** \~french + * \brief Implémentation de la classe IndexElement + ** \~english + * \brief Implements classe IndexElement + */ + +#include "rok4/utils/IndexElement.h" + +IndexElement::IndexElement(std::string k, Context *c, std::string n, int tiles_number, uint8_t *os, uint8_t *ss) { + key = k; + context = c; + name = n; + date = std::time(NULL); + for (int i = 0; i < tiles_number; i++) { + offsets.push_back(*((uint32_t*) (os + i*4))); + sizes.push_back(*((uint32_t*) (ss + i*4))); + } +} \ No newline at end of file From a5e63643e252be45c9e9193f0d2c37ae09d45f7d Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 7 Oct 2025 15:08:13 +0200 Subject: [PATCH 07/15] =?UTF-8?q?Export=20de=20TmsBook=20hors=20de=20Cache?= =?UTF-8?q?=20et=20changement=20du=20=C3=A0=20l'impact=20de=20ce=20changem?= =?UTF-8?q?ent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/utils/Cache.h | 178 +---------------------------------- include/rok4/utils/Pyramid.h | 2 +- include/rok4/utils/TmsBook.h | 162 +++++++++++++++++++++++++++++++ src/utils/TmsBook.cpp | 134 ++++++++++++++++++++++++++ 4 files changed, 298 insertions(+), 178 deletions(-) create mode 100644 include/rok4/utils/TmsBook.h create mode 100644 src/utils/TmsBook.cpp diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h index c3c61c81..3cc3f964 100644 --- a/include/rok4/utils/Cache.h +++ b/include/rok4/utils/Cache.h @@ -63,6 +63,7 @@ #include "rok4/style/Style.h" #include "rok4/utils/Utils.h" #include "rok4/utils/CRS.h" +#include "rok4/utils/TmsBook.h" #include "rok4/utils/IndexCache.h" #include "rok4/storage/Context.h" @@ -72,183 +73,6 @@ #define ROK4_STYLES_DIRECTORY "ROK4_STYLES_DIRECTORY" #define ROK4_STYLES_NO_CACHE "ROK4_STYLES_NO_CACHE" -/** - * \author Institut national de l'information géographique et forestière - * \~french - * \brief Création d'un annuaire de Tile Matrix Sets - * \details Cette classe est prévue pour être utilisée sans instance - */ -class TmsBook { - -private: - - /** - * \~french - * \brief Constructeur - * \~english - * \brief Constructeur - */ - TmsBook(){}; - - /** - * \~french - * \brief Répertoire de stockage des TMS - * \~english - * \brief TMS storage directory - */ - static std::string directory; - - /** - * \~french \brief Annuaire de TMS - * \details La clé est l'identifiant du TMS - * \~english \brief Book of TMS - * \details Key is a the TMS identifier - */ - static std::map book; - - /** - * \~french \brief Corbeille de TMS à supprimer - * \~english \brief TMS trash to delete - */ - static std::vector trash; - - /** - * \~french \brief Exclusion mutuelle - * \details Pour éviter les modifications concurrentes du cache de TMS - * \~english \brief Mutual exclusion - * \details To avoid concurrent TMS cache updates - */ - static std::mutex mtx; - -public: - - - /** - * \~french \brief Vide l'annuaire et met le contenu à la corbeille - * \~english \brief Empty book and put content into trash - */ - static void send_to_trash () { - mtx.lock(); - std::map::iterator it; - for (it = book.begin(); it != book.end(); ++it) { - trash.push_back(it->second); - } - book.clear(); - mtx.unlock(); - } - - /** - * \~french \brief Vide la corbeille - * \~english \brief Empty trash - */ - static void empty_trash () { - mtx.lock(); - for (int i = 0; i < trash.size(); i++) { - delete trash.at(i); - } - trash.clear(); - mtx.unlock(); - } - - - /** - * \~french \brief Renseigne le répertoire des TMS - * \~english \brief Set TMS directory - */ - static void set_directory (std::string d) { - // Suppression du slash final - if (d.compare ( d.size()-1,1,"/" ) == 0) { - d.pop_back(); - } - directory = d; - } - - /** - * \~french \brief Retourne l'ensemble de l'annuaire - * \~english \brief Return the book - */ - static std::map get_book () { - return book; - } - - /** - * \~french - * \brief Retourne le TMS d'après son identifiant - * \details Si le TMS demandé n'est pas encore dans l'annuaire, ou que l'on ne veut pas de cache, il est recherché dans le répertoire connu et chargé - * \param[in] id Identifiant du TMS voulu - - * \brief Return the TMS according to its identifier - * \details If TMS is still not in the book, or cache is disabled, it is searched in the known directory and loaded - * \param[in] id Wanted TMS identifier - */ - static TileMatrixSet* get_tms(std::string id) { - std::map::iterator it = book.find ( id ); - if ( it != book.end() ) { - return it->second; - } - - std::string d; - if (directory.empty()) { - char* e = getenv (ROK4_TMS_DIRECTORY); - if (e == NULL) { - d.assign("/usr/share/rok4/tilematrixsets"); - } else { - d.assign(e); - } - } else { - d = directory; - } - - std::string tms_path = d + "/" + id; - - mtx.lock(); - // Si on fait du cache de TMS, on revérifie que ce TMS n'a pas déjà été ajouté par un thread concurrent entre temps - if(getenv (ROK4_TMS_NO_CACHE) == NULL) { - if ( it != book.end() ) { - // On a effectivement depuis déjà enregistré ce TMS - return it->second; - } - } - - TileMatrixSet* tms = new TileMatrixSet(tms_path); - if ( ! tms->is_ok() ) { - BOOST_LOG_TRIVIAL(error) << tms->get_error_message(); - delete tms; - mtx.unlock(); - return NULL; - } - - if(getenv (ROK4_TMS_NO_CACHE) == NULL) { - // On veut utiliser le cache, on met donc ce nouveau TMS dans l'annuaire pour le trouver la prochaine fois - book.insert ( std::pair(id, tms) ); - } else { - // On met le TMS directement dans la corbeille, pour que le nettoyage se fasse bien - trash.push_back(tms); - } - - mtx.unlock(); - - return tms; - } - - /** - * \~french \brief Retourne le nombre de TMS dans l'annuaire - * \~english \brief Return the number of TMS in the book - */ - static int get_tms_count () { - return book.size(); - } - - /** - * \~french - * \brief Destructeur - * \~english - * \brief Destructor - */ - ~TmsBook() {}; - -}; - /** * \author Institut national de l'information géographique et forestière diff --git a/include/rok4/utils/Pyramid.h b/include/rok4/utils/Pyramid.h index 42149baa..ea05370f 100644 --- a/include/rok4/utils/Pyramid.h +++ b/include/rok4/utils/Pyramid.h @@ -49,7 +49,7 @@ class Pyramid; #include "rok4/style/Style.h" #include "rok4/enums/Interpolation.h" #include "rok4/utils/Configuration.h" -#include "rok4/utils/Cache.h" +#include "rok4/utils/TmsBook.h" #include "rok4/storage/Context.h" #define DEFAULT_NODATAVALUE 255 diff --git a/include/rok4/utils/TmsBook.h b/include/rok4/utils/TmsBook.h new file mode 100644 index 00000000..257ce57c --- /dev/null +++ b/include/rok4/utils/TmsBook.h @@ -0,0 +1,162 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file TmsBook.h + ** \~french + * \brief Définition de la classe TmsBook + ** \~english + * \brief Define classe TmsBook + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "rok4/utils/TileMatrixSet.h" + +#define ROK4_TMS_DIRECTORY "ROK4_TMS_DIRECTORY" +#define ROK4_TMS_NO_CACHE "ROK4_TMS_NO_CACHE" + +/** + * \author Institut national de l'information géographique et forestière + * \~french + * \brief Création d'un annuaire de Tile Matrix Sets + * \details Cette classe est prévue pour être utilisée sans instance + */ +class TmsBook { + +private: + + /** + * \~french + * \brief Constructeur + * \~english + * \brief Constructeur + */ + TmsBook(); + + /** + * \~french + * \brief Répertoire de stockage des TMS + * \~english + * \brief TMS storage directory + */ + static std::string directory; + + /** + * \~french \brief Annuaire de TMS + * \details La clé est l'identifiant du TMS + * \~english \brief Book of TMS + * \details Key is a the TMS identifier + */ + static std::map book; + + /** + * \~french \brief Corbeille de TMS à supprimer + * \~english \brief TMS trash to delete + */ + static std::vector trash; + + /** + * \~french \brief Exclusion mutuelle + * \details Pour éviter les modifications concurrentes du cache de TMS + * \~english \brief Mutual exclusion + * \details To avoid concurrent TMS cache updates + */ + static std::mutex mtx; + +public: + + + /** + * \~french \brief Vide l'annuaire et met le contenu à la corbeille + * \~english \brief Empty book and put content into trash + */ + static void send_to_trash (); + + /** + * \~french \brief Vide la corbeille + * \~english \brief Empty trash + */ + static void empty_trash (); + + + /** + * \~french \brief Renseigne le répertoire des TMS + * \~english \brief Set TMS directory + */ + static void set_directory (std::string d); + + /** + * \~french \brief Retourne l'ensemble de l'annuaire + * \~english \brief Return the book + */ + static std::map get_book (); + + /** + * \~french + * \brief Retourne le TMS d'après son identifiant + * \details Si le TMS demandé n'est pas encore dans l'annuaire, ou que l'on ne veut pas de cache, il est recherché dans le répertoire connu et chargé + * \param[in] id Identifiant du TMS voulu + + * \brief Return the TMS according to its identifier + * \details If TMS is still not in the book, or cache is disabled, it is searched in the known directory and loaded + * \param[in] id Wanted TMS identifier + */ + static TileMatrixSet* get_tms(std::string id); + + /** + * \~french \brief Retourne le nombre de TMS dans l'annuaire + * \~english \brief Return the number of TMS in the book + */ + static int get_tms_count (); + + /** + * \~french + * \brief Destructeur + * \~english + * \brief Destructor + */ + ~TmsBook(); + +}; \ No newline at end of file diff --git a/src/utils/TmsBook.cpp b/src/utils/TmsBook.cpp new file mode 100644 index 00000000..1159558f --- /dev/null +++ b/src/utils/TmsBook.cpp @@ -0,0 +1,134 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file TmsBook.cpp + ** \~french + * \brief Implémentation de la classe TmsBook + ** \~english + * \brief Implements classe TmsBook + */ + + +#include "rok4/utils/TmsBook.h" + +TmsBook::TmsBook(){ + +} + +void TmsBook::send_to_trash() { + mtx.lock(); + std::map::iterator it; + for (it = book.begin(); it != book.end(); ++it) { + trash.push_back(it->second); + } + book.clear(); + mtx.unlock(); +} + +void TmsBook::empty_trash() { + mtx.lock(); + for (int i = 0; i < trash.size(); i++) { + delete trash.at(i); + } + trash.clear(); + mtx.unlock(); +} + +void TmsBook::set_directory(std::string d) { + // Suppression du slash final + if (d.compare ( d.size()-1,1,"/" ) == 0) { + d.pop_back(); + } + directory = d; +} + +std::map TmsBook::get_book() { + return book; +} + +TileMatrixSet *TmsBook::get_tms(std::string id) { + std::map::iterator it = book.find ( id ); + if ( it != book.end() ) { + return it->second; + } + std::string d; + if (directory.empty()) { + char* e = getenv (ROK4_TMS_DIRECTORY); + if (e == NULL) { + d.assign("/usr/share/rok4/tilematrixsets"); + } else { + d.assign(e); + } + } else { + d = directory; + } + std::string tms_path = d + "/" + id; + mtx.lock(); + // Si on fait du cache de TMS, on revérifie que ce TMS n'a pas déjà été ajouté par un thread concurrent entre temps + if(getenv (ROK4_TMS_NO_CACHE) == NULL) { + if ( it != book.end() ) { + // On a effectivement depuis déjà enregistré ce TMS + return it->second; + } + } + TileMatrixSet* tms = new TileMatrixSet(tms_path); + if ( ! tms->is_ok() ) { + BOOST_LOG_TRIVIAL(error) << tms->get_error_message(); + delete tms; + mtx.unlock(); + return NULL; + } + if(getenv (ROK4_TMS_NO_CACHE) == NULL) { + // On veut utiliser le cache, on met donc ce nouveau TMS dans l'annuaire pour le trouver la prochaine fois + book.insert ( std::pair(id, tms) ); + } else { + // On met le TMS directement dans la corbeille, pour que le nettoyage se fasse bien + trash.push_back(tms); + } + + mtx.unlock(); + return tms; +} + +int TmsBook::get_tms_count() { + return book.size(); +} + +TmsBook::~TmsBook(){ + +} \ No newline at end of file From d72a4a368a31a59dd13d03287521a9bc05c6b8e1 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 7 Oct 2025 15:21:31 +0200 Subject: [PATCH 08/15] Export de StyleBook hors de Cache --- include/rok4/utils/Cache.h | 187 +-------------------------------- include/rok4/utils/StyleBook.h | 164 +++++++++++++++++++++++++++++ src/utils/StyleBook.cpp | 139 ++++++++++++++++++++++++ 3 files changed, 304 insertions(+), 186 deletions(-) create mode 100644 include/rok4/utils/StyleBook.h create mode 100644 src/utils/StyleBook.cpp diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h index 3cc3f964..9cb3a584 100644 --- a/include/rok4/utils/Cache.h +++ b/include/rok4/utils/Cache.h @@ -64,6 +64,7 @@ #include "rok4/utils/Utils.h" #include "rok4/utils/CRS.h" #include "rok4/utils/TmsBook.h" +#include "rok4/utils/StyleBook.h" #include "rok4/utils/IndexCache.h" #include "rok4/storage/Context.h" @@ -73,192 +74,6 @@ #define ROK4_STYLES_DIRECTORY "ROK4_STYLES_DIRECTORY" #define ROK4_STYLES_NO_CACHE "ROK4_STYLES_NO_CACHE" - -/** - * \author Institut national de l'information géographique et forestière - * \~french - * \brief Création d'un annuaire de styles - * \details Cette classe est prévue pour être utilisée sans instance - */ -class StyleBook { - -private: - - /** - * \~french - * \brief Constructeur - * \~english - * \brief Constructeur - */ - StyleBook(){}; - - /** - * \~french - * \brief Répertoire de stockage des styles - * \~english - * \brief TMS storage directory - */ - static std::string directory; - - /** - * \~french \brief Annuaire de styles - * \details La clé est l'identifiant du style - * \~english \brief Book of styles - * \details Key is a the style identifier - */ - static std::map book; - - /** - * \~french \brief Corbeille de styles à supprimer - * \~english \brief Styles trash to delete - */ - static std::vector trash; - - /** - * \~french \brief Exclusion mutuelle - * \details Pour éviter les modifications concurrentes du cache de styles - * \~english \brief Mutual exclusion - * \details To avoid concurrent styles cache updates - */ - static std::mutex mtx; - -public: - - - /** - * \~french \brief Vide l'annuaire et met le contenu à la corbeille - * \~english \brief Empty book and put content into trash - */ - static void send_to_trash () { - mtx.lock(); - std::map::iterator it; - for (it = book.begin(); it != book.end(); ++it) { - trash.push_back(it->second); - } - book.clear(); - mtx.unlock(); - } - - /** - * \~french \brief Vide la corbeille - * \~english \brief Empty trash - */ - static void empty_trash () { - mtx.lock(); - for (int i = 0; i < trash.size(); i++) { - delete trash.at(i); - } - trash.clear(); - mtx.unlock(); - } - - - /** - * \~french \brief Renseigne le répertoire des style - * \~english \brief Set styles directory - */ - static void set_directory (std::string d) { - // Suppression du slash final - if (d.compare ( d.size()-1,1,"/" ) == 0) { - d.pop_back(); - } - directory = d; - } - - /** - * \~french \brief Retourne l'ensemble de l'annuaire - * \~english \brief Return the book - */ - static std::map get_book () { - return book; - } - - /** - * \~french - * \brief Retourne le style d'après son identifiant - * \details Si le style demandé n'est pas encore dans l'annuaire, ou que l'on ne veut pas de cache, il est recherché dans le répertoire connu et chargé - * \param[in] id Identifiant du style voulu - - * \brief Return the style according to its identifier - * \details If style is still not in the book, or cache is disabled, it is searched in the known directory and loaded - * \param[in] id Wanted style identifier - */ - static Style* get_style(std::string id) { - - std::map::iterator it = book.find ( id ); - if ( it != book.end() ) { - return it->second; - } - - std::string d; - if (directory.empty()) { - char* e = getenv (ROK4_STYLES_DIRECTORY); - if (e == NULL) { - d.assign("/usr/share/rok4/styles"); - } else { - d.assign(e); - } - } else { - d = directory; - } - - std::string style_path = d + "/" + id; - - mtx.lock(); - // Si on fait du cache de style, on revérifie que ce style n'a pas déjà été ajouté par un thread concurrent entre temps - if(getenv (ROK4_STYLES_NO_CACHE) == NULL) { - if ( it != book.end() ) { - // On a effectivement depuis déjà enregistré ce style - return it->second; - } - } - - Style* style = new Style(style_path); - if ( ! style->is_ok() ) { - BOOST_LOG_TRIVIAL(error) << style->get_error_message(); - delete style; - mtx.unlock(); - return NULL; - } - - if ( contain_chars(style->get_identifier(), "<>") ) { - BOOST_LOG_TRIVIAL(error) << "Style identifier contains forbidden chars" ; - delete style; - mtx.unlock(); - return NULL; - } - - if(getenv (ROK4_STYLES_NO_CACHE) == NULL) { - // On veut utiliser le cache, on met donc ce nouveau style dans l'annuaire pour le trouver la porchaine fois - book.insert ( std::pair(id, style) ); - } else { - // On met le style directement dans la corbeille, pour que le nettoyage se fasse bien - trash.push_back(style); - } - - mtx.unlock(); - return style; - } - - /** - * \~french \brief Retourne le nombre de styles dans l'annuaire - * \~english \brief Return the number of styles in the book - */ - static int get_styles_count () { - return book.size(); - } - - /** - * \~french - * \brief Destructeur - * \~english - * \brief Destructor - */ - ~StyleBook() {}; - -}; - - /** * \author Institut national de l'information géographique et forestière * \~french diff --git a/include/rok4/utils/StyleBook.h b/include/rok4/utils/StyleBook.h new file mode 100644 index 00000000..53e6c95a --- /dev/null +++ b/include/rok4/utils/StyleBook.h @@ -0,0 +1,164 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file StyleBook.h + ** \~french + * \brief Définition de la classe StyleBook + ** \~english + * \brief Define classe StyleBook + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "rok4/style/Style.h" +#include "rok4/utils/Utils.h" + +#define ROK4_STYLES_DIRECTORY "ROK4_STYLES_DIRECTORY" +#define ROK4_STYLES_NO_CACHE "ROK4_STYLES_NO_CACHE" + + +/** + * \author Institut national de l'information géographique et forestière + * \~french + * \brief Création d'un annuaire de styles + * \details Cette classe est prévue pour être utilisée sans instance + */ +class StyleBook { + +private: + + /** + * \~french + * \brief Constructeur + * \~english + * \brief Constructeur + */ + StyleBook(); + + /** + * \~french + * \brief Répertoire de stockage des styles + * \~english + * \brief TMS storage directory + */ + static std::string directory; + + /** + * \~french \brief Annuaire de styles + * \details La clé est l'identifiant du style + * \~english \brief Book of styles + * \details Key is a the style identifier + */ + static std::map book; + + /** + * \~french \brief Corbeille de styles à supprimer + * \~english \brief Styles trash to delete + */ + static std::vector trash; + + /** + * \~french \brief Exclusion mutuelle + * \details Pour éviter les modifications concurrentes du cache de styles + * \~english \brief Mutual exclusion + * \details To avoid concurrent styles cache updates + */ + static std::mutex mtx; + +public: + + + /** + * \~french \brief Vide l'annuaire et met le contenu à la corbeille + * \~english \brief Empty book and put content into trash + */ + static void send_to_trash (); + + /** + * \~french \brief Vide la corbeille + * \~english \brief Empty trash + */ + static void empty_trash (); + + + /** + * \~french \brief Renseigne le répertoire des style + * \~english \brief Set styles directory + */ + static void set_directory (std::string d); + + /** + * \~french \brief Retourne l'ensemble de l'annuaire + * \~english \brief Return the book + */ + static std::map get_book (); + + /** + * \~french + * \brief Retourne le style d'après son identifiant + * \details Si le style demandé n'est pas encore dans l'annuaire, ou que l'on ne veut pas de cache, il est recherché dans le répertoire connu et chargé + * \param[in] id Identifiant du style voulu + + * \brief Return the style according to its identifier + * \details If style is still not in the book, or cache is disabled, it is searched in the known directory and loaded + * \param[in] id Wanted style identifier + */ + static Style* get_style(std::string id); + + /** + * \~french \brief Retourne le nombre de styles dans l'annuaire + * \~english \brief Return the number of styles in the book + */ + static int get_styles_count (); + + /** + * \~french + * \brief Destructeur + * \~english + * \brief Destructor + */ + ~StyleBook(); + +}; \ No newline at end of file diff --git a/src/utils/StyleBook.cpp b/src/utils/StyleBook.cpp new file mode 100644 index 00000000..30c72a70 --- /dev/null +++ b/src/utils/StyleBook.cpp @@ -0,0 +1,139 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file StyleBook.cpp + ** \~french + * \brief Implémentation de la classe StyleBook + ** \~english + * \brief Implements classe StyleBook + */ + + +#include "rok4/utils/StyleBook.h" + +StyleBook::StyleBook(){ + +} + +void StyleBook::send_to_trash() { + mtx.lock(); + std::map::iterator it; + for (it = book.begin(); it != book.end(); ++it) { + trash.push_back(it->second); + } + book.clear(); + mtx.unlock(); +} + +void StyleBook::empty_trash() { + mtx.lock(); + for (int i = 0; i < trash.size(); i++) { + delete trash.at(i); + } + trash.clear(); + mtx.unlock(); +} + +void StyleBook::set_directory(std::string d) { + // Suppression du slash final + if (d.compare ( d.size()-1,1,"/" ) == 0) { + d.pop_back(); + } + directory = d; +} + +std::map StyleBook::get_book() { + return book; +} + +Style *StyleBook::get_style(std::string id) { + std::map::iterator it = book.find ( id ); + if ( it != book.end() ) { + return it->second; + } + std::string d; + if (directory.empty()) { + char* e = getenv (ROK4_STYLES_DIRECTORY); + if (e == NULL) { + d.assign("/usr/share/rok4/styles"); + } else { + d.assign(e); + } + } else { + d = directory; + } + std::string style_path = d + "/" + id; + mtx.lock(); + // Si on fait du cache de style, on revérifie que ce style n'a pas déjà été ajouté par un thread concurrent entre temps + if(getenv (ROK4_STYLES_NO_CACHE) == NULL) { + if ( it != book.end() ) { + // On a effectivement depuis déjà enregistré ce style + return it->second; + } + } + Style* style = new Style(style_path); + if ( ! style->is_ok() ) { + BOOST_LOG_TRIVIAL(error) << style->get_error_message(); + delete style; + mtx.unlock(); + return NULL; + } + if ( contain_chars(style->get_identifier(), "<>") ) { + BOOST_LOG_TRIVIAL(error) << "Style identifier contains forbidden chars" ; + delete style; + mtx.unlock(); + return NULL; + } + if(getenv (ROK4_STYLES_NO_CACHE) == NULL) { + // On veut utiliser le cache, on met donc ce nouveau style dans l'annuaire pour le trouver la porchaine fois + book.insert ( std::pair(id, style) ); + } else { + // On met le style directement dans la corbeille, pour que le nettoyage se fasse bien + trash.push_back(style); + } + mtx.unlock(); + return style; +} + +int StyleBook::get_styles_count() { + return book.size(); +} + +StyleBook::~StyleBook() { + +} From 37007f6eb509fc55f774d56e7c2dd0514c610489 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Tue, 7 Oct 2025 16:01:30 +0200 Subject: [PATCH 09/15] Export de CrsBook hors de Cache --- include/rok4/image/Image.h | 3 +- include/rok4/utils/Cache.h | 96 ----------------------- include/rok4/utils/CrsBook.h | 117 +++++++++++++++++++++++++++++ include/rok4/utils/TileMatrixSet.h | 2 +- src/utils/Cache.cpp | 1 + src/utils/CrsBook.cpp | 80 ++++++++++++++++++++ 6 files changed, 201 insertions(+), 98 deletions(-) create mode 100644 include/rok4/utils/CrsBook.h create mode 100644 src/utils/CrsBook.cpp diff --git a/include/rok4/image/Image.h b/include/rok4/image/Image.h index 1a32238f..a881b128 100644 --- a/include/rok4/image/Image.h +++ b/include/rok4/image/Image.h @@ -51,8 +51,9 @@ #include #include "rok4/utils/BoundingBox.h" -#include "rok4/utils/CRS.h" #include "rok4/utils/Cache.h" +#include "rok4/utils/CrsBook.h" + #define METER_PER_DEG 111319.492 diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h index 9cb3a584..b19f9b5f 100644 --- a/include/rok4/utils/Cache.h +++ b/include/rok4/utils/Cache.h @@ -67,99 +67,3 @@ #include "rok4/utils/StyleBook.h" #include "rok4/utils/IndexCache.h" #include "rok4/storage/Context.h" - - -#define ROK4_TMS_DIRECTORY "ROK4_TMS_DIRECTORY" -#define ROK4_TMS_NO_CACHE "ROK4_TMS_NO_CACHE" -#define ROK4_STYLES_DIRECTORY "ROK4_STYLES_DIRECTORY" -#define ROK4_STYLES_NO_CACHE "ROK4_STYLES_NO_CACHE" - -/** - * \author Institut national de l'information géographique et forestière - * \~french - * \brief Création d'un annuaire de CRS - * \details Cette classe est prévue pour être utilisée sans instance - */ -class CrsBook { - -private: - - /** - * \~french - * \brief Constructeur - * \~english - * \brief Constructeur - */ - CrsBook(){}; - - /** - * \~french \brief Annuaire de styles - * \details La clé est l'identifiant du style - * \~english \brief Book of styles - * \details Key is a the style identifier - */ - static std::map book; - - /** - * \~french \brief Exclusion mutuelle - * \details Pour éviter les modifications concurrentes du cache de CRS - * \~english \brief Mutual exclusion - * \details To avoid concurrent CRS cache updates - */ - static std::mutex mtx; - -public: - - - /** - * \~french - * \brief Retourne le CRS d'après son identifiant (code de requête) - * \param[in] id Identifiant du CRS voulu - - * \brief Return the style according to its identifier - * \param[in] id Wanted style identifier - */ - static CRS* get_crs(std::string id) { - - id = to_upper_case(id); - - std::map::iterator it = book.find ( id ); - if ( it != book.end() ) { - return it->second; - } - - mtx.lock(); - - CRS* crs = new CRS(id); - // Le CRS est potentiellement non défini (si il n'est pas valide), on le mémorise pour ne pas réessayer la prochaine fois - book.emplace(id, crs); - - mtx.unlock(); - return crs; - } - - /** - * \~french \brief Nettoie tous les CRS dans l'annuaire et le vide - * \~english \brief Clean all CRS objects in the book and empty it - */ - static void clean_crss () { - mtx.lock(); - std::map::iterator it; - for (it = book.begin(); it != book.end(); ++it) { - delete it->second; - } - book.clear(); - mtx.unlock(); - } - - /** - * \~french - * \brief Destructeur - * \~english - * \brief Destructor - */ - ~CrsBook() {}; - -}; - - diff --git a/include/rok4/utils/CrsBook.h b/include/rok4/utils/CrsBook.h new file mode 100644 index 00000000..6c608760 --- /dev/null +++ b/include/rok4/utils/CrsBook.h @@ -0,0 +1,117 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file CrsBook.h + ** \~french + * \brief Définition de la classe CrsBook + ** \~english + * \brief Define classe CrsBook + */ + +#pragma once + +#include +#include +#include +#include + +#include "rok4/utils/CRS.h" +/** + * \author Institut national de l'information géographique et forestière + * \~french + * \brief Création d'un annuaire de CRS + * \details Cette classe est prévue pour être utilisée sans instance + */ +class CrsBook { + +private: + + /** + * \~french + * \brief Constructeur + * \~english + * \brief Constructeur + */ + CrsBook(); + + /** + * \~french \brief Annuaire de styles + * \details La clé est l'identifiant du style + * \~english \brief Book of styles + * \details Key is a the style identifier + */ + static std::map book; + + /** + * \~french \brief Exclusion mutuelle + * \details Pour éviter les modifications concurrentes du cache de CRS + * \~english \brief Mutual exclusion + * \details To avoid concurrent CRS cache updates + */ + static std::mutex mtx; + +public: + + + /** + * \~french + * \brief Retourne le CRS d'après son identifiant (code de requête) + * \param[in] id Identifiant du CRS voulu + + * \brief Return the style according to its identifier + * \param[in] id Wanted style identifier + */ + static CRS* get_crs(std::string id); + + /** + * \~french \brief Nettoie tous les CRS dans l'annuaire et le vide + * \~english \brief Clean all CRS objects in the book and empty it + */ + static void clean_crss (); + + /** + * \~french + * \brief Destructeur + * \~english + * \brief Destructor + */ + ~CrsBook(); + +}; + + diff --git a/include/rok4/utils/TileMatrixSet.h b/include/rok4/utils/TileMatrixSet.h index fd6ea72b..bd1028b6 100644 --- a/include/rok4/utils/TileMatrixSet.h +++ b/include/rok4/utils/TileMatrixSet.h @@ -52,7 +52,7 @@ #include #include "rok4/utils/TileMatrix.h" -#include "rok4/utils/CRS.h" +#include "rok4/utils/CrsBook.h" #include "rok4/utils/Keyword.h" #include "rok4/utils/Configuration.h" diff --git a/src/utils/Cache.cpp b/src/utils/Cache.cpp index 91ebdd8d..f61fab44 100644 --- a/src/utils/Cache.cpp +++ b/src/utils/Cache.cpp @@ -44,6 +44,7 @@ */ #include "utils/Cache.h" +#include "utils/CrsBook.h" #include "rok4/utils/ProjPool.h" #include "storage/FileContext.h" #include "storage/SwiftContext.h" diff --git a/src/utils/CrsBook.cpp b/src/utils/CrsBook.cpp new file mode 100644 index 00000000..6e04ac79 --- /dev/null +++ b/src/utils/CrsBook.cpp @@ -0,0 +1,80 @@ +/* + * Copyright © (2011) Institut national de l'information + * géographique et forestière + * + * Géoportail SAV + * + * This software is a computer program whose purpose is to publish geographic + * data using OGC WMS and WMTS protocol. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * + * knowledge of the CeCILL-C license and that you accept its terms. + */ + +/** + * \file CrsBook.cpp + ** \~french + * \brief Implémentation de la classe CrsBook + ** \~english + * \brief Implements classe CrsBook + */ + + +#include "rok4/utils/CrsBook.h" + +CrsBook::CrsBook(){ + +} + + +CRS* CrsBook::get_crs(std::string id) { + id = to_upper_case(id); + std::map::iterator it = book.find ( id ); + if ( it != book.end() ) { + return it->second; + } + mtx.lock(); + CRS* crs = new CRS(id); + // Le CRS est potentiellement non défini (si il n'est pas valide), on le mémorise pour ne pas réessayer la prochaine fois + book.emplace(id, crs); + mtx.unlock(); + return crs; +} + +void CrsBook::clean_crss () { + mtx.lock(); + std::map::iterator it; + for (it = book.begin(); it != book.end(); ++it) { + delete it->second; + } + book.clear(); + mtx.unlock(); +} + +CrsBook::~CrsBook() { + +} From f526524bbff0e1679fe272de276baeedf3431fb9 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Thu, 9 Oct 2025 11:08:40 +0200 Subject: [PATCH 10/15] Exporting Cache.cpp on each file. Deleting both Cache files --- include/rok4/utils/Cache.h | 69 ------------- include/rok4/utils/StoragePool.h | 9 +- include/rok4/utils/TileMatrixSet.h | 4 +- include/rok4/utils/TmsBook.h | 1 - src/datasource/StoreDataSource.cpp | 1 - src/image/file/Rok4Image.cpp | 1 - src/utils/BoundingBox.cpp | 1 - src/utils/Cache.cpp | 158 ----------------------------- src/utils/CrsBook.cpp | 3 + src/utils/CurlPool.cpp | 2 + src/utils/IndexCache.cpp | 6 ++ src/utils/ProjPool.cpp | 3 + src/utils/Pyramid.cpp | 1 - src/utils/StoragePool.cpp | 83 ++++++++++++++- src/utils/StyleBook.cpp | 5 + src/utils/TileMatrixSet.cpp | 3 - src/utils/TmsBook.cpp | 7 +- 17 files changed, 117 insertions(+), 240 deletions(-) delete mode 100644 include/rok4/utils/Cache.h delete mode 100644 src/utils/Cache.cpp diff --git a/include/rok4/utils/Cache.h b/include/rok4/utils/Cache.h deleted file mode 100644 index b19f9b5f..00000000 --- a/include/rok4/utils/Cache.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -/** - * \file Cache.h - ** \~french - * \brief Définition des classes IndexCache, CurlPool, StoragePool et ProjPool - ** \~english - * \brief Define classes IndexCache, CurlPool, StoragePool and ProjPool - */ - -#pragma once - -#include // pour uint8_t -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "rok4/utils/TileMatrixSet.h" -#include "rok4/style/Style.h" -#include "rok4/utils/Utils.h" -#include "rok4/utils/CRS.h" -#include "rok4/utils/TmsBook.h" -#include "rok4/utils/StyleBook.h" -#include "rok4/utils/IndexCache.h" -#include "rok4/storage/Context.h" diff --git a/include/rok4/utils/StoragePool.h b/include/rok4/utils/StoragePool.h index ce3fb524..c763cf12 100644 --- a/include/rok4/utils/StoragePool.h +++ b/include/rok4/utils/StoragePool.h @@ -37,7 +37,14 @@ #pragma once -#include "rok4/storage/Context.h" +#include "rok4/utils/StyleBook.h" +#include "rok4/utils/IndexCache.h" +#include "storage/FileContext.h" +#include "storage/SwiftContext.h" +#include "storage/S3Context.h" +#if CEPH_ENABLED + #include "storage/ceph/CephPoolContext.h" +#endif /** * \author Institut national de l'information géographique et forestière diff --git a/include/rok4/utils/TileMatrixSet.h b/include/rok4/utils/TileMatrixSet.h index bd1028b6..18f1616c 100644 --- a/include/rok4/utils/TileMatrixSet.h +++ b/include/rok4/utils/TileMatrixSet.h @@ -53,8 +53,7 @@ #include "rok4/utils/TileMatrix.h" #include "rok4/utils/CrsBook.h" -#include "rok4/utils/Keyword.h" -#include "rok4/utils/Configuration.h" +#include "rok4/utils/StoragePool.h" typedef std::function, std::pair)> ComparatorTileMatrix; @@ -96,6 +95,7 @@ typedef std::function, std::pair #include #include -#include #include #include "rok4/utils/TileMatrixSet.h" diff --git a/src/datasource/StoreDataSource.cpp b/src/datasource/StoreDataSource.cpp index d60e7fa2..b9c9f19a 100644 --- a/src/datasource/StoreDataSource.cpp +++ b/src/datasource/StoreDataSource.cpp @@ -52,7 +52,6 @@ #include #include #include -#include "utils/Cache.h" #include "enums/Format.h" #include "storage/Context.h" diff --git a/src/image/file/Rok4Image.cpp b/src/image/file/Rok4Image.cpp index 0bae3420..5abd7202 100644 --- a/src/image/file/Rok4Image.cpp +++ b/src/image/file/Rok4Image.cpp @@ -56,7 +56,6 @@ #include #include "utils/Utils.h" #include "datasource/DataSource.h" -#include "utils/Cache.h" #include #include #include diff --git a/src/utils/BoundingBox.cpp b/src/utils/BoundingBox.cpp index ffd68382..bc63d8a4 100644 --- a/src/utils/BoundingBox.cpp +++ b/src/utils/BoundingBox.cpp @@ -45,7 +45,6 @@ #include "utils/BoundingBox.h" #include "utils/CRS.h" -#include "utils/Cache.h" template bool BoundingBox::is_in_crs_area(CRS* c) { diff --git a/src/utils/Cache.cpp b/src/utils/Cache.cpp deleted file mode 100644 index f61fab44..00000000 --- a/src/utils/Cache.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright © (2011) Institut national de l'information - * géographique et forestière - * - * Géoportail SAV - * - * This software is a computer program whose purpose is to publish geographic - * data using OGC WMS and WMTS protocol. - * - * This software is governed by the CeCILL-C license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-C - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * - * knowledge of the CeCILL-C license and that you accept its terms. - */ - -/** - * \file Cache.cpp - ** \~french - * \brief Implémentation des classes IndexCache, CurlPool, StoragePool et ProjPool - ** \~english - * \brief Implements classes IndexCache, CurlPool, StoragePool and ProjPool - */ - -#include "utils/Cache.h" -#include "utils/CrsBook.h" -#include "rok4/utils/ProjPool.h" -#include "storage/FileContext.h" -#include "storage/SwiftContext.h" -#include "storage/S3Context.h" -#if CEPH_ENABLED - #include "storage/ceph/CephPoolContext.h" -#endif - -std::map CurlPool::pool; - -std::map ProjPool::pool; - -std::map,Context*> StoragePool::pool; - -std::list IndexCache::cache; -std::unordered_map::iterator> IndexCache::map; -int IndexCache::size = 100; -int IndexCache::validity = 300; -std::mutex IndexCache::mtx; - -std::map TmsBook::book; -std::vector TmsBook::trash; -std::string TmsBook::directory = ""; -std::mutex TmsBook::mtx; - -std::map StyleBook::book; -std::vector StyleBook::trash; -std::string StyleBook::directory = ""; -std::mutex StyleBook::mtx; - -std::map CrsBook::book; -std::mutex CrsBook::mtx; - -Context * StoragePool::get_context(ContextType::eContextType type, std::string tray, Context* reference_context) { - - if (reference_context != 0 && reference_context->get_type() != type) { - BOOST_LOG_TRIVIAL(error) << "Asked storage context and reference one have to own the same type"; - return NULL; - } - - if (type == ContextType::S3CONTEXT) { - // Dans le cas S3, le nom du bucket peut contenir le nom du cluster ou pas - // Pour voir si on a déjà ce contexte de stockage, il faut que "tray" contienne le nom du bucket et du cluster - // pour ne pas confondre 2 buckets avec le même nom sur deux clusters différents - // On va donc s'assurer d'avoir ce nom de cluster : - // - soit il y est déjà et on le laisse - // - soit il n'y est pas et on met celui du contexte de référence - // - soit il n'y est pas et pas de contexte de référence => on met celui par défaut - - size_t pos = tray.find ( "@" ); - if ( pos == std::string::npos ) { - std::string cluster_name; - if (reference_context == 0) { - cluster_name = S3Context::get_default_cluster(); - if (cluster_name == "") { - // Le chargement des informations a échoué (déjà loggé) - return NULL; - } - } else { - // On ajoute le nom du cluster au nom du bucket - cluster_name = ((S3Context *)reference_context)->getCluster(); - } - - tray = tray + "@" + cluster_name; - } - } - - Context* ctx; - std::pair key = make_pair(type,tray); - - std::map, Context*>::iterator it = pool.find (key); - if ( it != pool.end() ) { - // le contenant est déjà existant et donc connecté - return it->second; - - } else { - // ce contenant n'est pas encore connecté, on va créer la connexion - // on créé le context selon le type de stockage - switch(type){ -#if CEPH_ENABLED - case ContextType::CEPHCONTEXT: - ctx = new CephPoolContext(tray); - break; -#endif - case ContextType::SWIFTCONTEXT: - ctx = new SwiftContext(tray); - break; - case ContextType::S3CONTEXT: - ctx = new S3Context(tray); - break; - case ContextType::FILECONTEXT: - ctx = new FileContext(tray); - break; - default: - BOOST_LOG_TRIVIAL(error) << "Unhandled storage context type"; - return NULL; - } - - // on connecte pour vérifier que ce contexte est valide - if (! ctx->connection()) { - BOOST_LOG_TRIVIAL(error) << "Cannot connect " << ContextType::to_string(type) << " storage context, tray '" << tray << "'"; - delete ctx; - return NULL; - } - - BOOST_LOG_TRIVIAL(debug) << "Add storage context " << ContextType::to_string(type) << ", tray '" << tray << "'"; - pool.insert(make_pair(key,ctx)); - - return ctx; - } -} \ No newline at end of file diff --git a/src/utils/CrsBook.cpp b/src/utils/CrsBook.cpp index 6e04ac79..00e54047 100644 --- a/src/utils/CrsBook.cpp +++ b/src/utils/CrsBook.cpp @@ -78,3 +78,6 @@ void CrsBook::clean_crss () { CrsBook::~CrsBook() { } + +std::map CrsBook::book; +std::mutex CrsBook::mtx; diff --git a/src/utils/CurlPool.cpp b/src/utils/CurlPool.cpp index 4e3f5e5d..246a3282 100644 --- a/src/utils/CurlPool.cpp +++ b/src/utils/CurlPool.cpp @@ -74,3 +74,5 @@ void CurlPool::clean_curls() { } pool.clear(); } + +std::map CurlPool::pool; diff --git a/src/utils/IndexCache.cpp b/src/utils/IndexCache.cpp index cef722dc..99160300 100644 --- a/src/utils/IndexCache.cpp +++ b/src/utils/IndexCache.cpp @@ -146,3 +146,9 @@ void IndexCache::clean_indexes() { cache.clear(); mtx.unlock(); } + +std::list IndexCache::cache; +std::unordered_map::iterator> IndexCache::map; +int IndexCache::size = 100; +int IndexCache::validity = 300; +std::mutex IndexCache::mtx; diff --git a/src/utils/ProjPool.cpp b/src/utils/ProjPool.cpp index 3bd63b22..b90e9962 100644 --- a/src/utils/ProjPool.cpp +++ b/src/utils/ProjPool.cpp @@ -77,3 +77,6 @@ void ProjPool::clean_projs() { } pool.clear(); } + +std::map ProjPool::pool; + diff --git a/src/utils/Pyramid.cpp b/src/utils/Pyramid.cpp index eafa2ed2..b032449e 100644 --- a/src/utils/Pyramid.cpp +++ b/src/utils/Pyramid.cpp @@ -48,7 +48,6 @@ #include "image/ExtendedCompoundImage.h" #include "enums/Format.h" #include "utils/Level.h" -#include "utils/Cache.h" #include #include "image/EmptyImage.h" diff --git a/src/utils/StoragePool.cpp b/src/utils/StoragePool.cpp index c2fc3ce7..412e012d 100644 --- a/src/utils/StoragePool.cpp +++ b/src/utils/StoragePool.cpp @@ -111,4 +111,85 @@ void StoragePool::clean_storages () { delete it->second; it->second = NULL; } -} \ No newline at end of file +} + +Context * StoragePool::get_context(ContextType::eContextType type, std::string tray, Context* reference_context) { + + if (reference_context != 0 && reference_context->get_type() != type) { + BOOST_LOG_TRIVIAL(error) << "Asked storage context and reference one have to own the same type"; + return NULL; + } + + if (type == ContextType::S3CONTEXT) { + // Dans le cas S3, le nom du bucket peut contenir le nom du cluster ou pas + // Pour voir si on a déjà ce contexte de stockage, il faut que "tray" contienne le nom du bucket et du cluster + // pour ne pas confondre 2 buckets avec le même nom sur deux clusters différents + // On va donc s'assurer d'avoir ce nom de cluster : + // - soit il y est déjà et on le laisse + // - soit il n'y est pas et on met celui du contexte de référence + // - soit il n'y est pas et pas de contexte de référence => on met celui par défaut + + size_t pos = tray.find ( "@" ); + if ( pos == std::string::npos ) { + std::string cluster_name; + if (reference_context == 0) { + cluster_name = S3Context::get_default_cluster(); + if (cluster_name == "") { + // Le chargement des informations a échoué (déjà loggé) + return NULL; + } + } else { + // On ajoute le nom du cluster au nom du bucket + cluster_name = ((S3Context *)reference_context)->getCluster(); + } + + tray = tray + "@" + cluster_name; + } + } + + Context* ctx; + std::pair key = make_pair(type,tray); + + std::map, Context*>::iterator it = pool.find (key); + if ( it != pool.end() ) { + // le contenant est déjà existant et donc connecté + return it->second; + + } else { + // ce contenant n'est pas encore connecté, on va créer la connexion + // on créé le context selon le type de stockage + switch(type){ +#if CEPH_ENABLED + case ContextType::CEPHCONTEXT: + ctx = new CephPoolContext(tray); + break; +#endif + case ContextType::SWIFTCONTEXT: + ctx = new SwiftContext(tray); + break; + case ContextType::S3CONTEXT: + ctx = new S3Context(tray); + break; + case ContextType::FILECONTEXT: + ctx = new FileContext(tray); + break; + default: + BOOST_LOG_TRIVIAL(error) << "Unhandled storage context type"; + return NULL; + } + + // on connecte pour vérifier que ce contexte est valide + if (! ctx->connection()) { + BOOST_LOG_TRIVIAL(error) << "Cannot connect " << ContextType::to_string(type) << " storage context, tray '" << tray << "'"; + delete ctx; + return NULL; + } + + BOOST_LOG_TRIVIAL(debug) << "Add storage context " << ContextType::to_string(type) << ", tray '" << tray << "'"; + pool.insert(make_pair(key,ctx)); + + return ctx; + } +} + +std::map,Context*> StoragePool::pool; \ No newline at end of file diff --git a/src/utils/StyleBook.cpp b/src/utils/StyleBook.cpp index 30c72a70..640e9a7c 100644 --- a/src/utils/StyleBook.cpp +++ b/src/utils/StyleBook.cpp @@ -137,3 +137,8 @@ int StyleBook::get_styles_count() { StyleBook::~StyleBook() { } + +std::map StyleBook::book; +std::vector StyleBook::trash; +std::string StyleBook::directory = ""; +std::mutex StyleBook::mtx; \ No newline at end of file diff --git a/src/utils/TileMatrixSet.cpp b/src/utils/TileMatrixSet.cpp index 0e311c4c..78ef2c93 100644 --- a/src/utils/TileMatrixSet.cpp +++ b/src/utils/TileMatrixSet.cpp @@ -45,9 +45,6 @@ #include "utils/TileMatrixSet.h" -#include "utils/Utils.h" -#include "utils/Cache.h" -#include "storage/Context.h" #include #include diff --git a/src/utils/TmsBook.cpp b/src/utils/TmsBook.cpp index 1159558f..8f45ba44 100644 --- a/src/utils/TmsBook.cpp +++ b/src/utils/TmsBook.cpp @@ -131,4 +131,9 @@ int TmsBook::get_tms_count() { TmsBook::~TmsBook(){ -} \ No newline at end of file +} + +std::map TmsBook::book; +std::vector TmsBook::trash; +std::string TmsBook::directory = ""; +std::mutex TmsBook::mtx; \ No newline at end of file From bfc5e93fcb31b7edb9354af045d384b188a19eea Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Thu, 9 Oct 2025 15:23:48 +0200 Subject: [PATCH 11/15] =?UTF-8?q?Mise=20=C3=A0=20jour=20des=20imports=20po?= =?UTF-8?q?ur=20la=20compilation=20de=20g=C3=A9n=C3=A9ration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/utils/StoragePool.h | 4 +--- src/utils/StoragePool.cpp | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/rok4/utils/StoragePool.h b/include/rok4/utils/StoragePool.h index c763cf12..145cd27a 100644 --- a/include/rok4/utils/StoragePool.h +++ b/include/rok4/utils/StoragePool.h @@ -39,9 +39,7 @@ #include "rok4/utils/StyleBook.h" #include "rok4/utils/IndexCache.h" -#include "storage/FileContext.h" -#include "storage/SwiftContext.h" -#include "storage/S3Context.h" + #if CEPH_ENABLED #include "storage/ceph/CephPoolContext.h" #endif diff --git a/src/utils/StoragePool.cpp b/src/utils/StoragePool.cpp index 412e012d..0b6219d3 100644 --- a/src/utils/StoragePool.cpp +++ b/src/utils/StoragePool.cpp @@ -44,6 +44,9 @@ */ #include "utils/StoragePool.h" +#include "storage/FileContext.h" +#include "storage/SwiftContext.h" +#include "storage/S3Context.h" StoragePool::StoragePool(){ From 22ff93fe3dd29ca5ac3af9cf9cf8ff93407a8e1b Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Fri, 17 Oct 2025 17:02:32 +0200 Subject: [PATCH 12/15] =?UTF-8?q?Mise=20=C3=A0=20jour=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69533920..2408e48b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr ### Added ### Changed + +- `Cache` : Export de toutes les classes implémentées dans Cache dans leurs propres fichiers + ### Deprecated ### Removed ### Fixed From cb2ad2c398bdf7b8fedfd32bfa34cc0b1dde8ed1 Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 20 Oct 2025 10:05:20 +0200 Subject: [PATCH 13/15] =?UTF-8?q?Ajout=20pr=C3=A9cision=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2408e48b..6632391c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,15 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr ### Added ### Changed -- `Cache` : Export de toutes les classes implémentées dans Cache dans leurs propres fichiers +- `Cache` : Export de toutes les classes implémentées dans Cache dans leurs propres fichiers. Les fichiers ajoutés sont : + * `CurlPool` + * `ProjPool` + * `StoragePool` + * `IndexCache` + * `IndexElement` + * `TmsBook` + * `StyleBook` + * `CrsBook` ### Deprecated ### Removed From 5d9be630378ca8f58283aa4947c37014b771d45f Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 20 Oct 2025 10:47:55 +0200 Subject: [PATCH 14/15] retraits des relicats de Cache --- README.md | 6 +++++- include/rok4/image/Image.h | 1 - include/rok4/utils/Level.h | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0ab83793..089caf0a 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,11 @@ Le programme qui suit charge une pyramide SCAN1000 à partir de son descripteur, #include #include #include -#include "rok4/utils/Cache.h" +#include "rok4/utils/CrsBook.h" +#include "rok4/utils/TmsBook.h" +#include "rok4/utils/ProjPool.h" +#include "rok4/utils/IndexCache.h" +#include "rok4/utils/StoragePool.h" int main( int argc, char *argv[] ) { diff --git a/include/rok4/image/Image.h b/include/rok4/image/Image.h index a881b128..495391a1 100644 --- a/include/rok4/image/Image.h +++ b/include/rok4/image/Image.h @@ -51,7 +51,6 @@ #include #include "rok4/utils/BoundingBox.h" -#include "rok4/utils/Cache.h" #include "rok4/utils/CrsBook.h" diff --git a/include/rok4/utils/Level.h b/include/rok4/utils/Level.h index f7735902..f695597e 100644 --- a/include/rok4/utils/Level.h +++ b/include/rok4/utils/Level.h @@ -53,7 +53,6 @@ class Level; #include "rok4/utils/Configuration.h" #include "rok4/utils/Level.h" #include "rok4/utils/Table.h" -#include "rok4/utils/Cache.h" /** */ From 336c84f755ad135f77e99ddf54cb345a298812ba Mon Sep 17 00:00:00 2001 From: VincentMiras Date: Mon, 20 Oct 2025 10:48:20 +0200 Subject: [PATCH 15/15] =?UTF-8?q?Simplification=20d'une=20d=C3=A9pendance?= =?UTF-8?q?=20inutile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rok4/utils/StoragePool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rok4/utils/StoragePool.h b/include/rok4/utils/StoragePool.h index 145cd27a..c3f6e04e 100644 --- a/include/rok4/utils/StoragePool.h +++ b/include/rok4/utils/StoragePool.h @@ -38,7 +38,7 @@ #pragma once #include "rok4/utils/StyleBook.h" -#include "rok4/utils/IndexCache.h" +#include "rok4/storage/Context.h" #if CEPH_ENABLED #include "storage/ceph/CephPoolContext.h"