Bayeux  3.4.1
Core Foundation library for SuperNEMO
bayeux_library.h
Go to the documentation of this file.
1 // bayeux/detail/bayeux_library.h - Implementation of Bayeux Library System Singleton
2 //
3 // Copyright (c) 2017 by Francois Mauger <mauger@lpccaen.in2p3.fr>
4 // Copyright (c) 2017 Université de Caen
5 //
6 // This file is part of Bayeux.
7 //
8 // Bayeux is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // Bayeux is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Bayeux. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef BAYEUX_DETAIL_BAYEUX_LIBRARY_H
22 #define BAYEUX_DETAIL_BAYEUX_LIBRARY_H
23 
24 // Standard library
25 #include <string>
26 #include <iostream>
27 #include <fstream>
28 #include <stdexcept>
29 
30 // Third party:
31 #include <boost/core/noncopyable.hpp>
32 
33 // This project:
34 #include <datatools/exception.h>
35 #include <datatools/logger.h>
37 
38 namespace bayeux {
39 
40  namespace detail {
41 
42  // Singleton to automate Bayeux library embedded material (services...)
44  : private boost::noncopyable
45  {
46  public:
47 
49  static const std::string & bx_resource_db_name();
50 
52  static const std::string & bx_resource_resolver_name();
53 
54  // Return the logging priority set from the environment
56 
59 
62 
65 
67  bool is_initialized() const;
68 
70  void initialize();
71 
73  void shutdown();
74 
76  static bool is_instantiated();
77 
79  static bayeux_library & instance();
80 
82  static const bayeux_library & const_instance();
83 
85  static bayeux_library & instantiate();
86 
87  private:
88 
89  void _libinfo_registration_();
90 
91  void _libinfo_deregistration_();
92 
93  void _initialize_urn_services_();
94 
95  void _shutdown_urn_services_();
96 
97  private:
98 
99  // Management:
100  bool _initialized_ = false;
101  datatools::logger::priority _logging_;
102 
103  // Working internal data:
104  datatools::service_manager _services_;
105 
106  // Singleton:
107  static bayeux_library * _instance_;
108 
109  };
110 
111  } // end of namespace detail
112 
113 } // end of namespace bayeux
114 
115 #endif // BAYEUX_DETAIL_BAYEUX_LIBRARY_H
116 
117 // Local Variables: --
118 // mode: c++ --
119 // c-file-style: "gnu" --
120 // tab-width: 2 --
121 // End: --
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
bayeux_library()
Default constructor.
static datatools::logger::priority process_logging_env()
Utility macros for exception handling.
static bool is_instantiated()
Check if the Bayeux system singleton is instantiated.
bool is_initialized() const
Check initialization flag.
static const std::string & bx_resource_db_name()
Return the name of the Bayeux library's URN database service.
static bayeux_library & instance()
Return a mutable reference to the Bayeux system singleton instance.
datatools::logger::priority get_logging() const
Return the logging priority.
static bayeux_library & instantiate()
Instantiate the Vire system singleton.
Utilities for logging information.
static const bayeux_library & const_instance()
Return a non-mutable reference to the Bayeux system singleton instance.
Definition: bayeux_library.h:43
Top-level namespace of the Bayeux library.
Definition: bayeux.h:42
static const std::string & bx_resource_resolver_name()
Return the name of the Bayeux library's URN to resource path resolver service.
void initialize()
Initialize.
Service management class.
Definition: service_manager.h:57