ARB
Classes | Macros | Functions
adtools.cxx File Reference
#include "gb_data.h"
#include "gb_main.h"
#include <arb_sort.h>
#include <arb_file.h>
#include <arb_sleep.h>
#include <arb_str.h>
#include <arb_strarray.h>
#include <ad_cb.h>
#include <algorithm>
#include "ad_remote.h"
Include dependency graph for adtools.cxx:

Go to the source code of this file.

Classes

struct  GB_DbScanner
 
struct  scan_db_insert
 

Macros

#define GBT_SUM_LEN   4096
 
#define IF_DUMP_HANDSHAKE(cmd)
 

Functions

GBDATAGBT_create (GBDATA *father, const char *key, long delete_level)
 
GBDATAGBT_find_or_create (GBDATA *father, const char *key, long delete_level)
 
charGBT_get_default_helix (GBDATA *)
 
charGBT_get_default_helix_nr (GBDATA *)
 
charGBT_get_default_ref (GBDATA *)
 
static void gbt_scan_db_rek (GBDATA *gbd, char *prefix, GB_DbScanner *scanner)
 
static void gbt_scan_db_start (GBDATA *gbd, GB_DbScanner *scanner)
 
static void gbs_scan_db_insert (const char *key, long, void *cd_insert_data)
 
static int gbs_scan_db_compare (const void *left, const void *right, void *)
 
void GBT_scan_db (StrArray &fieldNames, GBDATA *gbd, const char *datapath)
 
static void new_gbt_message_created_cb (GBDATA *gb_pending_messages)
 
GBDATAfind_or_create_error_container (GBDATA *gb_main)
 
void GBT_install_message_handler (GBDATA *gb_main)
 
void GBT_message (GBDATA *gb_main, const char *msg)
 
charGBT_read_string (GBDATA *gb_container, const char *fieldpath)
 
charGBT_read_as_string (GBDATA *gb_container, const char *fieldpath)
 
const charGBT_read_char_pntr (GBDATA *gb_container, const char *fieldpath)
 
NOT4PERL longGBT_read_int (GBDATA *gb_container, const char *fieldpath)
 
NOT4PERL float * GBT_read_float (GBDATA *gb_container, const char *fieldpath)
 
charGBT_readOrCreate_string (GBDATA *gb_container, const char *fieldpath, const char *default_value)
 
const charGBT_readOrCreate_char_pntr (GBDATA *gb_container, const char *fieldpath, const char *default_value)
 
NOT4PERL longGBT_readOrCreate_int (GBDATA *gb_container, const char *fieldpath, long default_value)
 
NOT4PERL float * GBT_readOrCreate_float (GBDATA *gb_container, const char *fieldpath, float default_value)
 
GB_ERROR GBT_write_string (GBDATA *gb_container, const char *fieldpath, const char *content)
 
GB_ERROR GBT_write_int (GBDATA *gb_container, const char *fieldpath, long content)
 
GB_ERROR GBT_write_byte (GBDATA *gb_container, const char *fieldpath, unsigned char content)
 
GB_ERROR GBT_write_float (GBDATA *gb_container, const char *fieldpath, float content)
 
GBDATAGBT_open (const char *path, const char *opent)
 
static GBDATAwait_for_dbentry (GBDATA *gb_main, const char *entry, const ARB_timeout *timeout, bool verbose)
 
static GB_ERROR gbt_wait_for_remote_action (GBDATA *gb_main, GBDATA *gb_action, const char *awar_read)
 
static void mark_as_macro_executor (GBDATA *gb_main, bool mark)
 
GB_ERROR set_intEntry_to (GBDATA *gb_main, const char *path, int value)
 
GB_ERROR GB_set_macro_error (GBDATA *gb_main, const char *curr_error)
 
GB_ERROR GB_get_macro_error (GBDATA *gb_main)
 
GB_ERROR GB_clear_macro_error (GBDATA *gb_main)
 
static GB_ERROR start_remote_command_for_application (GBDATA *gb_main, const remote_awars &remote, const ARB_timeout *timeout, bool verbose)
 
NOT4PERL GB_ERROR GBT_remote_action_with_timeout (GBDATA *gb_main, const char *application, const char *action_name, const class ARB_timeout *timeout, bool verbose)
 
GB_ERROR GBT_remote_action (GBDATA *gb_main, const char *application, const char *action_name)
 
GB_ERROR GBT_remote_awar (GBDATA *gb_main, const char *application, const char *awar_name, const char *value)
 
GB_ERROR GBT_remote_read_awar (GBDATA *gb_main, const char *application, const char *awar_name)
 
charfind_macro_in (const char *dir, const char *macroname)
 
static charfullMacroname (const char *macro_name)
 
const charrelative_inside (const char *dir, const char *fullpath)
 
const charGBT_relativeMacroname (const char *macro_name)
 
GB_ERROR GBT_macro_execute (const char *macro_name, bool loop_marked, bool run_async)
 

Macro Definition Documentation

#define GBT_SUM_LEN   4096

Definition at line 72 of file adtools.cxx.

Referenced by GB_DbScanner::GB_DbScanner().

#define IF_DUMP_HANDSHAKE (   cmd)

Definition at line 667 of file adtools.cxx.

Referenced by start_remote_command_for_application().

Function Documentation

GBDATA* GBT_create ( GBDATA father,
const char key,
long  delete_level 
)
GBDATA* GBT_find_or_create ( GBDATA father,
const char key,
long  delete_level 
)
char* GBT_get_default_helix ( GBDATA )

Definition at line 64 of file adtools.cxx.

References ARB_strdup().

Referenced by get_helix_string(), BI_helix::init(), and NT_del_mark_move_REF().

char* GBT_get_default_helix_nr ( GBDATA )

Definition at line 65 of file adtools.cxx.

References ARB_strdup().

Referenced by BI_helix::init().

char* GBT_get_default_ref ( GBDATA )

Definition at line 66 of file adtools.cxx.

References ARB_strdup().

Referenced by BI_ecoli_ref::init(), and PT_init_input_data().

static void gbt_scan_db_rek ( GBDATA gbd,
char prefix,
GB_DbScanner scanner 
)
static
static void gbt_scan_db_start ( GBDATA gbd,
GB_DbScanner scanner 
)
static
static void gbs_scan_db_insert ( const char key,
long  ,
void *  cd_insert_data 
)
static
static int gbs_scan_db_compare ( const void *  left,
const void *  right,
void *   
)
static

Definition at line 157 of file adtools.cxx.

Referenced by GBT_scan_db().

void GBT_scan_db ( StrArray &  fieldNames,
GBDATA gbd,
const char datapath 
)

scan CONTAINER for existing sub-keys

recurses completely downwards the DB tree

Parameters
fieldNamesgets filled with result strings
  • each string is the path to a node beyond (any child container of) gbd
  • every string exists only once
  • the first character of a string is the type of the entry
  • the strings are sorted alphabetically
gbdnode where search starts
datapathif not NULp -> only keys with prefix datapath are scanned and the prefix is removed from the resulting key_names.

Note: this function is incredibly slow when called from clients

Warning: avoid to add new callers for this function: the interface is really weird

Definition at line 162 of file adtools.cxx.

References GBS_hash_do_const_loop(), gbs_scan_db_compare(), gbs_scan_db_insert(), gbt_scan_db_start(), GB_DbScanner::hash_table, and NULp.

Referenced by experiment_field_selection_list_rescan(), gene_field_selection_list_rescan(), and species_field_selection_list_rescan().

static void new_gbt_message_created_cb ( GBDATA gb_pending_messages)
static
GBDATA* find_or_create_error_container ( GBDATA gb_main)
inline

Definition at line 219 of file adtools.cxx.

References ERROR_CONTAINER_PATH, GB_CREATE_CONTAINER, and GB_search().

Referenced by GBT_install_message_handler(), and GBT_message().

void GBT_install_message_handler ( GBDATA gb_main)
void GBT_message ( GBDATA gb_main,
const char msg 
)

When called in client(or server) this causes the DB server to show the message. Message is shown via GB_warning (which uses aw_message in GUIs)

Note: The message is not shown before the transaction ends. If the transaction is aborted, the message is never shown!

see also : GB_warning()

Definition at line 238 of file adtools.cxx.

References error(), find_or_create_error_container(), gb_assert, GB_await_error(), GB_create(), GB_end_transaction(), GB_push_transaction(), GB_STRING, GB_write_string(), and NULp.

Referenced by ARB_main(), CON_insertSequences(), GBT_commit_rename_session(), GBT_install_message_handler(), gbt_read_tree_rek(), DI_MATRIX::load(), main(), mark_as_macro_executor(), nt_add(), nt_add_partial(), GroupSearch::perform_search(), read_tree_and_size_internal(), GBT_config::saveAsOver(), set_marks_of(), show_message(), transform_gbd_to_leaf(), and TREE_load_to_db().

char* GBT_read_string ( GBDATA gb_container,
const char fieldpath 
)

Read value from database field (of type GB_STRING)

Parameters
gb_containerwhere to start search for field
fieldpathrelative path from gb_container
Returns
NULp in case of error (use GB_await_error()) or when field does not exist. otherwise returns a heap copy.

other functions return a pointer to a temporary variable (invalidated by next call)

Definition at line 267 of file adtools.cxx.

References GB_FIND, GB_pop_transaction(), GB_push_transaction(), GB_read_string(), GB_search(), NULp, and result.

Referenced by ARB_main(), collectKeysRegisteredInDatabase(), concatenateFieldsCreateNewSpecies(), DI_ENTRY::DI_ENTRY(), ED4_get_and_jump_to_current(), ED4_jump_to_current_species(), ED4_selected_SAI_changed_cb(), ED4_selected_species_changed_cb(), edit_SAI_description(), ALI_selection::fill(), GBT_check_alignment(), GBT_config::GBT_config(), GBT_get_alignment_type_string(), GBT_load_colorset(), get_default_alignment(), getArbFilter(), PHDATA::load(), MG_merge_tagged_field_cb(), nt_build_conf_marked(), NT_suggestValidNames(), pars_generate_aliview(), and relink_pseudo_species_to_organisms().

char* GBT_read_as_string ( GBDATA gb_container,
const char fieldpath 
)

like GBT_read_string()

but

  • field may be of any type (result gets converted to reasonable char*)

Definition at line 290 of file adtools.cxx.

References GB_FIND, GB_pop_transaction(), GB_push_transaction(), GB_read_as_string(), GB_search(), NULp, and result.

Referenced by compare_hits(), QUERY::DbQuery_update_list(), and gbl_readdb().

const char* GBT_read_char_pntr ( GBDATA gb_container,
const char fieldpath 
)

like GBT_read_string()

but

  • result is not a heap-copy and may be invalidated by further DB access (especially by overwriting that fields)

Note: Under no circumstances you may modify the result!

Definition at line 307 of file adtools.cxx.

References GB_FIND, GB_pop_transaction(), GB_push_transaction(), GB_read_char_pntr(), GB_search(), NULp, and result.

Referenced by compare_hits(), delete_unused_changekeys(), export_format_multiple(), GBT_get_configuration_names(), GBT_get_name_or_description(), GBT_log_to_tree_remark(), gen_extract_gene_2_pseudoSpecies(), get_SAI_group(), get_SAI_groups(), set_field_of_queried_cb(), set_SAI_group(), and XML_recursive().

NOT4PERL long* GBT_read_int ( GBDATA gb_container,
const char fieldpath 
)
NOT4PERL float* GBT_read_float ( GBDATA gb_container,
const char fieldpath 
)

similar to GBT_read_string()

but

  • for fields of type GB_FLOAT
  • result gets invalidated by next call

Definition at line 349 of file adtools.cxx.

References GB_FIND, GB_pop_transaction(), GB_push_transaction(), GB_read_float(), GB_search(), NULp, and result.

Referenced by compare_hits().

char* GBT_readOrCreate_string ( GBDATA gb_container,
const char fieldpath,
const char default_value 
)

like GBT_read_string(),

but if field does not exist, it will be created and initialized with 'default_value'

Definition at line 371 of file adtools.cxx.

References GB_pop_transaction(), GB_push_transaction(), GB_read_string(), GB_searchOrCreate_string(), NULp, and result.

Referenced by check_for_remote_command(), MG_merge_tagged_field_cb(), and nt_add().

const char* GBT_readOrCreate_char_pntr ( GBDATA gb_container,
const char fieldpath,
const char default_value 
)

like GBT_read_char_pntr(),

but if field does not exist, it will be created and initialized with 'default_value'

Definition at line 386 of file adtools.cxx.

References GB_pop_transaction(), GB_push_transaction(), GB_read_char_pntr(), GB_searchOrCreate_string(), NULp, and result.

Referenced by awt_create_select_filter_window_gb_cb(), and ArbImporter::read_data().

NOT4PERL long* GBT_readOrCreate_int ( GBDATA gb_container,
const char fieldpath,
long  default_value 
)

like GBT_read_int(),

but if field does not exist, it will be created and initialized with 'default_value'

Definition at line 402 of file adtools.cxx.

References GB_pop_transaction(), GB_push_transaction(), GB_read_int(), GB_searchOrCreate_int(), NULp, and result.

Referenced by check_for_remote_command(), gb_load_single_key_data(), get_DB_state(), NodeTextBuilder::init(), AWT_graphic_tree::show_ruler(), and tree_vars_callback().

NOT4PERL float* GBT_readOrCreate_float ( GBDATA gb_container,
const char fieldpath,
float  default_value 
)

like GBT_read_float(),

but if field does not exist, it will be created and initialized with 'default_value'

Definition at line 422 of file adtools.cxx.

References gb_assert, GB_pop_transaction(), GB_push_transaction(), GB_read_float(), GB_searchOrCreate_float(), NULp, and result.

Referenced by AWT_graphic_tree::show_ruler().

GB_ERROR GBT_write_string ( GBDATA gb_container,
const char fieldpath,
const char content 
)

Write content to database field of type GB_STRING

if field exists, it will be overwritten. if field does not exist, it will be created.

The field should be unique, i.e. it should not exist twice or more in it's parent container

Returns
GB_ERROR on failure

Definition at line 451 of file adtools.cxx.

References error(), gb_assert, GB_await_error(), GB_end_transaction(), GB_nextEntry(), GB_push_transaction(), GB_search(), GB_STRING, and GB_write_string().

Referenced by alignToNextRelative(), ARB_main(), check_for_remote_command(), checkAndMergeFields(), CON_export(), concatenateFieldsCreateNewSpecies(), config_comment_changed_cb(), copy_move_del_alignment(), copy_SAI_cb(), copy_SAI_to_species_cb(), create_data_entry(), create_new_species(), create_split_gene(), edit_SAI_description(), experiment_copy_handler(), extended_rename_handler(), findOrCreate_configuration(), GBT_add_new_changekey_to_keypath(), GBT_check_alignment(), GBT_check_data(), GBT_find_or_create_item_rel_item_data(), GBT_gen_accession_number(), GBT_get_configuration_names(), GBT_remote_awar(), GBT_remote_read_awar(), GBT_save_colorset(), GBT_set_default_alignment(), gbt_write_tree(), GEN_create_nonexisting_gene_rel_gene_data(), GEN_find_or_create_gene_rel_gene_data(), gene_copy_handler(), InsertDatainGDE(), MERGE_sequences_simple(), mg_check_field_cb(), MG_export_fields(), MG_merge_tagged_field_cb(), NT_create_sai_from_pfold(), NT_importValidNames(), NT_suggestValidNames(), remove_redundant_translation(), rename_SAI_cb(), AP_pos_var::save_aliEntry_to_SAI(), GBT_config::saveAsOver(), selectValidNameFromList(), set_addid(), set_SAI_group(), species_copy_cb(), trace_termChange_in_global_awar(), transfer_field_of_listed_cb(), translate_getInfo(), translate_saveInfo(), write_tree_remark(), and writeHistory().

GB_ERROR GBT_write_int ( GBDATA gb_container,
const char fieldpath,
long  content 
)
GB_ERROR GBT_write_byte ( GBDATA gb_container,
const char fieldpath,
unsigned char  content 
)
GB_ERROR GBT_write_float ( GBDATA gb_container,
const char fieldpath,
float  content 
)

like GBT_write_string(),

but for fields of type GB_FLOAT

Definition at line 502 of file adtools.cxx.

References error(), gb_assert, GB_await_error(), GB_end_transaction(), GB_FLOAT, GB_nextEntry(), GB_push_transaction(), GB_search(), and GB_write_float().

Referenced by tree_write_float().

GBDATA* GBT_open ( const char path,
const char opent 
)

Open a database (as GB_open does) Additionally:

  • disable saving in the PT_SERVER directory,
  • create an index for species and extended names (server only!),
Parameters
pathfilename of the DB
opentsee GB_login()
Returns
database handle (or NULp in which case an error is exported)
See also
GB_open()

Definition at line 524 of file adtools.cxx.

References error(), gb_assert, GB_close(), GB_create_index(), GB_disable_path(), GB_export_error(), GB_FIND, GB_have_error(), GB_IGNORE_CASE, GB_number_of_subentries(), GB_open(), GB_path_in_ARBLIB(), GB_search(), GBT_get_SAI_data(), GBT_SAI_INDEX_SIZE, GBT_SPECIES_INDEX_SIZE, hash_size(), max, NULp, and ta.

Referenced by ARB_main(), load_and_startup_main_window(), main(), and SelectedDatabase::open_db_for_merge().

static GBDATA* wait_for_dbentry ( GBDATA gb_main,
const char entry,
const ARB_timeout timeout,
bool  verbose 
)
static
static GB_ERROR gbt_wait_for_remote_action ( GBDATA gb_main,
GBDATA gb_action,
const char awar_read 
)
static
static void mark_as_macro_executor ( GBDATA gb_main,
bool  mark 
)
static
GB_ERROR set_intEntry_to ( GBDATA gb_main,
const char path,
int  value 
)
inline
GB_ERROR GB_set_macro_error ( GBDATA gb_main,
const char curr_error 
)
GB_ERROR GB_get_macro_error ( GBDATA gb_main)
GB_ERROR GB_clear_macro_error ( GBDATA gb_main)
static GB_ERROR start_remote_command_for_application ( GBDATA gb_main,
const remote_awars remote,
const ARB_timeout timeout,
bool  verbose 
)
static
NOT4PERL GB_ERROR GBT_remote_action_with_timeout ( GBDATA gb_main,
const char application,
const char action_name,
const class ARB_timeout timeout,
bool  verbose 
)
GB_ERROR GBT_remote_action ( GBDATA gb_main,
const char application,
const char action_name 
)

Definition at line 809 of file adtools.cxx.

References GBT_remote_action_with_timeout(), mark_as_macro_executor(), and NULp.

GB_ERROR GBT_remote_awar ( GBDATA gb_main,
const char application,
const char awar_name,
const char value 
)
GB_ERROR GBT_remote_read_awar ( GBDATA gb_main,
const char application,
const char awar_name 
)
char* find_macro_in ( const char dir,
const char macroname 
)
inline

Definition at line 853 of file adtools.cxx.

References GB_is_readablefile(), and GBS_global_string_copy().

Referenced by fullMacroname().

static char* fullMacroname ( const char macro_name)
static

detect full path of 'macro_name'

Parameters
macro_namefull path or path relative to ARBMACRO or ARBMACROHOME
Returns
full path or NULp (in which case an error is exported)

Definition at line 862 of file adtools.cxx.

References ARB_strdup(), find_macro_in(), gb_assert, GB_export_errorf(), GB_getenvARBMACRO(), GB_getenvARBMACROHOME(), GB_have_error(), GB_is_readablefile(), NULp, and result.

Referenced by GBT_macro_execute().

const char* relative_inside ( const char dir,
const char fullpath 
)
inline

Definition at line 899 of file adtools.cxx.

References ARB_strBeginsWith(), NULp, and result.

Referenced by GBT_relativeMacroname().

const char* GBT_relativeMacroname ( const char macro_name)

make macro_name relative if it is located in or below ARBMACROHOME or ARBMACRO. Inverse function of fullMacroname()

Returns
pointer into macro_name (relative part) or macro_name itself (if macro is located somewhere else)

Definition at line 907 of file adtools.cxx.

References GB_getenvARBMACRO(), GB_getenvARBMACROHOME(), macro_name, relative_inside(), and result.

Referenced by RecordingMacro::write_action().

GB_ERROR GBT_macro_execute ( const char macro_name,
bool  loop_marked,
bool  run_async 
)

simply execute a macro

In doubt: do not use this function, instead use ../SL/MACROS/macros.hxx

Parameters
macro_namecontains the macro filename (either with full path or relative to directories pointed to by ARBMACRO or ARBMACROHOME)
loop_markedif true -> call macro once for each marked species
run_asyncif true -> run perl asynchronously (will not detect perl failure in that case!)

Definition at line 919 of file adtools.cxx.

References error(), fullMacroname(), GB_await_error(), GB_path_in_ARBHOME(), GBK_singlequote(), GBK_system(), GBS_global_string_copy(), and NULp.

Referenced by MacroRecorder::execute().