Bayeux  3.4.1
Core Foundation library for SuperNEMO
library_loader.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2011-06-30
4  * Last modified : 2013-04-19
5  *
6  * Copyright (C) 2014 Ben Morgan <Ben.Morgan@warwick.ac.uk>
7  * Copyright (C) 2011-2013 Francois Mauger <mauger@lpccaen.in2p3.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or (at
12  * your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  * Description:
25  *
26  * A shared library loader facility (based on kwsys).
27  *
28  */
29 
30 #ifndef DATATOOLS_LIBRARY_LOADER_H
31 #define DATATOOLS_LIBRARY_LOADER_H
32 
33 // Standard Library:
34 #include <iostream>
35 #include <string>
36 #include <memory>
37 
38 // Third Party:
39 // - Boost:
40 #include <boost/cstdint.hpp>
41 #include <boost/utility.hpp>
42 
43 // This Project:
45 #include <datatools/bit_mask.h>
48 
49 namespace datatools {
50 
53  : boost::noncopyable
54  {
55  public:
57 
60 
62  explicit library_loader(const std::string & config_file_);
63 
66 
68  virtual ~library_loader();
69 
71  bool has(const std::string & name_) const;
72 
74  bool is_loaded(const std::string & name_) const;
75 
77  int registration(const std::string & name_,
78  const std::string & directory_ = "",
79  const std::string & filename_ = "",
80  const std::string & full_path_ = "",
81  const std::string & version_ = "",
82  bool autoload_ = false);
83 
85 
94  int load(const std::string & name_,
95  const std::string & directory_ = "",
96  const std::string & filename_ = "",
97  const std::string & full_path_ = "",
98  const std::string & version_ = "");
99 
101  int close(const std::string & name_);
102 
104  int close_all();
105 
107  void print(std::ostream & out_ = std::clog) const;
108 
110  symbol_ptr get_symbol_address(const std::string & name_,
111  const std::string & symbol_);
112 
113  protected:
114 
116  void _init();
117 
118  private:
119 
120  datatools::multi_properties _config_;
121  class LibraryCollection;
122  std::unique_ptr<LibraryCollection> _lib_entries_;
123 
124  };
125 
126 } // end of namespace datatools
127 
128 #endif // DATATOOLS_LIBRARY_LOADER_H
129 
130 // Local Variables: --
131 // mode: c++ --
132 // c-file-style: "gnu" --
133 // tab-width: 2 --
134 // End: --
library_loader()
Default constructor.
A container of mapped properties objects.
Definition: multi_properties.h:99
void print(std::ostream &out_=std::clog) const
Smart print libraries configured/loaded to supplied stream.
int load(const std::string &name_, const std::string &directory_="", const std::string &filename_="", const std::string &full_path_="", const std::string &version_="")
Load a DLL.
symbol_ptr get_symbol_address(const std::string &name_, const std::string &symbol_)
Return pointer to symbol in named library.
virtual ~library_loader()
Destructor.
bool is_loaded(const std::string &name_) const
Return true if the DLL with name is loaded.
int close(const std::string &name_)
Close a DLL.
void _init()
Protected initialization.
int registration(const std::string &name_, const std::string &directory_="", const std::string &filename_="", const std::string &full_path_="", const std::string &version_="", bool autoload_=false)
Register a DLL.
void(* SymbolPointer)()
Definition: DynamicLoader.h:76
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
datatools::detail::DynamicLoader::SymbolPointer symbol_ptr
Definition: library_loader.h:56
int close_all()
Close all DLLs.
A DLL loader class.
Definition: library_loader.h:52
Describe the datatools API configuration.
bool has(const std::string &name_) const
Return true if the DLL with name is setup.