--- parser3/src/main/pa_stylesheet_manager.C 2004/02/06 11:54:11 1.25 +++ parser3/src/main/pa_stylesheet_manager.C 2026/04/25 13:38:46 1.38 @@ -1,14 +1,12 @@ /** @file Parser: sql driver manager implementation. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #include "pa_config_includes.h" #ifdef XML -static const char * const IDENT_STYLESHEET_MANAGER_C="$Date: 2004/02/06 11:54:11 $"; - #include "pa_stylesheet_manager.h" #include "pa_exception.h" #include "pa_common.h" @@ -17,6 +15,8 @@ static const char * const IDENT_STYLESHE #include "pa_vhash.h" #include "pa_vtable.h" +volatile const char * IDENT_PA_STYLESHEET_MANAGER_C="$Id: pa_stylesheet_manager.C,v 1.38 2026/04/25 13:38:46 moko Exp $" IDENT_PA_STYLESHEET_MANAGER_H; + // globals Stylesheet_manager* stylesheet_manager=0; @@ -32,10 +32,7 @@ static void expire_connection(Stylesheet if(connection.connected() && connection.expired(older_dies)) connection.disconnect(); } -static void expire_connections( - Stylesheet_manager::connection_cache_type::key_type /*key*/, - Stylesheet_manager::connection_cache_type::value_type stack, - time_t older_dies) { +static void expire_connections(Stylesheet_manager::connection_cache_type::key_type /*key*/, Stylesheet_manager::connection_cache_type::value_type stack, time_t older_dies) { for(size_t i=0; itop_index(); i++) expire_connection(*stack->get(i), older_dies); } @@ -52,14 +49,12 @@ Stylesheet_manager::Stylesheet_manager() } Stylesheet_manager::~Stylesheet_manager() { - connection_cache.for_each(expire_connections, time(0)+(time_t)10/*=in future=expire all*/); + connection_cache.for_each(expire_connections, time(0)+(time_t)10/*=in future=expire all*/); } -Stylesheet_connection_ptr Stylesheet_manager::get_connection(String::Body file_spec) { +Stylesheet_connection* Stylesheet_manager::get_connection(String::Body file_spec) { Stylesheet_connection* result=get_connection_from_cache(file_spec); - if(!result) - result=new Stylesheet_connection(file_spec); - return Stylesheet_connection_ptr(result); + return result ? result : new Stylesheet_connection(file_spec); } void Stylesheet_manager::close_connection(String::Body file_spec, Stylesheet_connection& connection) { @@ -81,8 +76,7 @@ Stylesheet_connection* Stylesheet_manage return 0; } -void Stylesheet_manager::put_connection_to_cache(String::Body file_spec, - Stylesheet_connection& connection) { +void Stylesheet_manager::put_connection_to_cache(String::Body file_spec, Stylesheet_connection& connection) { SYNCHRONIZED; connection_cache_type::value_type connections=connection_cache.get(file_spec); @@ -97,7 +91,7 @@ void Stylesheet_manager::maybe_expire_ca time_t now=time(0); if(prev_expiration_pass_time(expire_connections, now-EXPIRE_UNUSED_CONNECTION_SECONDS); prev_expiration_pass_time=now; } @@ -116,11 +110,8 @@ static void add_connection_to_status_cac *table+=&row; } } -static void add_connections_to_status_cache_table( - Stylesheet_manager::connection_cache_type::key_type /*key*/, - Stylesheet_manager::connection_cache_type::value_type stack, Table* table) -{ - for(Array_iterator i(*stack); i.has_next(); ) +static void add_connections_to_status_cache_table(Stylesheet_manager::connection_cache_type::key_type /*key*/, Stylesheet_manager::connection_cache_type::value_type stack, Table* table) { + for(Array_iterator i(*stack); i; ) add_connection_to_status_cache_table(*i.next(), table); } @@ -133,7 +124,7 @@ Value* Stylesheet_manager::get_status() columns+=new String("time"); Table& table=*new Table(&columns, connection_cache.count()); - connection_cache.for_each(add_connections_to_status_cache_table, &table); + connection_cache.for_each(add_connections_to_status_cache_table, &table); result->get_hash()->put(*new String("cache"), new VTable(&table)); }