RobotTestingFramework 2.0.1
Robot Testing Framework
Loading...
Searching...
No Matches
SharedLibraryClassFactory.h
Go to the documentation of this file.
1/*
2 * Robot Testing Framework
3 *
4 * Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21
22#ifndef ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYCLASSFACTORY_H
23#define ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYCLASSFACTORY_H
24
26
27namespace shlibpp {
28template <class T>
29class SharedLibraryClassFactory;
30}
31
32
41template <class T>
43{
44public:
48
49 SharedLibraryClassFactory(const char* dll_name, const char* fn_name = 0 /*nullptr*/) :
50 SharedLibraryFactory(dll_name, fn_name)
51 {
52 }
53
54 T* create()
55 {
56 if (!isValid())
57 return nullptr;
58 return (T*)getApi().create();
59 }
60
61 void destroy(T* obj)
62 {
63 if (!isValid())
64 return;
65 getApi().destroy(obj);
66 }
67};
68
69#endif // ROBOTTESTINGFRAMEWORK_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=0)
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.