1 /* === S Y N F I G ========================================================= */ 2 /*! \file tool/definitions.cpp 3 ** \brief Implementation of the definitions header file for synfig tool 4 ** 5 ** $Id$ 6 ** 7 ** \legal 8 ** Copyright (c) 2014 Diego Barrios Romero 9 ** 10 ** This package is free software; you can redistribute it and/or 11 ** modify it under the terms of the GNU General Public License as 12 ** published by the Free Software Foundation; either version 2 of 13 ** the License, or (at your option) any later version. 14 ** 15 ** This package is distributed in the hope that it will be useful, 16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 ** General Public License for more details. 19 ** \endlegal 20 */ 21 /* ========================================================================= */ 22 23 #include "definitions.h" 24 #include "synfigtoolexception.h" 25 26 #include <synfig/localization.h> 27 #include <synfig/general.h> 28 29 #include <synfig/main.h> 30 31 boost::shared_ptr<SynfigToolGeneralOptions> SynfigToolGeneralOptions::_instance; 32 create_singleton_instance(const char * argv0)33void SynfigToolGeneralOptions::create_singleton_instance(const char* argv0) 34 { 35 _instance = boost::shared_ptr<SynfigToolGeneralOptions>( 36 new SynfigToolGeneralOptions(argv0)); 37 } 38 instance()39SynfigToolGeneralOptions* SynfigToolGeneralOptions::instance() 40 { 41 if (_instance.get() == NULL) 42 { 43 throw SynfigToolException(SYNFIGTOOL_UNKNOWNERROR, 44 _("Uninitialized Synfig tool general options singleton.")); 45 } 46 47 return _instance.get(); 48 } 49 SynfigToolGeneralOptions(const char * argv0)50SynfigToolGeneralOptions::SynfigToolGeneralOptions(const char* argv0) 51 { 52 _binary_path = synfig::get_binary_path(argv0); 53 54 _verbosity = 0; 55 _should_be_quiet = false; 56 _should_print_benchmarks = false; 57 _threads = 1; 58 } 59 get_binary_path() const60boost::filesystem::path SynfigToolGeneralOptions::get_binary_path() const 61 { 62 return _binary_path; 63 } 64 get_threads() const65size_t SynfigToolGeneralOptions::get_threads() const 66 { 67 return _threads; 68 } 69 set_threads(size_t threads)70void SynfigToolGeneralOptions::set_threads(size_t threads) 71 { 72 _threads = threads; 73 } 74 get_verbosity() const75int SynfigToolGeneralOptions::get_verbosity() const 76 { 77 return _verbosity; 78 } 79 set_verbosity(int verbosity)80void SynfigToolGeneralOptions::set_verbosity(int verbosity) 81 { 82 _verbosity = verbosity; 83 } 84 should_be_quiet() const85bool SynfigToolGeneralOptions::should_be_quiet() const 86 { 87 return _should_be_quiet; 88 } 89 set_should_be_quiet(bool be_quiet)90void SynfigToolGeneralOptions::set_should_be_quiet(bool be_quiet) 91 { 92 _should_be_quiet = be_quiet; 93 } 94 should_print_benchmarks() const95bool SynfigToolGeneralOptions::should_print_benchmarks() const 96 { 97 return _should_print_benchmarks; 98 } 99 set_should_print_benchmarks(bool print_benchmarks)100void SynfigToolGeneralOptions::set_should_print_benchmarks(bool print_benchmarks) 101 { 102 _should_print_benchmarks = print_benchmarks; 103 } 104