WModuleLoader.h 2.23 KB
Newer Older
schurade's avatar
schurade committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

25 26
#ifndef WMODULELOADER_H
#define WMODULELOADER_H
schurade's avatar
schurade committed
27

28
#include <set>
29 30
#include <string>
#include <vector>
31

32
#include <boost/filesystem.hpp>
33

34
#include "../common/WSharedLib.h"
35 36 37
#include "../common/WSharedAssociativeContainer.h"
#include "../common/WLogger.h"
#include "WModule.h"
schurade's avatar
schurade committed
38 39

/**
40
 * Loads module prototypes from shared objects in a given directory and injects it into the module factory.
schurade's avatar
schurade committed
41
 */
42
class WModuleLoader
schurade's avatar
schurade committed
43 44
{
public:
45

46
	/**
47 48
	 * Constructor. It does not load any files. Use load to do this.
	 *
49 50
     */
    explicit WModuleLoader();
51

52 53 54
	/**
	 * Destructor, closes all handles to shared libraries.
	 */
55 56
    ~WModuleLoader();

57 58
	/**
	 * Load the module prototypes from the shared libraries.
59
	 *
60 61
	 * \param ticket A write ticket to a shared container.
	 */
62
    void load( WSharedAssociativeContainer< std::set< boost::shared_ptr< WModule > > >::WriteTicket ticket );
schurade's avatar
schurade committed
63 64 65

private:

66 67 68 69 70 71 72 73
    /**
     * All the loaded shared libraries. Get freed on destruction. So do NOT free this instance while the libs are used.
     */
    std::vector< WSharedLib > m_libs;

    /**
     * Path to the modules. This is used during load to find all libMODULENAME.{so,dll,dylib} files.
     */
74
    boost::filesystem::path m_path;
75
};
76

77
#endif  // WMODULELOADER_H