Fawkes API Fawkes Development Version
module_manager.h
1
2/***************************************************************************
3 * module_manager.h - manager for modules (i.e. shared objects)
4 *
5 * Created: Wed Aug 23 16:15:02 2006
6 * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program 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 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _UTILS_SYSTEM_DYNAMIC_MODULE_MODULE_MANAGER_H_
25#define _UTILS_SYSTEM_DYNAMIC_MODULE_MODULE_MANAGER_H_
26
27#include <utils/system/dynamic_module/module.h>
28
29#include <map>
30#include <string>
31
32namespace fawkes {
33
34class Module;
35class Mutex;
36
38{
39public:
40 ModuleManager(const char * module_base_dir,
42 virtual ~ModuleManager();
43
44 virtual Module *open_module(const char *filename);
45 virtual void close_module(Module *module);
46 virtual void close_module(const char *filename);
47 virtual bool module_opened(const char *filename);
48 virtual Module *get_module(const char *filename);
49
50 virtual const char *get_module_file_extension();
51
52 void set_open_flags(Module::ModuleFlags open_flags);
53
54private:
55 std::map<std::string, Module *> modules_;
56
57 const char * module_base_dir_;
58 Mutex * mutex_;
59 Module::ModuleFlags open_flags_;
60};
61
62} // end namespace fawkes
63
64#endif
Dynamic module manager.
virtual ~ModuleManager()
Destructor.
virtual const char * get_module_file_extension()
Get the file extension for the current module type.
virtual void close_module(Module *module)
Close a module by Module instance.
virtual Module * get_module(const char *filename)
Get a module if opened.
virtual Module * open_module(const char *filename)
Open a module.
ModuleManager(const char *module_base_dir, Module::ModuleFlags open_flags=Module::MODULE_FLAGS_DEFAULT)
Constructor of NetworkManagerTemplate.
void set_open_flags(Module::ModuleFlags open_flags)
Set flags to open modules with.
virtual bool module_opened(const char *filename)
Check if the module is already opened.
Dynamic module loader for Linux, FreeBSD, and MacOS X.
Definition: module.h:41
ModuleFlags
Flags for the loading process.
Definition: module.h:44
@ MODULE_FLAGS_DEFAULT
Default flags, these are MODULE_BIND_GLOBAL, MODULE_BIND_NOW and MODULE_BIND_DEEP.
Definition: module.h:46
Mutex mutual exclusion lock.
Definition: mutex.h:33
Fawkes library namespace.