33 typedef vector<string> CallbackArray;
34 typedef CallbackArray::const_iterator CallbackIter;
39 static void forgetCalledCallbacks() {
44 static void auto_dontcall1(
const char *key,
long value,
void *cl_hash) {
45 if (strncmp(key,
"ARB_NT/", 7) == 0) {
50 static void auto_dontcall2(
const char *key,
long value,
void *) {
54 static void forget_dontCallHash() {
62 static void build_dontCallHash() {
65 forgetCalledCallbacks();
67 atexit(forget_dontCallHash);
85 GBS_write_hash(dontCallHash,
"GDE__User__Start_a_slave_ARB_on_a_foreign_host_/GO", 2);
86 GBS_write_hash(dontCallHash,
"NAME_SERVER_ADMIN/REMOVE_SUPERFLUOUS_ENTRIES_IN_NAMES_FILE", 2);
87 GBS_write_hash(dontCallHash,
"GDE__Print__Pretty_print_sequences_slow_/GO", 2);
98 GBS_write_hash(dontCallHash,
"NAME_SERVER_ADMIN/EDIT_NAMES_FILE", 2);
113 GBS_write_hash(dontCallHash,
"PT_SERVER_ADMIN/CREATE_TEMPLATE", 2);
115 GBS_write_hash(dontCallHash,
"NAME_SERVER_ADMIN/CREATE_TEMPLATE", 2);
117 GBS_write_hash(dontCallHash,
"EXPORT_TREE_AS_XFIG/START_XFIG", 2);
141 GBS_write_hash(dontCallHash,
"Signature_region_search_1/SAVE", 3);
142 GBS_write_hash(dontCallHash,
"Signature_global_search_1/SAVE", 3);
152 GBS_write_hash(dontCallHash,
"ARB_NT/view_probe_group_result", 4);
174 GBS_write_hash(dontCallHash,
"GDE__Import__Import_sequences_using_Readseq_slow_/GO", 5);
177 GBS_write_hash(dontCallHash,
"MULTI_PROBE/CREATE_NEW_SEQUENCE", 5);
178 GBS_write_hash(dontCallHash,
"PT_SERVER_ADMIN/KILL_ALL_SERVERS", 5);
183 GBS_write_hash(dontCallHash,
"SPECIES_QUERY/DELETE_LISTED_spec", 5);
184 GBS_write_hash(dontCallHash,
"SPECIES_QUERY/SAVELOAD_CONFIG_spec", 5);
190 GBS_write_hash(dontCallHash,
"NAME_SERVER_ADMIN/DELETE_OLD_NAMES_FILE", 5);
207 StringVectorArray(
const CallbackArray& a)
211 for (CallbackArray::iterator
id = array.begin();
id != array.end(); ++
id) {
217 inline bool exclude_key(
const char *key) {
218 if (strncmp(key,
"FILTER_SELECT_", 14) == 0) {
219 if (strstr(key,
"/2filter/2filter/2filter/")) {
224 if (strstr(key,
"SAVELOAD_CONFIG"))
return true;
229 inline bool is_wanted_callback(
const char *key) {
235 static int sortedByCallbackLocation(
const char *k0,
long v0,
const char *k1,
long v1) {
240 if (!cmp) cmp = strcmp(k0, k1);
248 static void add_wanted_callbacks(
const char *key,
long ,
void *cl_callbacks) {
249 if (is_wanted_callback(key)) {
250 CallbackArray *callbacks =
reinterpret_cast<CallbackArray*
>(cl_callbacks);
251 callbacks->push_back(
string(key));
256 if (!dontCallHash) build_dontCallHash();
257 CallbackArray callbacks;
259 return new StringVectorArray(callbacks);
265 size_t AW_root::callallcallbacks(
int mode) {
276 size_t callCount = 0;
280 if (!dontCallHash) build_dontCallHash();
282 if (mode>0 && (mode&8)) {
284 for (
int iter = 1; ; ++iter) {
285 size_t thisCount = callallcallbacks(mode&~8);
292 callCount += thisCount;
295 else if (mode == -1) {
296 forgetCalledCallbacks();
299 CallbackArray callbacks;
310 aw_message(
"Marking all callbacks as \"called\"");
325 case 3: reverse(callbacks.begin(), callbacks.end());
break;
326 case 4: random_shuffle(callbacks.begin(), callbacks.end());
break;
330 count = callbacks.size();
333 CallbackIter end = callbacks.end();
335 for (
int pass = 1; pass <= 2; ++pass) {
337 CallbackIter
cb = callbacks.begin();
339 for (; cb != end; ++
cb) {
340 const char *remote_command = cb->c_str();
341 const char *remote_command_name = remote_command;
343 const char *slash = strrchr(remote_command,
'/');
344 if (slash) remote_command_name = slash+1;
347 char firstNameChar = remote_command_name[0];
348 bool this_pass = firstNameChar ==
'-' ? (pass == 2) : (pass == 1);
355 bool skipcb = firstNameChar ==
'!' ||
GBS_read_hash(dontCallHash, remote_command);
362 fprintf(stderr,
"Skipped callback %zu/%zu (%s)\n", curr, count, remote_command);
365 fprintf(stderr,
"Calling back %zu/%zu (%s)\n", curr, count, remote_command);
371 process_pending_events();
374 fprintf(stderr,
"Unhandled error in '%s': %s\n", remote_command,
GB_await_error());
381 fprintf(stderr,
"Delayed callback %zu/%zu (%s)\n", curr, count, remote_command);
388 if (pass == 1) fprintf(stderr,
"Executing delayed callbacks:\n");
void GBS_hash_do_const_sorted_loop(const GB_HASH *hs, gb_hash_const_loop_type func, gbs_hash_compare_function sorter, void *client_data)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
const char * GBS_global_string(const char *templat,...)
void GBS_free_hash(GB_HASH *hs)
GB_ERROR GB_await_error()
bool contains(AnyWinCB g)
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
int compare(const AW_cb &other) const
size_t GBS_hash_elements(const GB_HASH *hs)
WindowCallbackSimple AnyWinCB
void AW_help_entry_pressed(AW_window *aww)
void aw_message(const char *msg)
int GBS_HCF_sortedByKey(const char *k0, long dummy_1x, const char *k1, long dummy_2x)
long GBS_read_hash(const GB_HASH *hs, const char *key)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)