Bayeux  3.4.1
Core Foundation library for SuperNEMO
context_service.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2011-06-07
4  * Last modified : 2015-09-22
5  *
6  * Copyright (C) 2011-2015 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program 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 (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * Context service. A service that provides a general purpose container
26  * as the repository for transcient and sharable data during the
27  * lifetime of a data processing chain.
28  *
29  */
30 
31 #ifndef DPP_CONTEXT_SERVICE_H
32 #define DPP_CONTEXT_SERVICE_H 1
33 
34 // Standard library:
35 #include <iostream>
36 #include <string>
37 
38 // Third party:
39 // - Bayeux/datatools:
40 #include <datatools/base_service.h>
42 
43 // This project:
44 #include <dpp/dpp_config.h>
45 
46 namespace datatools {
47  class multi_properties;
48 }
49 
50 namespace dpp {
51 
55  {
56  public:
57 
59  const datatools::multi_properties & get_store() const;
60 
63 
66 
69 
71  virtual bool is_initialized() const;
72 
74  virtual int initialize(const datatools::properties & config_,
75  datatools::service_dict_type & service_dict_);
76 
78  virtual int reset();
79 
82 
84  virtual ~context_service();
85 
87  virtual void tree_dump(std::ostream & out_ = std::clog,
88  const std::string & title_ = "",
89  const std::string & indent_ = "",
90  bool inherit_ = false) const;
91 
92  private:
93 
94  // Management:
95  bool _initialized_;
96 
97  // Configuration:
98  std::string _load_filename_;
99  std::string _store_filename_;
100  std::string _backup_filename_;
101 
102  // Internal data:
103  datatools::multi_properties * _store_;
104 
105  // Registration :
107 
108  };
109 
110 } // end of namespace dpp
111 
112 #endif // DPP_CONTEXT_SERVICE_H
113 
114 // Local Variables: --
115 // mode: c++ --
116 // c-file-style: "gnu" --
117 // tab-width: 2 --
118 // End: --
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
virtual int initialize(const datatools::properties &config_, datatools::service_dict_type &service_dict_)
Initialize.
A container of mapped properties objects.
Definition: multi_properties.h:99
const datatools::multi_properties & get_store() const
Return a const reference to the internal store.
virtual int reset()
Reset.
Top-level namespace of the Bayeux/dpp module library.
Definition: base_module.h:56
A service that handles a context object store implemented as a datatools::multi_properties container.
Definition: context_service.h:53
std::map< std::string, service_entry_ptr > service_dict_type
Type alias for a flat dictionary of service entries.
Definition: service_tools.h:196
The base service class.
Definition: base_service.h:68
virtual ~context_service()
Destructor.
context_service()
Default constructor.
#define DATATOOLS_SERVICE_REGISTRATION_INTERFACE(SERVICE_CLASS_NAME)
Definition: base_service.h:152
header file
const datatools::multi_properties & operator()() const
Return a const reference to the internal store.
datatools::multi_properties & grab_store()
Return a mutable reference to the internal store.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
virtual bool is_initialized() const
Check initialization.
A dictionary of arbitrary properties.
Definition: properties.h:125