| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : AW_rename.hxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #ifndef AW_RENAME_HXX |
|---|
| 12 | #define AW_RENAME_HXX |
|---|
| 13 | |
|---|
| 14 | #ifndef AW_BASE_HXX |
|---|
| 15 | #include <aw_base.hxx> |
|---|
| 16 | #endif |
|---|
| 17 | #ifndef ARBDBT_H |
|---|
| 18 | #include <arbdbt.h> |
|---|
| 19 | #endif |
|---|
| 20 | |
|---|
| 21 | #define AWAR_NAMESERVER_ADDID "nt/nameserver_addid" |
|---|
| 22 | |
|---|
| 23 | // -------------------------------------------------------------------------------- |
|---|
| 24 | #ifndef AW_RENAME_SKIP_GUI |
|---|
| 25 | |
|---|
| 26 | void AWTC_create_rename_awars(AW_root *root, AW_default db1); |
|---|
| 27 | AW_window *AWTC_create_rename_window(AW_root *root, GBDATA *gb_main); |
|---|
| 28 | |
|---|
| 29 | void AW_create_namesadmin_awars(AW_root *aw_root, GBDATA *gb_main); |
|---|
| 30 | void AW_popup_namesadmin_window(AW_window *parent_win, GBDATA *gb_main); |
|---|
| 31 | |
|---|
| 32 | GB_ERROR AW_select_nameserver(GBDATA *gb_main, GBDATA *gb_other_main); |
|---|
| 33 | |
|---|
| 34 | #endif // AW_RENAME_SKIP_GUI |
|---|
| 35 | // -------------------------------------------------------------------------------- |
|---|
| 36 | |
|---|
| 37 | char *AWTC_create_numbered_suffix(GB_HASH *species_name_hash, const char *shortname, GB_ERROR& warning); |
|---|
| 38 | GB_ERROR AWTC_pars_names(GBDATA *gb_main, bool *isWarning); |
|---|
| 39 | GB_ERROR AWTC_generate_one_name(GBDATA *gb_main, const char *full_name, const char *acc, const char *addid, char*& new_name); |
|---|
| 40 | GB_ERROR AWTC_recreate_name(GBDATA *gb_main); |
|---|
| 41 | |
|---|
| 42 | // return name of additional field used for species identification |
|---|
| 43 | // (-> para 'addid' in AWTC_generate_one_name) |
|---|
| 44 | const char *AW_get_nameserver_addid(GBDATA *gb_main); |
|---|
| 45 | |
|---|
| 46 | GB_ERROR AW_test_nameserver(GBDATA *gb_main); // create a test link to the nameserver |
|---|
| 47 | |
|---|
| 48 | class UniqueNameDetector : virtual Noncopyable { |
|---|
| 49 | // Note: If you add new items to the DB while one instance of this class exists, |
|---|
| 50 | // you have to call add_name() for these new species! |
|---|
| 51 | |
|---|
| 52 | GB_HASH *hash; |
|---|
| 53 | public: |
|---|
| 54 | UniqueNameDetector(GBDATA *gb_item_data, long additionalEntries = 0); |
|---|
| 55 | ~UniqueNameDetector(); |
|---|
| 56 | |
|---|
| 57 | bool name_known(const char *name) { return GBS_read_hash(hash, name) == 1; } |
|---|
| 58 | void add_name(const char *name) { GBS_write_hash(hash, name, 1); } |
|---|
| 59 | }; |
|---|
| 60 | |
|---|
| 61 | char *AWTC_makeUniqueShortName(const char *prefix, UniqueNameDetector& existingNames); |
|---|
| 62 | char *AWTC_generate_random_name(UniqueNameDetector& existingNames); |
|---|
| 63 | |
|---|
| 64 | struct PersistentNameServerConnection { |
|---|
| 65 | // create a PersistentNameServerConnection instance while calling AWTC_generate_one_name |
|---|
| 66 | // to avoid repeated re-connections to name server |
|---|
| 67 | bool dummy; |
|---|
| 68 | PersistentNameServerConnection(); |
|---|
| 69 | ~PersistentNameServerConnection(); |
|---|
| 70 | }; |
|---|
| 71 | |
|---|
| 72 | int AWTC_name_quality(const char *short_name); |
|---|
| 73 | |
|---|
| 74 | #else |
|---|
| 75 | #error AW_rename.hxx included twice |
|---|
| 76 | #endif // AW_RENAME_HXX |
|---|