SharedLibraryClassFactory.h
Go to the documentation of this file.
/*
* Robot Testing Framework
*
* Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYCLASSFACTORY_H
#define ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYCLASSFACTORY_H
#include <robottestingframework/dll/SharedLibraryFactory.h>
namespace shlibpp {
template <class T>
class SharedLibraryClassFactory;
}
template <class T>
class shlibpp::SharedLibraryClassFactory : public SharedLibraryFactory
{
public:
SharedLibraryClassFactory()
{
}
SharedLibraryClassFactory(const char* dll_name, const char* fn_name = 0 /*nullptr*/) :
SharedLibraryFactory(dll_name, fn_name)
{
}
T* create()
{
if (!isValid())
return nullptr;
return (T*)getApi().create();
}
void destroy(T* obj)
{
if (!isValid())
return;
getApi().destroy(obj);
}
};
#endif // ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYCLASSFACTORY_H
SharedLibraryFactory.h
shlibpp::SharedLibraryClassFactory
A type-safe wrapper for SharedLibraryFactory, committing to creation/destruction of instances of a pa...
Definition: SharedLibraryClassFactory.h:43
shlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory
SharedLibraryClassFactory(const char *dll_name, const char *fn_name=0)
Definition: SharedLibraryClassFactory.h:49
shlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory
SharedLibraryClassFactory()
Definition: SharedLibraryClassFactory.h:45
shlibpp::SharedLibraryClassFactory::create
T * create()
Definition: SharedLibraryClassFactory.h:54
shlibpp::SharedLibraryClassFactory::destroy
void destroy(T *obj)
Definition: SharedLibraryClassFactory.h:61
shlibpp::SharedLibraryFactory
A wrapper for a named factory method in a named shared library.
Definition: SharedLibraryFactory.h:43
shlibpp::SharedLibraryFactory::isValid
bool isValid() const
Check if factory is configured and present.
shlibpp::SharedLibraryFactory::getApi
const SharedLibraryClassApi & getApi() const
Get the factory API, which has creation/deletion methods.
shlibpp
Definition: SharedLibrary.h:27
shlibpp::SharedLibraryClassApi::destroy
void(* destroy)(void *obj)
Definition: SharedLibraryClassApi.h:56
shlibpp::SharedLibraryClassApi::create
void *(* create)()
Definition: SharedLibraryClassApi.h:55