1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
// =================================================================================================
// Copyright Adobe
// Copyright 2011 Adobe
// All Rights Reserved
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it.
// =================================================================================================
#ifndef MODULE_H
#define MODULE_H
#include "ModuleUtils.h"
#include "PluginManager.h"
namespace XMP_PLUGIN
{
/** @class Module
* @brief Manages module's loading and unloading.
*/
class Module
{
public:
Module( std::string & path ):
mPath( path ), mHandle( NULL ), mPluginAPIs( NULL ), mLoaded( kModuleNotLoaded ) { }
~Module() { unload(); }
inline OS_ModuleRef getHandle() const { return mHandle; }
inline const std::string & getPath() const { return mPath; }
/**
* Returns pluginAPI. It loads the module if not already loaded.
* @return pluginAPI.
*/
PluginAPIRef getPluginAPIs();
/**
* It loads the module if not already loaded.
* @return true if module is loaded successfully otherwise returns false.
*/
bool load();
/**
* Unloads the module if it is loaded.
* @return Void.
*/
void unload();
private:
/************************************************************************/
/* Loads the module without acquiring the lock */
/************************************************************************/
bool loadInternal();
/************************************************************************/
/* Unloads the module without acquiring the lock */
/************************************************************************/
void unloadInternal();
typedef enum
{
kModuleNotLoaded = 0,
kModuleLoaded,
kModuleErrorOnLoad
} LoadStatus;
std::string mPath;
OS_ModuleRef mHandle;
PluginAPIRef mPluginAPIs;
LoadStatus mLoaded;
XMP_ReadWriteLock mLoadingLock;
};
} //namespace XMP_PLUGIN
#endif //MODULE_H
|