stmm-input-doc  0.17.0
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
stmi::PluginsDeviceManager Class Reference

Dynamic plug-in loader device manager class. More...

Inheritance diagram for stmi::PluginsDeviceManager:
Inheritance graph
[legend]

Classes

struct  Init
 Initialization data. More...
 

Public Member Functions

virtual ~PluginsDeviceManager () noexcept
 
- Public Member Functions inherited from stmi::ParentDeviceManager
shared_ptr< DevicegetDevice (int32_t nDeviceId) const noexcept override
 Return the device with the given id. More...
 
shared_ptr< CapabilitygetCapability (const Capability::Class &oClass) const noexcept override
 Get a device manager capability of a certain class. More...
 
shared_ptr< CapabilitygetCapability (int32_t nCapabilityId) const noexcept override
 Get a device manager capability by id. More...
 
std::vector< Capability::ClassgetCapabilityClasses () const noexcept override
 The union of the device manager capability classes of all the children. More...
 
std::vector< Capability::ClassgetDeviceCapabilityClasses () const noexcept override
 The union of the device capability classes of all the children's devices. More...
 
std::vector< Event::ClassgetEventClasses () const noexcept override
 The union of the event types of all the children. More...
 
std::vector< int32_t > getDevicesWithCapabilityClass (const Capability::Class &oCapabilityClass) const noexcept override
 The union of the devices of all the children with a given capability class. More...
 
std::vector< int32_t > getDevices () const noexcept override
 The union of the devices of all the children. More...
 
bool isEventClassEnabled (const Event::Class &oEventClass) const noexcept override
 Tells whether an event class is enabled in at least one of the children. More...
 
void enableEventClass (const Event::Class &oEventClass) noexcept override
 Calls the function for all the children. More...
 
bool addAccessor (const shared_ptr< Accessor > &refAccessor) noexcept override
 Calls addAccessor() of children. More...
 
bool removeAccessor (const shared_ptr< Accessor > &refAccessor) noexcept override
 Calls removeAccessor() of children. More...
 
bool hasAccessor (const shared_ptr< Accessor > &refAccessor) noexcept override
 Tells whether an accessor is at least in one of the children. More...
 
bool addEventListener (const shared_ptr< EventListener > &refEventListener, const shared_ptr< CallIf > &refCallIf) noexcept override
 Calls addEventListener of children. More...
 
bool addEventListener (const shared_ptr< EventListener > &refEventListener) noexcept override
 Calls addEventListener of children. More...
 
bool removeEventListener (const shared_ptr< EventListener > &refEventListener, bool bFinalize) noexcept override
 Calls removeEventListener of children. More...
 
bool removeEventListener (const shared_ptr< EventListener > &refEventListener) noexcept override
 Calls removeEventListener of children. More...
 
std::vector< shared_ptr< ChildDeviceManager > > getChildren () const noexcept
 The child device managers. More...
 
virtual std::vector< shared_ptr< Capability > > getDeviceManagerCapabilities (const Capability::Class &oClass) const noexcept
 Get the device manager capabilities of a given class of all the children. More...
 
- Public Member Functions inherited from stmi::ChildDeviceManager
shared_ptr< ParentDeviceManagergetParent () const noexcept
 Gets the parent of this child device manager. More...
 
shared_ptr< ParentDeviceManagergetParent () noexcept
 Gets the parent of this child device manager. More...
 
shared_ptr< ParentDeviceManagergetRoot () const noexcept
 Returns the root device manager. More...
 
shared_ptr< ParentDeviceManagergetRoot () noexcept
 Returns the root device manager. More...
 
bool isParent () const noexcept
 Tells whether this instance is also a ParentDeviceManager. More...
 
shared_ptr< ParentDeviceManagergetAsParent () const noexcept
 If a parent returns this object as a parent. More...
 
shared_ptr< ParentDeviceManagergetAsParent () noexcept
 If a parent returns this object as a parent. More...
 
- Public Member Functions inherited from stmi::DeviceManager
virtual ~DeviceManager () noexcept=default
 
template<typename TCapa >
bool getCapability (shared_ptr< TCapa > &refCapa) const noexcept
 Request a registered device manager capability. More...
 

Static Public Member Functions

static std::pair< shared_ptr< PluginsDeviceManager >, std::string > create (Init &&oInit) noexcept
 Create an instance. More...
 
- Static Public Member Functions inherited from stmi::DeviceManager
static int64_t getNowTimeMicroseconds () noexcept
 Current time from epoch in microseconds. More...
 

Protected Member Functions

void init (const std::vector< shared_ptr< ChildDeviceManager > > &aChildDeviceManager) noexcept
 
- Protected Member Functions inherited from stmi::ParentDeviceManager
 ParentDeviceManager () noexcept
 
void init (const std::vector< shared_ptr< ChildDeviceManager > > &aChildDeviceManager) noexcept
 Initialization. More...
 
void removeChildren () noexcept
 Removes all children. More...
 
- Protected Member Functions inherited from stmi::ChildDeviceManager
 ChildDeviceManager () noexcept
 Constructor. More...
 
- Protected Member Functions inherited from stmi::DeviceManager
 DeviceManager () noexcept
 

Friends

shared_ptr< PluginsDeviceManagercreate (bool bEnableEventClasses, const std::vector< Event::Class > &aEnDisableEventClasses) noexcept
 

Detailed Description

Dynamic plug-in loader device manager class.

The contained device managers (the children) must be subclasses of ChildDeviceManager. A child device manager must be defined within its own shared library, compiled with the "-Wl,-E" flag (g++ only!) that implements the (extern "C") interface defined in <stmm-input-dl/plugininterface.h>:

shared_ptr<ChildDeviceManager> createPlugin(const std::string sAppName, bool bEnableEventClasses
                              , const std::vector<Event::Class>& aEnDisableEventClasses);

The plugins (.dlp) are found by an instance of this class by searching the plugin paths. The first to be searched is the optional one passed to the create() function. The second is the local system path (ex. /usr/local/etc/stmm-input-dl). The third (if library installed in /usr/lib)) is the system path (ex. /etc/stmm-input-dl).

A plugin file name (ex. 90myplugin.dlp) is composed by the rank within the path (the first two digits, here 90), the suffix (.dlp) and the plugin name (myplugin). If two or more files define the same plugin name only the one with smallest rank number is loaded (70foo.dlp has higher rank than 90foo.dlp).

The content of a plugin file has the following format:

# Lines that start with #=#+#=# separate blocks.
# Other lines that start with # are comments. Comments are ignored.
# The first block of (non comment) lines are the library paths. These strings
# are passed to the dlopen() function. If one succeeds to load the plugin,
# an instance is created by calling the createPlugin function (see above).
libmyplugin.so.0
libmyplugin.so
/usr/local/lib/libmyplugin.so.0
/usr/lib/libmyplugin.so.0
#=#+#=# This line marks the next block ...
# ... which contains the plugins names that the to be loaded plugin depends on.
# This causes them to be loaded with dlopen before this one.
# These names must be present as .dlp files on any of the plugin paths,
# otherwise they are ignored. The loading of myplugin.dlp library is still
# attempted anyway. Note that the dependency doesn't include the ".dlp".
my-other-plugin
#=#+#=# The next block is a description of the plugin.
myplugin creates devices that do this and that.
#=#+#=# The next block contains a list of groups the plugin belongs to.
# Groups can be used by PluginsDeviceManager to selectively load only
# a subset of the enabled plugins. Each line contains a group name.
# A group name is made of following characters (regex notation):
#     [a-zA-Z][a-zA-Z0-9]*
gtk

Plugins can be disabled without removing their .dlp file. In each plugin path and additionally in the local user path (ex. ~/.local/etc/stmm-input-dl) the optional file "disabled-dlps.txt" defines the disabled plugin names. The plugin names (without the .dlp extension) are listed one per line. Example: if you want to disable the above plugin

# Comments are ignored here too.
# This is "disabled-dlps.txt" in directory ~/.local/share/stmm-input-dl
myplugin
# If a plugin name doesn't exist as .dlp file, it is just skipped.
some-other-plugin

Constructor & Destructor Documentation

◆ ~PluginsDeviceManager()

virtual stmi::PluginsDeviceManager::~PluginsDeviceManager ( )
virtualnoexcept

Member Function Documentation

◆ create()

static std::pair<shared_ptr<PluginsDeviceManager>, std::string> stmi::PluginsDeviceManager::create ( Init &&  oInit)
staticnoexcept

Create an instance.

Parameters
oInitThe initialization data.
Returns
The created device manager and an empty string or null and an error if creation failed or null and an empty string if no plugins loaded.

◆ init()

void stmi::PluginsDeviceManager::init ( const std::vector< shared_ptr< ChildDeviceManager > > &  aChildDeviceManager)
inlineprotectednoexcept

Friends And Related Function Documentation

◆ create

shared_ptr<PluginsDeviceManager> create ( bool  bEnableEventClasses,
const std::vector< Event::Class > &  aEnDisableEventClasses 
)
friend