YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SharedLibraryClassFactory.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_SHAREDLIBRARYCLASSFACTORY_H
7#define YARP_OS_SHAREDLIBRARYCLASSFACTORY_H
8
10
11namespace yarp::os {
12
19template <class T>
21{
22public:
24
25 SharedLibraryClassFactory(const char* dll_name, const char* fn_name = nullptr) :
26 SharedLibraryFactory(dll_name, fn_name)
27 {
28 }
29
30 T* create()
31 {
32 if (!isValid()) {
33 return nullptr;
34 }
35 return (T*)getApi().create();
36 }
37
38 void destroy(T* obj) const
39 {
40 if (!isValid()) {
41 return;
42 }
43 getApi().destroy(obj);
44 }
45};
46
47} // namespace yarp::os
48
49#endif // YARP_OS_SHAREDLIBRARYCLASSFACTORY_H
A type-safe wrapper for SharedLibraryFactory, committing to creation/destruction of instances of a pa...
SharedLibraryClassFactory(const char *dll_name, const char *fn_name=nullptr)
A wrapper for a named factory method in a named shared library.
bool isValid() const
Check if factory is configured and present.
const SharedLibraryClassApi & getApi() const
Get the factory API, which has creation/deletion methods.
An interface to the operating system, including Port based communication.