Loading...
Searching...
No Matches
SharedLibraryFactory.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_SHAREDLIBRARYFACTORY_H
#define ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYFACTORY_H
#include <robottestingframework/dll/SharedLibrary.h>
#include <robottestingframework/dll/SharedLibraryClassApi.h>
#include <robottestingframework/dll/Vocab.h>
#include <string>
namespace shlibpp {
class SharedLibraryFactory;
}
class shlibpp::SharedLibraryFactory
{
public:
enum
{
STATUS_NONE,
STATUS_OK = VOCAB('o', 'k'),
STATUS_LIBRARY_NOT_FOUND = VOCAB('f', 'o', 'u', 'n'),
STATUS_LIBRARY_NOT_LOADED = VOCAB('l', 'o', 'a', 'd'),
STATUS_FACTORY_NOT_FOUND = VOCAB('f', 'a', 'c', 't'),
STATUS_FACTORY_NOT_FUNCTIONAL = VOCAB('r', 'u', 'n')
};
explicit SharedLibraryFactory();
SharedLibraryFactory(const char* dll_name,
const char* fn_name = nullptr);
virtual ~SharedLibraryFactory();
bool open(const char* dll_name, const char* fn_name = nullptr);
bool isValid() const;
int getStatus() const;
std::string getError() const;
const SharedLibraryClassApi& getApi() const;
int getReferenceCount() const;
int addRef();
int removeRef();
std::string getName() const;
std::string getClassName() const;
std::string getBaseClassName() const;
bool useFactoryFunction(void* factory);
private:
SharedLibrary lib;
int status;
SharedLibraryClassApi api;
int returnValue;
int rct;
std::string name;
std::string className;
std::string baseClassName;
std::string error;
};
#endif // ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYFACTORY_H
SharedLibraryClassApi.h
SharedLibrary.h
Vocab.h
shlibpp::SharedLibraryFactory
A wrapper for a named factory method in a named shared library.
Definition SharedLibraryFactory.h:43
shlibpp::SharedLibraryFactory::className
std::string className
Definition SharedLibraryFactory.h:181
shlibpp::SharedLibraryFactory::open
bool open(const char *dll_name, const char *fn_name=nullptr)
Configure the factory.
shlibpp::SharedLibraryFactory::useFactoryFunction
bool useFactoryFunction(void *factory)
Specify function to use as factory.
shlibpp::SharedLibraryFactory::addRef
int addRef()
Increment the reference count of this factory.
shlibpp::SharedLibraryFactory::api
SharedLibraryClassApi api
Definition SharedLibraryFactory.h:177
shlibpp::SharedLibraryFactory::returnValue
int returnValue
Definition SharedLibraryFactory.h:178
shlibpp::SharedLibraryFactory::SharedLibraryFactory
SharedLibraryFactory(const char *dll_name, const char *fn_name=nullptr)
Constructor.
shlibpp::SharedLibraryFactory::isValid
bool isValid() const
Check if factory is configured and present.
shlibpp::SharedLibraryFactory::~SharedLibraryFactory
virtual ~SharedLibraryFactory()
Destructor.
shlibpp::SharedLibraryFactory::getName
std::string getName() const
Get the name associated with this factory.
shlibpp::SharedLibraryFactory::getStatus
int getStatus() const
Get the status of the factory.
shlibpp::SharedLibraryFactory::rct
int rct
Definition SharedLibraryFactory.h:179
shlibpp::SharedLibraryFactory::getClassName
std::string getClassName() const
Get the type associated with this factory.
shlibpp::SharedLibraryFactory::getError
std::string getError() const
Get the latest error of the factory.
shlibpp::SharedLibraryFactory::removeRef
int removeRef()
Decrement the reference count of this factory.
shlibpp::SharedLibraryFactory::STATUS_LIBRARY_NOT_LOADED
@ STATUS_LIBRARY_NOT_LOADED
Named shared library failed to load.
Definition SharedLibraryFactory.h:59
shlibpp::SharedLibraryFactory::STATUS_FACTORY_NOT_FOUND
@ STATUS_FACTORY_NOT_FOUND
Named method wasn't present in library.
Definition SharedLibraryFactory.h:60
shlibpp::SharedLibraryFactory::STATUS_LIBRARY_NOT_FOUND
@ STATUS_LIBRARY_NOT_FOUND
Named shared library was not found.
Definition SharedLibraryFactory.h:58
shlibpp::SharedLibraryFactory::STATUS_NONE
@ STATUS_NONE
Not configured yet.
Definition SharedLibraryFactory.h:56
shlibpp::SharedLibraryFactory::STATUS_FACTORY_NOT_FUNCTIONAL
@ STATUS_FACTORY_NOT_FUNCTIONAL
Named method is not working right.
Definition SharedLibraryFactory.h:61
shlibpp::SharedLibraryFactory::STATUS_OK
@ STATUS_OK
Present and sane.
Definition SharedLibraryFactory.h:57
shlibpp::SharedLibraryFactory::getBaseClassName
std::string getBaseClassName() const
Get the base type associated with this factory.
shlibpp::SharedLibraryFactory::error
std::string error
Definition SharedLibraryFactory.h:183
shlibpp::SharedLibraryFactory::SharedLibraryFactory
SharedLibraryFactory()
Constructor for unconfigured factory.
shlibpp::SharedLibraryFactory::status
int status
Definition SharedLibraryFactory.h:176
shlibpp::SharedLibraryFactory::baseClassName
std::string baseClassName
Definition SharedLibraryFactory.h:182
shlibpp::SharedLibraryFactory::getReferenceCount
int getReferenceCount() const
Get the current reference count of this factory.
shlibpp::SharedLibraryFactory::lib
SharedLibrary lib
Definition SharedLibraryFactory.h:175
shlibpp::SharedLibraryFactory::getApi
const SharedLibraryClassApi & getApi() const
Get the factory API, which has creation/deletion methods.
shlibpp::SharedLibraryFactory::name
std::string name
Definition SharedLibraryFactory.h:180
shlibpp::SharedLibrary
Low-level wrapper for loading shared libraries (DLLs) and accessing symbols within it.
Definition SharedLibrary.h:36
shlibpp
Definition SharedLibrary.h:27
shlibpp::VOCAB
constexpr int32_t VOCAB(char a, char b=0, char c=0, char d=0)
Definition Vocab.h:31
shlibpp::SharedLibraryClassApi
Collection of hooks for creating/destroying a plugin.
Definition SharedLibraryClassApi.h:46