Falaise  4.0.1
SuperNEMO Software Toolkit
falaise_sys.h
Go to the documentation of this file.
1 //! \file falaise/detail/falaise_sys.h
2 //! \brief Provide Falaise library system singleton
3 //! \details
4 //
5 // Copyright (c) 2017 by Francois Mauger <mauger@lpccaen.in2p3.fr>
6 // Copyright (c) 2017 by Université de Caen Normandie
7 //
8 // This file is part of Falaise.
9 //
10 // Falaise is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Falaise 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
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Falaise. If not, see <http://www.gnu.org/licenses/>.
22 
23 #ifndef FALAISE_DETAIL_FALAISE_SYS_H
24 #define FALAISE_DETAIL_FALAISE_SYS_H
25 
26 // Standard Library
27 // #include <string>
28 
29 // Third party:
30 #include <boost/core/noncopyable.hpp>
31 
32 // This project:
33 #include <datatools/logger.h>
35 
36 namespace falaise {
37 
38 namespace detail {
39 
40 //! \brief Falaise system singleton
41 class falaise_sys : private boost::noncopyable {
42  public:
43  /// Return the name of the Falaise library URN database service for supported setups (geometry,
44  /// simulation...)
45  static const std::string& fl_setup_db_name();
46 
47  /// Return the name of the Falaise library URN to resource path resolver service
48  static const std::string& fl_resource_resolver_name();
49 
50  /// Extract the verbosity from the FALAISE_SYS_LOGGING environment variable (if any)
52 
53  /// Default constructor
54  falaise_sys();
55 
56  /// Destructor
57  virtual ~falaise_sys();
58 
59  /// Return the logging priority
61 
62  /// Check initialization flag
63  bool is_initialized() const;
64 
65  /// Initialize
66  void initialize();
67 
68  /// Shutdown
69  void shutdown();
70 
71  /// Return a mutable reference to the embedded service manager
73 
74  /// Return a non mutable reference to the embedded service manager
76 
77  /// Check if the Falaise system singleton is instantiated
78  static bool is_instantiated();
79 
80  /// Return a mutable reference to the Falaise system singleton instance
81  static falaise_sys& instance();
82 
83  /// Return a non-mutable reference to the Falaise system singleton instance
84  static const falaise_sys& const_instance();
85 
86  /// Instantiate the Falaise system singleton
87  static falaise_sys& instantiate();
88 
89  private:
90  void _libinfo_registration_();
91 
92  void _libinfo_deregistration_();
93 
94  void _initialize_urn_services_();
95 
96  void _shutdown_urn_services_();
97 
98  private:
99  // Management:
100  bool _initialized_ = false; //!< Initialization flag
101  datatools::logger::priority _logging_; //!< Logging priority threshold
102 
103  // Working internal data:
104  datatools::service_manager _services_; //!< Embedded services
105 
106  // Singleton:
107  static falaise_sys* _instance_; //!< Falaise system singleton handle
108 };
109 
110 } // end of namespace detail
111 
112 } // namespace falaise
113 
114 #endif // FALAISE_DETAIL_FALAISE_SYS_H
115 
116 // Local Variables: --
117 // mode: c++ --
118 // c-file-style: "gnu" --
119 // tab-width: 2 --
120 // End: --
static bool is_instantiated()
Check if the Falaise system singleton is instantiated.
const datatools::service_manager & get_services() const
Return a non mutable reference to the embedded service manager.
static falaise_sys & instantiate()
Instantiate the Falaise system singleton.
static datatools::logger::priority process_logging_env()
Extract the verbosity from the FALAISE_SYS_LOGGING environment variable (if any)
virtual ~falaise_sys()
Destructor.
datatools::service_manager & grab_services()
Return a mutable reference to the embedded service manager.
void initialize()
Initialize.
static const std::string & fl_resource_resolver_name()
Return the name of the Falaise library URN to resource path resolver service.
Definition: metadata_utils.h:35
Falaise system singleton.
Definition: falaise_sys.h:41
static falaise_sys & instance()
Return a mutable reference to the Falaise system singleton instance.
static const falaise_sys & const_instance()
Return a non-mutable reference to the Falaise system singleton instance.
falaise_sys()
Default constructor.
bool is_initialized() const
Check initialization flag.
static const std::string & fl_setup_db_name()
datatools::logger::priority get_logging() const
Return the logging priority.