Bayeux  3.4.1
Core Foundation library for SuperNEMO
functor_factory.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2015 by François Mauger <mauger@lpccaen.in2p3.fr>
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 MYGSL_FUNCTOR_FACTORY_H
22 #define MYGSL_FUNCTOR_FACTORY_H
23 
24 // This project:
25 #include <mygsl/i_unary_function.h>
26 
27 // Third party:
28 // - Boost:
29 #include <boost/scoped_ptr.hpp>
30 // - Bayeux/datatools :
31 #include <datatools/i_tree_dump.h>
32 
33 namespace mygsl {
34 
38  {
39  public:
40 
46  };
47 
49  bool is_locked() const;
50 
52  void lock();
53 
55  void unlock();
56 
59 
61  functor_factory(uint32_t flags_);
62 
64  virtual ~functor_factory();
65 
67  void create(unary_function_handle_type & handle_,
68  const std::string & functor_id_);
69 
71  void create(unary_function_handle_type & handle_,
72  const std::string & functor_id_,
73  const datatools::properties & functor_config_);
74 
76  void create(unary_function_handle_type & handle_,
77  const std::string & functor_id_,
78  const datatools::properties & functor_config_,
79  unary_function_dict_type & functors_);
80 
82  virtual void tree_dump(std::ostream & out_ = std::clog,
83  const std::string & title_ = "",
84  const std::string & indent_ = "",
85  bool inherit_ = false) const;
86 
87  protected:
88 
89  i_unary_function * _allocate(const std::string & functor_id_);
90 
91  virtual void _at_lock();
92 
93  virtual void _at_unlock();
94 
95  void _basic_construct(uint32_t flags_);
96 
97  void _basic_destroy();
98 
99  private:
100 
101  bool _locked_;
102  boost::scoped_ptr<i_unary_function::factory_register_type> _factory_register_;
103 
104  };
105 
106 } // end of namespace mygsl
107 
108 #endif // MYGSL_FUNCTOR_FACTORY_H
109 
110 /* Local Variables: */
111 /* mode: c++ */
112 /* coding: utf-8 */
113 /* End: */
virtual void _at_lock()
functor_factory()
Default constructor.
construct_flags
construct flags
Definition: functor_factory.h:42
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
Activate verbosity of the embedded factory.
Definition: functor_factory.h:45
Do not preload factories from system register.
Definition: functor_factory.h:44
virtual void _at_unlock()
Factory of functors.
Definition: functor_factory.h:36
void unlock()
Unlock the factory.
virtual ~functor_factory()
Destructor.
Templatized handle class that wraps a Boost shared pointer and behaves like a reference.
Definition: handle.h:114
void _basic_construct(uint32_t flags_)
No flags.
Definition: functor_factory.h:43
Abstract interface for unary functions : R -> R.
Definition: i_unary_function.h:44
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
bool is_locked() const
Check lock flag.
void create(unary_function_handle_type &handle_, const std::string &functor_id_)
Create a functor without initialization.
std::map< std::string, unary_function_handle_type > unary_function_dict_type
Alias for dictionary of handles to unary function objects.
Definition: unary_function_utils.h:30
void lock()
Lock the factory.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart dump.
i_unary_function * _allocate(const std::string &functor_id_)
A dictionary of arbitrary properties.
Definition: properties.h:125