YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SharedLibraryFactory.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_OS_SHAREDLIBRARYFACTORY_H
7#define YARP_OS_SHAREDLIBRARYFACTORY_H
8
9#include <yarp/os/api.h>
10
13#include <yarp/os/Vocab.h>
14
15#include <string>
16
17
18namespace yarp::os {
19
27{
28public:
38 enum
39 {
41 STATUS_OK = yarp::os::createVocab32('o', 'k'),
42 STATUS_LIBRARY_NOT_FOUND = yarp::os::createVocab32('f', 'o', 'u', 'n'),
43 STATUS_LIBRARY_NOT_LOADED = yarp::os::createVocab32('l', 'o', 'a', 'd'),
44 STATUS_FACTORY_NOT_FOUND = yarp::os::createVocab32('f', 'a', 'c', 't'),
45 STATUS_FACTORY_NOT_FUNCTIONAL = yarp::os::createVocab32('r', 'u', 'n')
46 };
47
51 explicit SharedLibraryFactory();
52
59 SharedLibraryFactory(const char* dll_name,
60 const char* fn_name = nullptr);
61
66
74 bool open(const char* dll_name, const char* fn_name = nullptr);
75
81 bool isValid() const;
82
88 int getStatus() const;
89
95 std::string getError() const;
96
102 const SharedLibraryClassApi& getApi() const;
103
109 int getReferenceCount() const;
110
116 int addRef();
117
123 int removeRef();
124
130 std::string getName() const;
131
137 std::string getClassName() const;
138
144 std::string getBaseClassName() const;
145
155 bool useFactoryFunction(void* factory);
156
157private:
158 SharedLibrary lib;
159 int status;
161 int returnValue;
162 int rct; // FIXME Remove this reference counter and use a shared_ptr instead.
164 YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) className;
165 YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) baseClassName;
167};
168
169} // namespace yarp::os
170
171#endif // YARP_OS_SHAREDLIBRARYFACTORY_H
A wrapper for a named factory method in a named shared library.
virtual ~SharedLibraryFactory()
Destructor.
Low-level wrapper for loading shared libraries (DLLs) and accessing symbols within it.
DumpObj * factory(Bottle &obj)
Definition main.cpp:82
An interface to the operating system, including Port based communication.
constexpr yarp::conf::vocab32_t createVocab32(char a, char b=0, char c=0, char d=0)
Create a vocab from chars.
Definition Vocab.h:27
Collection of hooks for creating/destroying a plugin.
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition system.h:338
#define YARP_os_API
Definition api.h:18