Plug more leaks (in the test, not the core)
[gnash.git] / libbase / extension.h
blobc646ea452812373ef4871498bf656ffb3f576d1b
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
3 // Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef GNASH_EXTENSION_H
20 #define GNASH_EXTENSION_H
22 #include <map>
23 #include <vector>
24 #include <string>
25 #include <boost/tokenizer.hpp>
26 #include "sharedlib.h"
27 #include "dsodefs.h"
30 namespace gnash
33 class DSOEXPORT Extension
35 typedef boost::char_separator<char> Sep;
36 typedef boost::tokenizer< Sep > Tok;
38 public:
40 Extension();
42 Extension(const std::string& dir);
44 ~Extension();
46 /// Scan a directory for Gnash modules
47 bool scanDir();
49 /// Scan the given directory for modules
51 /// @param dir The directory to scan.
52 bool scanDir(const std::string& dir);
54 /// Scan the plugins directory and attach any found modules to
55 /// the given object.
57 /// @param where The as_object to which the modules should be
58 /// attached (usually the global object)
59 bool scanAndLoad(as_object &where);
61 /// Scan the given directory and attach any found modules to
62 /// the given object.
64 /// @param where The as_object to which the modules should be
65 /// attached (usually the global object)
66 /// @param dir A directory to scan.
67 bool scanAndLoad(const std::string& dir, as_object &where);
69 // open a module, initialize the module within Gnash. Known function name.
70 bool initModuleWithFunc(const std::string& module, const std::string& func, as_object &obj);
71 bool initNewObject(as_object &obj);
72 void dumpModules();
73 protected:
75 /// Initialize the named module within Gnash
77 /// @param symbol The name of the module to find and
78 /// initialize.
79 /// @param obj The object to attach the module to.
80 bool initModule(const std::string& module, as_object &obj);
82 /// A list of modules
83 std::vector<std::string> _modules;
85 /// A map of loaded modules
86 std::map<std::string, SharedLib *> _plugins;
88 /// The default directory to search for modules.
89 std::string _pluginsdir;
92 } // end of gnash namespace
94 // GNASH_EXTENSION_H
95 #endif
97 // Local Variables:
98 // mode: C++
99 // indent-tabs-mode: t
100 // End: