Skip to content

Commit bab7295

Browse files
authored
Clean up and improve documentation (#156)
* Clean up documentation Signed-off-by: ahcorde <ahcorde@gmail.com> * Added extra space between brief and params Signed-off-by: ahcorde <ahcorde@gmail.com>
1 parent 2039e72 commit bab7295

File tree

5 files changed

+169
-46
lines changed

5 files changed

+169
-46
lines changed

include/class_loader/class_loader.hpp

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,22 @@
5959
namespace class_loader
6060
{
6161

62-
/// Returns the default library prefix for the native os
63-
CLASS_LOADER_PUBLIC
64-
std::string systemLibraryPrefix();
65-
66-
/// Returns runtime library extension for native os
67-
CLASS_LOADER_PUBLIC
68-
std::string systemLibrarySuffix();
69-
7062
/// Returns a platform specific version of a basic library name
7163
/**
7264
* On *nix platforms the library name is prefixed with `lib`.
7365
* On all platforms the output of class_loader::systemLibrarySuffix() is appended.
66+
*
67+
* @param[in] library_name name to add the prefix
68+
* @return library name with the prefix added
7469
*/
7570
CLASS_LOADER_PUBLIC
7671
std::string systemLibraryFormat(const std::string & library_name);
7772

7873
/**
7974
* @class ClassLoader
80-
* @brief This class allows loading and unloading of dynamically linked libraries which contain class definitions from which objects can be created/destroyed during runtime (i.e. class_loader). Libraries loaded by a ClassLoader are only accessible within scope of that ClassLoader object.
75+
* @brief This class allows loading and unloading of dynamically linked libraries which contain class
76+
* definitions from which objects can be created/destroyed during runtime (i.e. class_loader).
77+
* Libraries loaded by a ClassLoader are only accessible within scope of that ClassLoader object.
8178
*/
8279
class ClassLoader
8380
{
@@ -89,21 +86,24 @@ class ClassLoader
8986
using UniquePtr = std::unique_ptr<Base, DeleterType<Base>>;
9087

9188
/**
92-
* @brief Constructor for ClassLoader
89+
* @brief Constructor for ClassLoader
90+
*
9391
* @param library_path - The path of the runtime library to load
94-
* @param ondemand_load_unload - Indicates if on-demand (lazy) unloading/loading of libraries occurs as plugins are created/destroyed
92+
* @param ondemand_load_unload - Indicates if on-demand (lazy) unloading/loading of libraries
93+
* occurs as plugins are created/destroyed.
9594
*/
9695
CLASS_LOADER_PUBLIC
9796
explicit ClassLoader(const std::string & library_path, bool ondemand_load_unload = false);
9897

9998
/**
100-
* @brief Destructor for ClassLoader. All libraries opened by this ClassLoader are unloaded automatically.
99+
* @brief Destructor for ClassLoader. All libraries opened by this ClassLoader are unloaded automatically.
101100
*/
102101
CLASS_LOADER_PUBLIC
103102
virtual ~ClassLoader();
104103

105104
/**
106-
* @brief Indicates which classes (i.e. class_loader) that can be loaded by this object
105+
* @brief Indicates which classes (i.e. class_loader) that can be loaded by this object
106+
*
107107
* @return vector of strings indicating names of instantiable classes derived from <Base>
108108
*/
109109
template<class Base>
@@ -113,12 +113,12 @@ class ClassLoader
113113
}
114114

115115
/**
116-
* @brief Generates an instance of loadable classes (i.e. class_loader).
116+
* @brief Generates an instance of loadable classes (i.e. class_loader).
117117
*
118118
* It is not necessary for the user to call loadLibrary() as it will be invoked automatically
119119
* if the library is not yet loaded (which typically happens when in "On Demand Load/Unload" mode).
120120
*
121-
* @param derived_class_name The name of the class we want to create (@see getAvailableClasses())
121+
* @param derived_class_name The name of the class we want to create (@see getAvailableClasses())
122122
* @return A std::shared_ptr<Base> to newly created plugin object
123123
*/
124124
template<class Base>
@@ -174,6 +174,7 @@ class ClassLoader
174174

175175
/**
176176
* @brief Indicates if a plugin class is available
177+
*
177178
* @param Base - polymorphic type indicating base class
178179
* @param class_name - the name of the plugin class
179180
* @return true if yes it is available, false otherwise
@@ -188,40 +189,64 @@ class ClassLoader
188189

189190
/**
190191
* @brief Gets the full-qualified path and name of the library associated with this class loader
192+
*
193+
* @return the full-qualified path and name of the library
191194
*/
192195
CLASS_LOADER_PUBLIC
193196
const std::string & getLibraryPath() const;
194197

195198
/**
196-
* @brief Indicates if a library is loaded within the scope of this ClassLoader. Note that the library may already be loaded internally through another ClassLoader, but until loadLibrary() method is called, the ClassLoader cannot create objects from said library. If we want to see if the library has been opened by somebody else, @see isLibraryLoadedByAnyClassloader()
197-
* @param library_path The path to the library to load
199+
* @brief Indicates if a library is loaded within the scope of this ClassLoader.
200+
*
201+
* Note that the library may already be loaded internally through another ClassLoader,
202+
* but until loadLibrary() method is called, the ClassLoader cannot create objects from said library.
203+
* If we want to see if the library has been opened by somebody else, @see isLibraryLoadedByAnyClassloader()
204+
*
205+
* @param library_path The path to the library to load
198206
* @return true if library is loaded within this ClassLoader object's scope, otherwise false
199207
*/
200208
CLASS_LOADER_PUBLIC
201209
bool isLibraryLoaded() const;
202210

203211
/**
204-
* @brief Indicates if a library is loaded by some entity in the plugin system (another ClassLoader), but not necessarily loaded by this ClassLoader
212+
* @brief Indicates if a library is loaded by some entity in the plugin system (another ClassLoader),
213+
* but not necessarily loaded by this ClassLoader.
214+
*
205215
* @return true if library is loaded within the scope of the plugin system, otherwise false
206216
*/
207217
CLASS_LOADER_PUBLIC
208218
bool isLibraryLoadedByAnyClassloader() const;
209219

210220
/**
211-
* @brief Indicates if the library is to be loaded/unloaded on demand...meaning that only to load a lib when the first plugin is created and automatically shut it down when last active plugin is destroyed.
221+
* @brief Indicates if the library is to be loaded/unloaded on demand...meaning that only to load
222+
* a lib when the first plugin is created and automatically shut it down when last active plugin
223+
* is destroyed.
224+
*
225+
* @return true if ondemand load and unload is active, otherwise false
212226
*/
213227
CLASS_LOADER_PUBLIC
214228
bool isOnDemandLoadUnloadEnabled() const;
215229

216230
/**
217-
* @brief Attempts to load a library on behalf of the ClassLoader. If the library is already opened, this method has no effect. If the library has been already opened by some other entity (i.e. another ClassLoader or global interface), this object is given permissions to access any plugin classes loaded by that other entity. This is
218-
* @param library_path The path to the library to load
231+
* @brief Attempts to load a library on behalf of the ClassLoader. If the library is already
232+
* opened, this method has no effect. If the library has been already opened by some other entity
233+
* (i.e. another ClassLoader or global interface), this object is given permissions to access any
234+
* plugin classes loaded by that other entity.
219235
*/
220236
CLASS_LOADER_PUBLIC
221237
void loadLibrary();
222238

223239
/**
224-
* @brief Attempts to unload a library loaded within scope of the ClassLoader. If the library is not opened, this method has no effect. If the library is opened by other another ClassLoader, the library will NOT be unloaded internally -- however this ClassLoader will no longer be able to instantiate class_loader bound to that library. If there are plugin objects that exist in memory created by this classloader, a warning message will appear and the library will not be unloaded. If loadLibrary() was called multiple times (e.g. in the case of multiple threads or purposefully in a single thread), the user is responsible for calling unloadLibrary() the same number of times. The library will not be unloaded within the context of this classloader until the number of unload calls matches the number of loads.
240+
* @brief Attempts to unload a library loaded within scope of the ClassLoader. If the library is
241+
* not opened, this method has no effect. If the library is opened by other another ClassLoader,
242+
* the library will NOT be unloaded internally -- however this ClassLoader will no longer be able
243+
* to instantiate class_loader bound to that library. If there are plugin objects that exist in
244+
* memory created by this classloader, a warning message will appear and the library will not be
245+
* unloaded. If loadLibrary() was called multiple times (e.g. in the case of multiple threads or
246+
* purposefully in a single thread), the user is responsible for calling unloadLibrary() the same
247+
* number of times. The library will not be unloaded within the context of this classloader until
248+
* the number of unload calls matches the number of loads.
249+
*
225250
* @return The number of times more unloadLibrary() has to be called for it to be unbound from this ClassLoader
226251
*/
227252
CLASS_LOADER_PUBLIC
@@ -230,6 +255,7 @@ class ClassLoader
230255
private:
231256
/**
232257
* @brief Callback method when a plugin created by this class loader is destroyed
258+
*
233259
* @param obj - A pointer to the deleted object
234260
*/
235261
template<class Base>
@@ -319,9 +345,14 @@ class ClassLoader
319345
static void setUnmanagedInstanceBeenCreated(bool state);
320346

321347
/**
322-
* @brief As the library may be unloaded in "on-demand load/unload" mode, unload maybe called from createInstance(). The problem is that createInstance() locks the plugin_ref_count as does unloadLibrary(). This method is the implementation of unloadLibrary but with a parameter to decide if plugin_ref_mutex_ should be locked
348+
* @brief As the library may be unloaded in "on-demand load/unload" mode, unload maybe called from
349+
* createInstance(). The problem is that createInstance() locks the plugin_ref_count as does
350+
* unloadLibrary(). This method is the implementation of unloadLibrary but with a parameter to
351+
* decide if plugin_ref_mutex_ should be locked.
352+
*
323353
* @param lock_plugin_ref_count - Set to true if plugin_ref_count_mutex_ should be locked, else false
324-
* @return The number of times unloadLibraryInternal has to be called again for it to be unbound from this ClassLoader
354+
* @return The number of times unloadLibraryInternal has to be called again for it to be unbound
355+
* from this ClassLoader
325356
*/
326357
CLASS_LOADER_PUBLIC
327358
int unloadLibraryInternal(bool lock_plugin_ref_count);

0 commit comments

Comments
 (0)