|
|
| version 1.17, 2003/07/24 11:31:24 | version 1.21, 2003/11/28 10:27:00 |
|---|---|
| Line 7 | Line 7 |
| #include "pa_config_includes.h" | #include "pa_config_includes.h" |
| #ifdef XML | #ifdef XML |
| static const char* IDENT_STYLESHEET_MANAGER_C="$Date$"; | static const char * const IDENT_STYLESHEET_MANAGER_C="$Date$"; |
| #include "pa_stylesheet_manager.h" | #include "pa_stylesheet_manager.h" |
| #include "pa_exception.h" | #include "pa_exception.h" |
| Line 37 static void expire_connections( | Line 37 static void expire_connections( |
| Stylesheet_manager::connection_cache_type::key_type /*key*/, | Stylesheet_manager::connection_cache_type::key_type /*key*/, |
| Stylesheet_manager::connection_cache_type::value_type stack, | Stylesheet_manager::connection_cache_type::value_type stack, |
| time_t older_dies) { | time_t older_dies) { |
| for(size_t i=0; i<stack->top(); i++) | for(size_t i=0; i<stack->top_index(); i++) |
| expire_connection(*stack->get(i), older_dies); | expire_connection(*stack->get(i), older_dies); |
| } | } |
| Line 51 void Stylesheet_connection::close() { | Line 51 void Stylesheet_connection::close() { |
| Stylesheet_manager::Stylesheet_manager(): prev_expiration_pass_time(0) { | Stylesheet_manager::Stylesheet_manager(): prev_expiration_pass_time(0) { |
| cache_managers.put(StringBody("stylesheet"), this); | cache_managers.put(String::Body("stylesheet"), this); |
| } | } |
| Stylesheet_manager::~Stylesheet_manager() { | Stylesheet_manager::~Stylesheet_manager() { |
| connection_cache.for_each(expire_connections, time(0)+SECOND/*=in future=expire all*/); | connection_cache.for_each(expire_connections, time(0)+SECOND/*=in future=expire all*/); |
| } | } |
| Stylesheet_connection_ptr Stylesheet_manager::get_connection(const String& file_spec) { | Stylesheet_connection_ptr Stylesheet_manager::get_connection(String::Body file_spec) { |
| Stylesheet_connection* result=get_connection_from_cache(file_spec); | Stylesheet_connection* result=get_connection_from_cache(file_spec); |
| if(!result) | if(!result) |
| result=new Stylesheet_connection(file_spec); | result=new Stylesheet_connection(file_spec); |
| return Stylesheet_connection_ptr(result); | return Stylesheet_connection_ptr(result); |
| } | } |
| void Stylesheet_manager::close_connection(const String& file_spec, | void Stylesheet_manager::close_connection(String::Body file_spec, Stylesheet_connection& connection) { |
| Stylesheet_connection& connection) { | |
| put_connection_to_cache(file_spec, connection); | put_connection_to_cache(file_spec, connection); |
| } | } |
| // stylesheet cache | // stylesheet cache |
| /// @todo get rid of memory spending Stack [zeros deep inside got accumulated] | /// @todo get rid of memory spending Stack [zeros deep inside got accumulated] |
| Stylesheet_connection* Stylesheet_manager::get_connection_from_cache(const String& file_spec) { | Stylesheet_connection* Stylesheet_manager::get_connection_from_cache(String::Body file_spec) { |
| SYNCHRONIZED; | SYNCHRONIZED; |
| if(connection_cache_type::value_type connections=connection_cache.get(file_spec)) | if(connection_cache_type::value_type connections=connection_cache.get(file_spec)) |
| Line 85 Stylesheet_connection* Stylesheet_manage | Line 84 Stylesheet_connection* Stylesheet_manage |
| return 0; | return 0; |
| } | } |
| void Stylesheet_manager::put_connection_to_cache(const String& file_spec, | void Stylesheet_manager::put_connection_to_cache(String::Body file_spec, |
| Stylesheet_connection& connection) { | Stylesheet_connection& connection) { |
| SYNCHRONIZED; | SYNCHRONIZED; |