--- parser3/src/main/pa_sql_driver_manager.C 2003/09/25 09:15:03 1.72 +++ parser3/src/main/pa_sql_driver_manager.C 2003/12/11 09:22:09 1.78 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_SQL_DRIVER_MANAGER_C="$Date: 2003/09/25 09:15:03 $"; +static const char * const IDENT_SQL_DRIVER_MANAGER_C="$Date: 2003/12/11 09:22:09 $"; #include "pa_sql_driver_manager.h" #include "ltdl.h" @@ -18,7 +18,7 @@ static const char* IDENT_SQL_DRIVER_MANA // globals -SQL_Driver_manager SQL_driver_manager; +SQL_Driver_manager* SQL_driver_manager=0; // consts @@ -47,16 +47,14 @@ static void expire_connection(SQL_Connec static void expire_connections(SQL_Driver_manager::connection_cache_type::key_type /*key*/, SQL_Driver_manager::connection_cache_type::value_type stack, time_t older_dies) { - for(size_t i=0; itop(); i++) + for(size_t i=0; itop_index(); i++) expire_connection(*stack->get(i), older_dies); } // SQL_Driver_manager SQL_Driver_manager::SQL_Driver_manager(): - prev_expiration_pass_time(0), is_dlinited(false) { - - cache_managers.put(String::Body("sql"), this); + is_dlinited(false), prev_expiration_pass_time(0) { } SQL_Driver_manager::~SQL_Driver_manager() { @@ -242,47 +240,42 @@ void SQL_Driver_manager::maybe_expire_ca prev_expiration_pass_time=now; } } -/* -static void add_connection_to_status_cache_table(Array::Item *value, void *info) { - SQL_Connection& connection=*static_cast(value); - Table& table=*static_cast(info); +static void add_connection_to_status_cache_table(SQL_Connection& connection, Table* table) { if(connection.connected()) { - Array& row=*new Array(); + ArrayString& row=*new ArrayString; // url - row+=&url_without_login(connection.get_url()); + row+=&connection.services().url_without_login(); // time time_t time_used=connection.get_time_used(); - const char* unsafe_time_cstr=ctime(&time_used); - int time_buf_size=strlen(unsafe_time_cstr); - char *safe_time_buf=pool.copy(unsafe_time_cstr, time_buf_size); - row+=new String(safe_time_buf, time_buf_size); + row+=new String(pa_strdup(ctime(&time_used))); - table+=&row; + *table+=&row; } } -static void add_connections_to_status_cache_table(const Hash::Key& key, Hash::Val *value, void *info) { - Stack& stack=*static_cast(value); - Array_iter iter(stack); - for(int countdown=stack.top_index(); countdown-->=0; ) - add_connection_to_status_cache_table(iter.next(), info); -}*/ -/// @todo convert to object_ptr +static void add_connections_to_status_cache_table( + SQL_Driver_manager::connection_cache_type::key_type /*key*/, + SQL_Driver_manager::connection_cache_type::value_type stack, Table* table) +{ + for(Array_iterator i(*stack); i.has_next(); ) + add_connection_to_status_cache_table(*i.next(), table); +} + Value* SQL_Driver_manager::get_status() { Value* result=new VHash; - /* + // cache { - Array& columns=*new Array(); + ArrayString& columns=*new ArrayString; columns+=new String("url"); columns+=new String("time"); - Table& table=*new Table(0, &columns, connection_cache.length()); + Table& table=*new Table(&columns, connection_cache.count()); connection_cache.for_each(add_connections_to_status_cache_table, &table); - result.hash(source).put(*new String("cache"), new VTable(&table)); - }*/ + result->get_hash()->put(*new String("cache"), new VTable(&table)); + } return result; }