From 4ef5bb7efa72c0d9a016f270b5a56e8302f6e209 Mon Sep 17 00:00:00 2001 From: guigues Date: Mon, 16 Feb 2009 09:47:02 +0000 Subject: [PATCH] *** empty log message *** --- appli/gimmick/gimmick.ggo | 1 + appli/gimmick/gimmick_ggo.c | 23 +++++++++- appli/gimmick/gimmick_ggo.h | 4 ++ appli/gimmick/main.cxx | 5 +- src2/creaImageIOGimmick.cpp | 66 +++++++++++++++------------ src2/creaImageIOGimmick.h | 8 ++-- src2/creaImageIOSQLiteTreeHandler.cpp | 2 +- src2/creaImageIOSystem.h | 2 +- 8 files changed, 73 insertions(+), 38 deletions(-) diff --git a/appli/gimmick/gimmick.ggo b/appli/gimmick/gimmick.ggo index d67d7ee..f698d5b 100644 --- a/appli/gimmick/gimmick.ggo +++ b/appli/gimmick/gimmick.ggo @@ -13,6 +13,7 @@ option "recurse" r "Recurse into sub-directories" flag off dependon="dir" section "OPTIONS" option "verbose" v "Verbosity level" int default="1" optional +option "debug" D "Debug messages level" int default="0" optional #package "" # version "" diff --git a/appli/gimmick/gimmick_ggo.c b/appli/gimmick/gimmick_ggo.c index 6f5e74d..72e99f4 100644 --- a/appli/gimmick/gimmick_ggo.c +++ b/appli/gimmick/gimmick_ggo.c @@ -37,6 +37,7 @@ const char *gengetopt_args_info_help[] = { " -r, --recurse Recurse into sub-directories (default=off)", "\nOPTIONS:", " -v, --verbose=INT Verbosity level (default=`1')", + " -D, --debug=INT Debug messages level (default=`0')", 0 }; @@ -95,6 +96,7 @@ void clear_given (struct gengetopt_args_info *args_info) args_info->dir_given = 0 ; args_info->recurse_given = 0 ; args_info->verbose_given = 0 ; + args_info->debug_given = 0 ; } static @@ -108,6 +110,8 @@ void clear_args (struct gengetopt_args_info *args_info) args_info->recurse_flag = 0; args_info->verbose_arg = 1; args_info->verbose_orig = NULL; + args_info->debug_arg = 0; + args_info->debug_orig = NULL; } @@ -123,6 +127,7 @@ void init_args_info(struct gengetopt_args_info *args_info) args_info->dir_help = gengetopt_args_info_help[5] ; args_info->recurse_help = gengetopt_args_info_help[6] ; args_info->verbose_help = gengetopt_args_info_help[8] ; + args_info->debug_help = gengetopt_args_info_help[9] ; } @@ -209,6 +214,7 @@ cmdline_parser_release (struct gengetopt_args_info *args_info) free_string_field (&(args_info->dir_arg)); free_string_field (&(args_info->dir_orig)); free_string_field (&(args_info->verbose_orig)); + free_string_field (&(args_info->debug_orig)); for (i = 0; i < args_info->inputs_num; ++i) @@ -257,6 +263,8 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) write_into_file(outfile, "recurse", 0, 0 ); if (args_info->verbose_given) write_into_file(outfile, "verbose", args_info->verbose_orig, 0); + if (args_info->debug_given) + write_into_file(outfile, "debug", args_info->debug_orig, 0); i = EXIT_SUCCESS; @@ -540,10 +548,11 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf { "dir", 1, NULL, 'd' }, { "recurse", 0, NULL, 'r' }, { "verbose", 1, NULL, 'v' }, + { "debug", 1, NULL, 'D' }, { NULL, 0, NULL, 0 } }; - c = getopt_long (argc, argv, "hVpf:d:rv:", long_options, &option_index); + c = getopt_long (argc, argv, "hVpf:d:rv:D:", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ @@ -615,6 +624,18 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf goto failure; break; + case 'D': /* Debug messages level. */ + + + if (update_arg( (void *)&(args_info->debug_arg), + &(args_info->debug_orig), &(args_info->debug_given), + &(local_args_info.debug_given), optarg, 0, "0", ARG_INT, + check_ambiguity, override, 0, 0, + "debug", 'D', + additional_error)) + goto failure; + + break; case 0: /* Long option with no short option */ case '?': /* Invalid option. */ diff --git a/appli/gimmick/gimmick_ggo.h b/appli/gimmick/gimmick_ggo.h index db36397..f788976 100644 --- a/appli/gimmick/gimmick_ggo.h +++ b/appli/gimmick/gimmick_ggo.h @@ -47,6 +47,9 @@ struct gengetopt_args_info int verbose_arg; /**< @brief Verbosity level (default='1'). */ char * verbose_orig; /**< @brief Verbosity level original value given at command line. */ const char *verbose_help; /**< @brief Verbosity level help description. */ + int debug_arg; /**< @brief Debug messages level (default='0'). */ + char * debug_orig; /**< @brief Debug messages level original value given at command line. */ + const char *debug_help; /**< @brief Debug messages level help description. */ unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int version_given ; /**< @brief Whether version was given. */ @@ -55,6 +58,7 @@ struct gengetopt_args_info unsigned int dir_given ; /**< @brief Whether dir was given. */ unsigned int recurse_given ; /**< @brief Whether recurse was given. */ unsigned int verbose_given ; /**< @brief Whether verbose was given. */ + unsigned int debug_given ; /**< @brief Whether debug was given. */ char **inputs ; /**< @brief unamed options (options without names) */ unsigned inputs_num ; /**< @brief unamed options number */ diff --git a/appli/gimmick/main.cxx b/appli/gimmick/main.cxx index 516dfd4..0a3a810 100644 --- a/appli/gimmick/main.cxx +++ b/appli/gimmick/main.cxx @@ -9,6 +9,7 @@ int main(int argc, char* argv[]) creaImageIO::Gimmick g; if (args.verbose_given) g.SetMessageLevel(args.verbose_arg); + if (args.debug_given) g.SetDebugMessageLevel(args.debug_arg); bool something_to_do = args.dir_given | @@ -23,7 +24,7 @@ int main(int argc, char* argv[]) try { - if (!g.Initialize()) return 1; + g.Initialize(); if (args.file_given) { @@ -40,7 +41,7 @@ int main(int argc, char* argv[]) g.PrintLocalDatabase(); } - if (!g.Finalize()) return 1; + g.Finalize(); } catch (crea::Exception e) { diff --git a/src2/creaImageIOGimmick.cpp b/src2/creaImageIOGimmick.cpp index a9f7264..64099e5 100644 --- a/src2/creaImageIOGimmick.cpp +++ b/src2/creaImageIOGimmick.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -14,6 +14,8 @@ namespace creaImageIO { crea::MessageManager::RegisterMessageType("Gimmick!", "Gimmick",1); + crea::MessageManager::RegisterMessageType("Gimmick! DEBUG", + "Gimmick",0); } //============================================================== @@ -28,10 +30,10 @@ namespace creaImageIO //============================================================== - bool Gimmick::Initialize() + void Gimmick::Initialize() { // Create the UserSettings dir if does not exist - if (!CreateUserSettingsDirectory()) return false; + CreateUserSettingsDirectory(); // Sets the current directory to the home dir mCurrentDirectory = GetHomeDirectory(); @@ -40,44 +42,38 @@ namespace creaImageIO // Create or open local database if (! boost::filesystem::exists( GetLocalDatabasePath() ) ) { - creaMessage("Gimmick!",1, - "[Gimmick!] Local database '"<GetTree().GetDescriptor().CreateDefault(); if ( ! mLocalDatabase->Create(true) ) { - creaMessage("Gimmick!",1, - "[Gimmick!] !! ERROR CREATING '"<SetAttribute(0,"Name","Local database"); } else { /// Open and test it - creaMessage("Gimmick!",1, - "[Gimmick!] Opening local database '" - <Open(true) ) { - creaMessage("Gimmick!",1, - "[Gimmick!] !! ERROR OPENING '"<