summaryrefslogtreecommitdiffstats
path: root/fastos/src/vespa/fastos/unix_dynamiclibrary.h
blob: cf0b39e6abf2dd44c217a798818b6390a41ba808 (plain) (blame)
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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
*************************************************************-*C++-*-
* @author Eyvind Bernhardsen
* @date   Creation date: 2003-07-02
* @file
* Class definitions for FastOS_Unix_DynamicLibrary
*********************************************************************/



#pragma once


#include <vespa/fastos/types.h>

class FastOS_UNIX_DynamicLibrary : public FastOS_DynamicLibraryInterface
{
private:
    FastOS_UNIX_DynamicLibrary(const FastOS_UNIX_DynamicLibrary&);
    FastOS_UNIX_DynamicLibrary& operator=(const FastOS_UNIX_DynamicLibrary&);

    void        *_handle;
    std::string  _libname;

public:
    FastOS_UNIX_DynamicLibrary(const char *libname = NULL);
    ~FastOS_UNIX_DynamicLibrary();

    void SetLibName(const char *libname);
    bool NormalizeLibName(void);
    bool Close() override;
    bool Open(const char *libname = NULL) override;
    void * GetSymbol(const char *symbol) const override;
    std::string GetLastErrorString() const;
    const char * GetLibName() const { return _libname.c_str(); }
    bool IsOpen()             const override { return (_handle != NULL); }
};