RobotTestingFramework  2.0.1
Robot Testing Framework
SharedLibraryFactory.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_SHAREDLIBRARYFACTORY_H
23 #define ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYFACTORY_H
24 
28 
29 #include <string>
30 
31 
32 namespace shlibpp {
33 class SharedLibraryFactory;
34 }
35 
43 {
44 public:
54  enum
55  {
57  STATUS_OK = VOCAB('o', 'k'),
58  STATUS_LIBRARY_NOT_FOUND = VOCAB('f', 'o', 'u', 'n'),
59  STATUS_LIBRARY_NOT_LOADED = VOCAB('l', 'o', 'a', 'd'),
60  STATUS_FACTORY_NOT_FOUND = VOCAB('f', 'a', 'c', 't'),
62  };
63 
67  explicit SharedLibraryFactory();
68 
75  SharedLibraryFactory(const char* dll_name,
76  const char* fn_name = nullptr);
77 
81  virtual ~SharedLibraryFactory();
82 
90  bool open(const char* dll_name, const char* fn_name = nullptr);
91 
97  bool isValid() const;
98 
104  int getStatus() const;
105 
111  std::string getError() const;
112 
119  const SharedLibraryClassApi& getApi() const;
120 
126  int getReferenceCount() const;
127 
133  int addRef();
134 
140  int removeRef();
141 
147  std::string getName() const;
148 
154  std::string getClassName() const;
155 
161  std::string getBaseClassName() const;
162 
172  bool useFactoryFunction(void* factory);
173 
174 private:
176  int status;
179  int rct;
180  std::string name;
181  std::string className;
182  std::string baseClassName;
183  std::string error;
184 };
185 
186 
187 #endif // ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYFACTORY_H
SharedLibraryFactory()
Constructor for unconfigured factory.
Collection of hooks for creating/destroying a plugin.
Named method wasn&#39;t present in library.
Low-level wrapper for loading shared libraries (DLLs) and accessing symbols within it...
Definition: SharedLibrary.h:35
int getStatus() const
Get the status of the factory.
bool isValid() const
Check if factory is configured and present.
A wrapper for a named factory method in a named shared library.
int addRef()
Increment the reference count of this factory.
bool useFactoryFunction(void *factory)
Specify function to use as factory.
std::string getName() const
Get the name associated with this factory.
std::string getClassName() const
Get the type associated with this factory.
constexpr int32_t VOCAB(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:31
bool open(const char *dll_name, const char *fn_name=nullptr)
Configure the factory.
std::string getBaseClassName() const
Get the base type associated with this factory.
int getReferenceCount() const
Get the current reference count of this factory.
std::string getError() const
Get the latest error of the factory.
virtual ~SharedLibraryFactory()
Destructor.
const SharedLibraryClassApi & getApi() const
Get the factory API, which has creation/deletion methods.
int removeRef()
Decrement the reference count of this factory.