Skip to content

Commit 58d57ed

Browse files
committed
some fixes
Signed-off-by: ahcorde <ahcorde@gmail.com>
1 parent 0969655 commit 58d57ed

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

include/class_loader/class_loader.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ class ClassLoader : public std::enable_shared_from_this<ClassLoader>
122122
* @return A std::shared_ptr<Base> to newly created plugin object
123123
*/
124124
template<class Base>
125-
std::shared_ptr<Base> createInstance(const std::string & derived_class_name,
125+
std::shared_ptr<Base> createInstance(
126+
const std::string & derived_class_name,
126127
bool is_shared_ptr = false)
127128
{
128129
if (is_shared_ptr) {
@@ -152,19 +153,20 @@ class ClassLoader : public std::enable_shared_from_this<ClassLoader>
152153
* @return A std::unique_ptr<Base> to newly created plugin object.
153154
*/
154155
template<class Base>
155-
UniquePtr<Base> createUniqueInstance(const std::string & derived_class_name,
156+
UniquePtr<Base> createUniqueInstance(
157+
const std::string & derived_class_name,
156158
bool is_shared_ptr = false)
157159
{
158160
Base * raw = createRawInstance<Base>(derived_class_name, true);
159161
if (is_shared_ptr) {
160162
return std::unique_ptr<Base, DeleterType<Base>>(
161163
raw,
162-
std::bind(&ClassLoader::onPluginDeletion<Base>, this, std::placeholders::_1)
164+
std::bind(&ClassLoader::onPluginDeletion<Base>, shared_from_this(), std::placeholders::_1)
163165
);
164166
} else {
165167
return std::unique_ptr<Base, DeleterType<Base>>(
166168
raw,
167-
std::bind(&ClassLoader::onPluginDeletion<Base>, shared_from_this(), std::placeholders::_1)
169+
std::bind(&ClassLoader::onPluginDeletion<Base>, this, std::placeholders::_1)
168170
);
169171
}
170172
}

include/class_loader/multi_library_class_loader.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class CLASS_LOADER_PUBLIC MultiLibraryClassLoader
154154
"Make sure that the library exists and was explicitly loaded through "
155155
"MultiLibraryClassLoader::loadLibrary()");
156156
}
157-
return loader->createUniqueInstance<Base>(class_name);
157+
return loader->createUniqueInstance<Base>(class_name, true);
158158
}
159159

160160
/// Creates an instance of an object of given class name with ancestor class Base
@@ -321,7 +321,8 @@ class CLASS_LOADER_PUBLIC MultiLibraryClassLoader
321321
* @param library_path - the library from which we want to create the plugin
322322
* @return A pointer to the ClassLoader*, == nullptr if not found
323323
*/
324-
std::shared_ptr<class_loader::ClassLoader> getClassLoaderForLibrary(const std::string & library_path);
324+
std::shared_ptr<class_loader::ClassLoader> getClassLoaderForLibrary(
325+
const std::string & library_path);
325326

326327
/// Gets a handle to the class loader corresponding to a specific class.
327328
/**

src/multi_library_class_loader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "class_loader/multi_library_class_loader.hpp"
3131

3232
#include <cstddef>
33+
#include <memory>
3334
#include <mutex>
3435
#include <string>
3536
#include <vector>

0 commit comments

Comments
 (0)