#ifndef FLUTTER_FML_NATIVE_LIBRARY_H_
#define FLUTTER_FML_NATIVE_LIBRARY_H_
#include "flutter/fml/build_config.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/memory/ref_ptr.h"
#if OS_WIN
#include <windows.h>
#endif
namespace fml {
class NativeLibrary : public fml::RefCountedThreadSafe<NativeLibrary> {
public:
#if OS_WIN
using Handle = HMODULE;
#else
using Handle = void*;
#endif
static fml::RefPtr<NativeLibrary> Create(const char* path);
static fml::RefPtr<NativeLibrary> CreateWithHandle(
Handle handle,
bool close_handle_when_done);
static fml::RefPtr<NativeLibrary> CreateForCurrentProcess();
const uint8_t* ResolveSymbol(const char* symbol);
private:
Handle handle_ = nullptr;
bool close_handle_ = true;
NativeLibrary(const char* path);
NativeLibrary(Handle handle, bool close_handle);
~NativeLibrary();
Handle GetHandle() const;
FML_DISALLOW_COPY_AND_ASSIGN(NativeLibrary);
FML_FRIEND_REF_COUNTED_THREAD_SAFE(NativeLibrary);
FML_FRIEND_MAKE_REF_COUNTED(NativeLibrary);
};
}
#endif