You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
819 lines
77 KiB
819 lines
77 KiB
<!-- HTML header for doxygen 1.8.13-->
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.14"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>QtMvvm: QtMvvm::ServiceRegistry Class Reference</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0" style="display: inline;">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">QtMvvm
|
|
 <span id="projectnumber">1.0.0</span>
|
|
</div>
|
|
<div id="projectbrief">A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<a style="float: right;" target="_blank" href="https://github.com/Skycoder42/QtMvvm">
|
|
<img style="padding: 10px;" src="GitHub_Logo.png"/>
|
|
</a>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.14 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="namespace_qt_mvvm.html">QtMvvm</a></li><li class="navelem"><a class="el" href="class_qt_mvvm_1_1_service_registry.html">ServiceRegistry</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#pub-methods">Public Member Functions</a> |
|
|
<a href="#pub-static-methods">Static Public Member Functions</a> |
|
|
<a href="class_qt_mvvm_1_1_service_registry-members.html">List of all members</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">QtMvvm::ServiceRegistry Class Reference</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>A singleton to prepare services for dependency injection and to access them.
|
|
<a href="class_qt_mvvm_1_1_service_registry.html#details">More...</a></p>
|
|
|
|
<p><code>#include <<a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>></code></p>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
|
|
Public Member Functions</h2></td></tr>
|
|
<tr class="memitem:a2fddc2077d76404550f037dfbd9029ca"><td class="memTemplParams" colspan="2"><a id="a2fddc2077d76404550f037dfbd9029ca"></a>
|
|
template<typename TInterface > </td></tr>
|
|
<tr class="memitem:a2fddc2077d76404550f037dfbd9029ca"><td class="memTemplItemLeft" align="right" valign="top">bool </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a2fddc2077d76404550f037dfbd9029ca">isRegistered</a> () const</td></tr>
|
|
<tr class="memdesc:a2fddc2077d76404550f037dfbd9029ca"><td class="mdescLeft"> </td><td class="mdescRight">Checks if a given interface or service is already registered. <br /></td></tr>
|
|
<tr class="separator:a2fddc2077d76404550f037dfbd9029ca"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a33106199077763388fabff116dc190e2"><td class="memItemLeft" align="right" valign="top"><a id="a33106199077763388fabff116dc190e2"></a>
|
|
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a33106199077763388fabff116dc190e2">isRegistered</a> (const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearray.html">QByteArray</a> &iid) const</td></tr>
|
|
<tr class="memdesc:a33106199077763388fabff116dc190e2"><td class="mdescLeft"> </td><td class="mdescRight">Checks if a given interface or service is already registered. <br /></td></tr>
|
|
<tr class="separator:a33106199077763388fabff116dc190e2"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:abacfa0d81764df255df41e4ccf175ad8"><td class="memTemplParams" colspan="2">template<typename TInterface , typename TService > </td></tr>
|
|
<tr class="memitem:abacfa0d81764df255df41e4ccf175ad8"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#abacfa0d81764df255df41e4ccf175ad8">registerInterface</a> (bool weak=false)</td></tr>
|
|
<tr class="memdesc:abacfa0d81764df255df41e4ccf175ad8"><td class="mdescLeft"> </td><td class="mdescRight">Register a service for its interface via the type. <a href="#abacfa0d81764df255df41e4ccf175ad8">More...</a><br /></td></tr>
|
|
<tr class="separator:abacfa0d81764df255df41e4ccf175ad8"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aa06f0c25e8238e7740a4f4ec09569a87"><td class="memTemplParams" colspan="2">template<typename TInterface , typename TService , typename TFunc > </td></tr>
|
|
<tr class="memitem:aa06f0c25e8238e7740a4f4ec09569a87"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#aa06f0c25e8238e7740a4f4ec09569a87">registerInterface</a> (const TFunc &fn, bool weak=false)</td></tr>
|
|
<tr class="memdesc:aa06f0c25e8238e7740a4f4ec09569a87"><td class="mdescLeft"> </td><td class="mdescRight">Register a service for its interface via a constructor function. <a href="#aa06f0c25e8238e7740a4f4ec09569a87">More...</a><br /></td></tr>
|
|
<tr class="separator:aa06f0c25e8238e7740a4f4ec09569a87"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:afad92a0b52150125c010913e3365d1ab"><td class="memTemplParams" colspan="2">template<typename TInterface , typename TService > </td></tr>
|
|
<tr class="memitem:afad92a0b52150125c010913e3365d1ab"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#afad92a0b52150125c010913e3365d1ab">registerInterface</a> (TService *<a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31">service</a>, bool weak=false)</td></tr>
|
|
<tr class="memdesc:afad92a0b52150125c010913e3365d1ab"><td class="mdescLeft"> </td><td class="mdescRight">Register a service for its interface via an already existing instance. <a href="#afad92a0b52150125c010913e3365d1ab">More...</a><br /></td></tr>
|
|
<tr class="separator:afad92a0b52150125c010913e3365d1ab"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a9c2f2166f4ecbd4b2f3ae0d0e4165ab5"><td class="memTemplParams" colspan="2">template<typename TService > </td></tr>
|
|
<tr class="memitem:a9c2f2166f4ecbd4b2f3ae0d0e4165ab5"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5">registerObject</a> (bool weak=false)</td></tr>
|
|
<tr class="memdesc:a9c2f2166f4ecbd4b2f3ae0d0e4165ab5"><td class="mdescLeft"> </td><td class="mdescRight">Register a service via its type. <a href="#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5">More...</a><br /></td></tr>
|
|
<tr class="separator:a9c2f2166f4ecbd4b2f3ae0d0e4165ab5"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:afaa2b66fdb3ead00d6b52ef0df4c4f61"><td class="memTemplParams" colspan="2">template<typename TService , typename TFunc > </td></tr>
|
|
<tr class="memitem:afaa2b66fdb3ead00d6b52ef0df4c4f61"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#afaa2b66fdb3ead00d6b52ef0df4c4f61">registerObject</a> (const TFunc &fn, bool weak=false)</td></tr>
|
|
<tr class="memdesc:afaa2b66fdb3ead00d6b52ef0df4c4f61"><td class="mdescLeft"> </td><td class="mdescRight">Register a service via a constructor function. <a href="#afaa2b66fdb3ead00d6b52ef0df4c4f61">More...</a><br /></td></tr>
|
|
<tr class="separator:afaa2b66fdb3ead00d6b52ef0df4c4f61"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a25ae0f6bd651835d90455d5540ea533b"><td class="memTemplParams" colspan="2">template<typename TService > </td></tr>
|
|
<tr class="memitem:a25ae0f6bd651835d90455d5540ea533b"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a25ae0f6bd651835d90455d5540ea533b">registerObject</a> (TService *<a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31">service</a>, bool weak=false)</td></tr>
|
|
<tr class="memdesc:a25ae0f6bd651835d90455d5540ea533b"><td class="mdescLeft"> </td><td class="mdescRight">Register a service via an already existing instance. <a href="#a25ae0f6bd651835d90455d5540ea533b">More...</a><br /></td></tr>
|
|
<tr class="separator:a25ae0f6bd651835d90455d5540ea533b"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a6d904ac2abf387eb877dae3aad801848"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6d904ac2abf387eb877dae3aad801848">registerService</a> (const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearray.html">QByteArray</a> &iid, const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qmetaobject.html">QMetaObject</a> *metaObject, bool weak=false)</td></tr>
|
|
<tr class="memdesc:a6d904ac2abf387eb877dae3aad801848"><td class="mdescLeft"> </td><td class="mdescRight">Register a service by an iid via their metadata. <a href="#a6d904ac2abf387eb877dae3aad801848">More...</a><br /></td></tr>
|
|
<tr class="separator:a6d904ac2abf387eb877dae3aad801848"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a342a6e90115c9a3657877c31ead01c56"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a342a6e90115c9a3657877c31ead01c56">registerService</a> (const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearray.html">QByteArray</a> &iid, const std::function< <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *(const QObjectList &)> &fn, <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearraylist.html">QByteArrayList</a> injectables, bool weak=false)</td></tr>
|
|
<tr class="memdesc:a342a6e90115c9a3657877c31ead01c56"><td class="mdescLeft"> </td><td class="mdescRight">Register a service by an iid via a generalized constructor function. <a href="#a342a6e90115c9a3657877c31ead01c56">More...</a><br /></td></tr>
|
|
<tr class="separator:a342a6e90115c9a3657877c31ead01c56"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a54085d3bac2c39f58c46165827686a31"><td class="memTemplParams" colspan="2">template<typename TInterface > </td></tr>
|
|
<tr class="memitem:a54085d3bac2c39f58c46165827686a31"><td class="memTemplItemLeft" align="right" valign="top">TInterface * </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31">service</a> ()</td></tr>
|
|
<tr class="memdesc:a54085d3bac2c39f58c46165827686a31"><td class="mdescLeft"> </td><td class="mdescRight">Returns the service for the given interface. <a href="#a54085d3bac2c39f58c46165827686a31">More...</a><br /></td></tr>
|
|
<tr class="separator:a54085d3bac2c39f58c46165827686a31"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:abff2c6776647fdb377860a3c3cca9080"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080">serviceObj</a> (const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearray.html">QByteArray</a> &iid)</td></tr>
|
|
<tr class="memdesc:abff2c6776647fdb377860a3c3cca9080"><td class="mdescLeft"> </td><td class="mdescRight">Returns the service for the given iid. <a href="#abff2c6776647fdb377860a3c3cca9080">More...</a><br /></td></tr>
|
|
<tr class="separator:abff2c6776647fdb377860a3c3cca9080"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a6c3bf4e06311d321bdea7e78a4899769"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769">injectServices</a> (<a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *object)</td></tr>
|
|
<tr class="memdesc:a6c3bf4e06311d321bdea7e78a4899769"><td class="mdescLeft"> </td><td class="mdescRight">Inject services for all injectable properties on object. <a href="#a6c3bf4e06311d321bdea7e78a4899769">More...</a><br /></td></tr>
|
|
<tr class="separator:a6c3bf4e06311d321bdea7e78a4899769"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a3db366f49af65a3b7b79a5494bb69f19"><td class="memTemplParams" colspan="2">template<typename TClass > </td></tr>
|
|
<tr class="memitem:a3db366f49af65a3b7b79a5494bb69f19"><td class="memTemplItemLeft" align="right" valign="top">TClass * </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a3db366f49af65a3b7b79a5494bb69f19">constructInjected</a> (<a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent=nullptr)</td></tr>
|
|
<tr class="memdesc:a3db366f49af65a3b7b79a5494bb69f19"><td class="mdescLeft"> </td><td class="mdescRight">Constructs a new instance of TClass with properties injected. <a href="#a3db366f49af65a3b7b79a5494bb69f19">More...</a><br /></td></tr>
|
|
<tr class="separator:a3db366f49af65a3b7b79a5494bb69f19"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a18479634e9d4ba58ed03231ecf006c48"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a18479634e9d4ba58ed03231ecf006c48">constructInjected</a> (const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qmetaobject.html">QMetaObject</a> *metaObject, <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent=nullptr)</td></tr>
|
|
<tr class="memdesc:a18479634e9d4ba58ed03231ecf006c48"><td class="mdescLeft"> </td><td class="mdescRight">Constructs a new instance of metaObject with properties injected. <a href="#a18479634e9d4ba58ed03231ecf006c48">More...</a><br /></td></tr>
|
|
<tr class="separator:a18479634e9d4ba58ed03231ecf006c48"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
|
|
Static Public Member Functions</h2></td></tr>
|
|
<tr class="memitem:aabda69c79dc04cebfd2ebaea25e9ee62"><td class="memItemLeft" align="right" valign="top"><a id="aabda69c79dc04cebfd2ebaea25e9ee62"></a>
|
|
static <a class="el" href="class_qt_mvvm_1_1_service_registry.html">ServiceRegistry</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="class_qt_mvvm_1_1_service_registry.html#aabda69c79dc04cebfd2ebaea25e9ee62">instance</a> ()</td></tr>
|
|
<tr class="memdesc:aabda69c79dc04cebfd2ebaea25e9ee62"><td class="mdescLeft"> </td><td class="mdescRight">Returns the <a class="el" href="class_qt_mvvm_1_1_service_registry.html" title="A singleton to prepare services for dependency injection and to access them. ">ServiceRegistry</a> singleton instance. <br /></td></tr>
|
|
<tr class="separator:aabda69c79dc04cebfd2ebaea25e9ee62"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p>A singleton to prepare services for dependency injection and to access them. </p>
|
|
<p>This is the class responsible for the dependency injection (DI) part. All services registered with the registry are available for DI. When using lazy initialization, services themselves can also have dependencies to be injected. When the registry creates them it will automatically inject them. Automatic DI is also done for <a class="el" href="class_qt_mvvm_1_1_view_model.html" title="The base class for all viewmodels. ">ViewModel</a> created by the <a class="el" href="class_qt_mvvm_1_1_core_app.html" title="A logicaly application object to drive the mvvm application from the core part. ">CoreApp</a>.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>If a service has a slot named <code>qtmvvm_init()</code> it is called automatically by the registry right after all dependant services have been injected.</dd></dl>
|
|
<p>The following example shows how to use DI. The first shows how to use it with a simple, interface-less service for an already created object:</p>
|
|
<div class="fragment"><div class="line"><span class="comment">// service.h</span></div><div class="line"><span class="keyword">class </span>Service : <span class="keyword">public</span> <a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a></div><div class="line">{</div><div class="line"> Q_OBJECT</div><div class="line"></div><div class="line"><span class="keyword">public</span>:</div><div class="line"> Q_INVOKABLE <span class="keyword">explicit</span> Service(<a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = <span class="keyword">nullptr</span>); <span class="comment">//required signature</span></div><div class="line"></div><div class="line"><span class="keyword">public</span> Q_SLOTS:</div><div class="line"> <span class="keywordtype">void</span> baum();</div><div class="line"> <span class="keywordtype">void</span> qtmvvm_init(); <span class="comment">//is called by the registry</span></div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">// myclass.h</span></div><div class="line"><span class="keyword">class </span>MyClass : <span class="keyword">public</span> <a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a></div><div class="line">{</div><div class="line"> Q_OBJECT</div><div class="line"></div><div class="line"> <a class="code" href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f">QTMVVM_INJECT_PROP</a>(Service*, <a class="code" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31">service</a>, _service)</div><div class="line"></div><div class="line"> <span class="comment">//...</span></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> Service *_service;</div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">//main.cpp</span></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line">{</div><div class="line"> <a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtwidgets/qtwidgets.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qapplication.html">QApplication</a> a(argc, argv);</div><div class="line"> <a class="code" href="class_qt_mvvm_1_1_service_registry.html#aabda69c79dc04cebfd2ebaea25e9ee62">QtMvvm::ServiceRegistry::instance</a>()-><a class="code" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5">registerObject</a><Service>();</div><div class="line"></div><div class="line"> <span class="comment">//...</span></div><div class="line"></div><div class="line"> <span class="keyword">auto</span> myObj = <span class="keyword">new</span> MyClass(parent);</div><div class="line"> <a class="code" href="class_qt_mvvm_1_1_service_registry.html#aabda69c79dc04cebfd2ebaea25e9ee62">QtMvvm::ServiceRegistry::instance</a>()-><a class="code" href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769">injectServices</a>(myObj);</div><div class="line"> <span class="comment">// _service is now initialized via a valid Service</span></div><div class="line">}</div></div><!-- fragment --><p>The second example shows how to use it for interface based services and on objects that are created via the registry:</p>
|
|
<div class="fragment"><div class="line"><span class="comment">// iservice.h</span></div><div class="line"><span class="keyword">class </span>IService</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> <span class="keyword">virtual</span> <span class="keyword">inline</span> ~IService() = <span class="keywordflow">default</span>;</div><div class="line"></div><div class="line"><span class="keyword">public</span> Q_SLOTS:</div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> baum() = 0;</div><div class="line">};</div><div class="line"></div><div class="line"><span class="preprocessor">#define IServiceIid "com.example.myapp.IService"</span></div><div class="line">Q_DECLARE_INTERFACE(IService, IServiceIid)</div><div class="line"></div><div class="line"><span class="comment">// service.h</span></div><div class="line"><span class="keyword">class </span>Service : <span class="keyword">public</span> <a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a>, <span class="keyword">public</span> IService</div><div class="line">{</div><div class="line"> Q_OBJECT</div><div class="line"> Q_INTERFACES(IService)</div><div class="line"></div><div class="line"><span class="keyword">public</span>:</div><div class="line"> Q_INVOKABLE <span class="keyword">explicit</span> Service(<a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = <span class="keyword">nullptr</span>); <span class="comment">//required signature</span></div><div class="line"></div><div class="line"><span class="keyword">public</span> Q_SLOTS:</div><div class="line"> <span class="keywordtype">void</span> baum() <span class="keyword">override</span>;</div><div class="line"> <span class="keywordtype">void</span> qtmvvm_init(); <span class="comment">//is called by the registry</span></div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">// myclass.h</span></div><div class="line"><span class="keyword">class </span>MyClass : <span class="keyword">public</span> <a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a></div><div class="line">{</div><div class="line"> Q_OBJECT</div><div class="line"></div><div class="line"> <a class="code" href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f">QTMVVM_INJECT_PROP</a>(IService*, <a class="code" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31">service</a>, _service)</div><div class="line"></div><div class="line"><span class="keyword">public</span>:</div><div class="line"> Q_INVOKABLE MyClass(<a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = <span class="keyword">nullptr</span>); <span class="comment">//required signature</span></div><div class="line"></div><div class="line"> <span class="comment">//...</span></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> IService *_service;</div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">//main.cpp</span></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line">{</div><div class="line"> <a class="codeRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtwidgets/qtwidgets.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qapplication.html">QApplication</a> a(argc, argv);</div><div class="line"> QtMvvm::registerInterfaceConverter<IService>();</div><div class="line"> <a class="code" href="class_qt_mvvm_1_1_service_registry.html#aabda69c79dc04cebfd2ebaea25e9ee62">QtMvvm::ServiceRegistry::instance</a>()-><a class="code" href="class_qt_mvvm_1_1_service_registry.html#abacfa0d81764df255df41e4ccf175ad8">registerInterface</a><IService, Service>();</div><div class="line"></div><div class="line"> <span class="comment">//...</span></div><div class="line"></div><div class="line"> <span class="keyword">auto</span> myObj = <a class="code" href="class_qt_mvvm_1_1_service_registry.html#aabda69c79dc04cebfd2ebaea25e9ee62">QtMvvm::ServiceRegistry::instance</a>()-><a class="code" href="class_qt_mvvm_1_1_service_registry.html#a3db366f49af65a3b7b79a5494bb69f19">constructInjected</a><MyClass>();</div><div class="line"> <span class="comment">// _service is now initialized via a valid IService</span></div><div class="line">}</div></div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><a class="el" href="namespace_qt_mvvm.html#ada3398eab54e79982c27bb4b7d8e4b9f" title="Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE. ">QtMvvm::registerInterfaceConverter</a>, <a class="el" href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151" title="Mark a property for injection. ">QTMVVM_INJECT</a>, <a class="el" href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f" title="Create a for injection marked property based on a member. ">QTMVVM_INJECT_PROP</a>, <a class="el" href="class_qt_mvvm_1_1_view_model.html" title="The base class for all viewmodels. ">ViewModel</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00017">17</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
</div><h2 class="groupheader">Member Function Documentation</h2>
|
|
<a id="a3db366f49af65a3b7b79a5494bb69f19"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a3db366f49af65a3b7b79a5494bb69f19">◆ </a></span>constructInjected() <span class="overload">[1/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename TClass > </div>
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::constructInjected </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> * </td>
|
|
<td class="paramname"><em>parent</em> = <code>nullptr</code></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Constructs a new instance of TClass with properties injected. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">TClass</td><td>The type of object to be created, must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">parent</td><td>The parent object of the created object </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A newly created instance of TClass. </dd></dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_construction_exception.html" title="Is thrown in case the construction of a service has failed. ">ServiceConstructionException</a></td><td>If the registry failed to create an instance that needs to be injected into the object</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>First the method creates a new instance of TClass, then loads all services that are needed to inject into properties of the object that are marked for injection via <a class="el" href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151" title="Mark a property for injection. ">QTMVVM_INJECT</a>. If any lazy service has not been created yet, it is created on the fly and then injected. The returned object is parented to the parent object. If that is null it is owned by the caller.</p>
|
|
<dl class="section attention"><dt>Attention</dt><dd>For this to work, the TClass must have an invokable constructor with the following signature: <code>Q_INVOKABLE explicit TClass(<a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = nullptr);</code></dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769" title="Inject services for all injectable properties on object. ">ServiceRegistry::injectServices</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a>, <a class="el" href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151" title="Mark a property for injection. ">QTMVVM_INJECT</a>, <a class="el" href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f" title="Create a for injection marked property based on a member. ">QTMVVM_INJECT_PROP</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00219">219</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a18479634e9d4ba58ed03231ecf006c48"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a18479634e9d4ba58ed03231ecf006c48">◆ </a></span>constructInjected() <span class="overload">[2/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::constructInjected </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qmetaobject.html">QMetaObject</a> * </td>
|
|
<td class="paramname"><em>metaObject</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype"><a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> * </td>
|
|
<td class="paramname"><em>parent</em> = <code>nullptr</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Constructs a new instance of metaObject with properties injected. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">metaObject</td><td>The metaobject of object type to be created, must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> </td></tr>
|
|
<tr><td class="paramname">parent</td><td>The parent object of the created object </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A newly created instance of the given type. </dd></dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_construction_exception.html" title="Is thrown in case the construction of a service has failed. ">ServiceConstructionException</a></td><td>If the registry failed to create an instance that needs to be injected into the object</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>First the method creates a new instance of metaObject, then loads all services that are needed to inject into properties of the object that are marked for injection via <a class="el" href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151" title="Mark a property for injection. ">QTMVVM_INJECT</a>. If any lazy service has not been created yet, it is created on the fly and then injected. The returned object is parented to the parent object. If that is null it is owned by the caller.</p>
|
|
<dl class="section attention"><dt>Attention</dt><dd>For this to work, the class defined by metaObject must have an invokable constructor with the following signature: <code>Q_INVOKABLE explicit TClass(<a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = nullptr);</code></dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769" title="Inject services for all injectable properties on object. ">ServiceRegistry::injectServices</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a>, <a class="el" href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151" title="Mark a property for injection. ">QTMVVM_INJECT</a>, <a class="el" href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f" title="Create a for injection marked property based on a member. ">QTMVVM_INJECT_PROP</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a6c3bf4e06311d321bdea7e78a4899769"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a6c3bf4e06311d321bdea7e78a4899769">◆ </a></span>injectServices()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::injectServices </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> * </td>
|
|
<td class="paramname"><em>object</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Inject services for all injectable properties on object. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">object</td><td>The object to inject properties into </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_construction_exception.html" title="Is thrown in case the construction of a service has failed. ">ServiceConstructionException</a></td><td>If the registry failed to create an instance that needs to be injected into the object</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>Loads all services that are needed to inject into properties of the object that are marked for injection via <a class="el" href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151" title="Mark a property for injection. ">QTMVVM_INJECT</a>. If any lazy service has not been created yet, it is created on the fly and then injected.</p>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a3db366f49af65a3b7b79a5494bb69f19" title="Constructs a new instance of TClass with properties injected. ">ServiceRegistry::constructInjected</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a>, <a class="el" href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151" title="Mark a property for injection. ">QTMVVM_INJECT</a>, <a class="el" href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f" title="Create a for injection marked property based on a member. ">QTMVVM_INJECT_PROP</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="abacfa0d81764df255df41e4ccf175ad8"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#abacfa0d81764df255df41e4ccf175ad8">◆ </a></span>registerInterface() <span class="overload">[1/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename TInterface , typename TService > </div>
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::registerInterface </td>
|
|
<td>(</td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>weak</em> = <code>false</code></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Register a service for its interface via the type. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">TInterface</td><td>The interface type to register the service for </td></tr>
|
|
<tr><td class="paramname">TService</td><td>The service to be registered for that interface. Must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> and implement TInterface </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_exists_exception.html" title="Is thrown if a service is beeing registered that is already registered. ">ServiceExistsException</a></td><td>If a non-weak service has already been registered for TInterface</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the function returns successfully, from now on a service of the given type can be accessed via the registry for the interface. The service is lazy initialized an will be created as soon as it is requested for the first time. If it has any injectable properties, they will be automatically injected on construction.</p>
|
|
<p>If the service is registered as weak, registering another service for the same interface will not throw an exception but instead discard (and delete) this one.</p>
|
|
<dl class="section attention"><dt>Attention</dt><dd>Make shure to register TInterface via <a class="el" href="namespace_qt_mvvm.html#ada3398eab54e79982c27bb4b7d8e4b9f" title="Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE. ">QtMvvm::registerInterfaceConverter</a>, otherwise injection for the interface is not possible. In addition to this, TService must have an invokable constructor with the following signature: <code>Q_INVOKABLE explicit TService(<a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = nullptr);</code></dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5" title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <a class="el" href="namespace_qt_mvvm.html#ada3398eab54e79982c27bb4b7d8e4b9f" title="Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE. ">QtMvvm::registerInterfaceConverter</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6d904ac2abf387eb877dae3aad801848" title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00155">155</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="aa06f0c25e8238e7740a4f4ec09569a87"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aa06f0c25e8238e7740a4f4ec09569a87">◆ </a></span>registerInterface() <span class="overload">[2/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename TInterface , typename TService , typename TFunc > </div>
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::registerInterface </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const TFunc & </td>
|
|
<td class="paramname"><em>fn</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>weak</em> = <code>false</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Register a service for its interface via a constructor function. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">TInterface</td><td>The interface type to register the service for </td></tr>
|
|
<tr><td class="paramname">TService</td><td>The service to be registered for that interface. Must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> and implement TInterface </td></tr>
|
|
<tr><td class="paramname">TFunc</td><td>The function type of the <code>fn</code> parameter. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">fn</td><td>The function to be called to construct the service </td></tr>
|
|
<tr><td class="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_exists_exception.html" title="Is thrown if a service is beeing registered that is already registered. ">ServiceExistsException</a></td><td>If a non-weak service has already been registered for TInterface</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the function returns successfully, from now on a service of the given type can be accessed via the registry for the interface. The service is lazy initialized an will be created as soon as it is requested for the first time. It is created by calling the given <code>fn</code> function.</p>
|
|
<p><code>fn</code> must have the following signature: </p><div class="fragment"><div class="line">TService *fn(...);</div></div><!-- fragment --><p> TService is the template parameter of this function. The arguments are variable, but if arguments are present, they all must be pointers of types that are injectable via the registry. When the function is called internally, the registry will "inject" all services as parameters of this function.</p>
|
|
<p>If the service is registered as weak, registering another service for the same interface will not throw an exception but instead discard (and delete) this one.</p>
|
|
<dl class="section attention"><dt>Attention</dt><dd>Make shure to register TInterface via <a class="el" href="namespace_qt_mvvm.html#ada3398eab54e79982c27bb4b7d8e4b9f" title="Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE. ">QtMvvm::registerInterfaceConverter</a>, otherwise injection for the interface is not possible.</dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5" title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <a class="el" href="namespace_qt_mvvm.html#ada3398eab54e79982c27bb4b7d8e4b9f" title="Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE. ">QtMvvm::registerInterfaceConverter</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6d904ac2abf387eb877dae3aad801848" title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00162">162</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="afad92a0b52150125c010913e3365d1ab"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#afad92a0b52150125c010913e3365d1ab">◆ </a></span>registerInterface() <span class="overload">[3/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename TInterface , typename TService > </div>
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::registerInterface </td>
|
|
<td>(</td>
|
|
<td class="paramtype">TService * </td>
|
|
<td class="paramname"><em>service</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>weak</em> = <code>false</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Register a service for its interface via an already existing instance. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">TInterface</td><td>The interface type to register the service for </td></tr>
|
|
<tr><td class="paramname">TService</td><td>The service to be registered for that interface. Must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> and implement TInterface </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">service</td><td>The service instance to be registered as service </td></tr>
|
|
<tr><td class="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_exists_exception.html" title="Is thrown if a service is beeing registered that is already registered. ">ServiceExistsException</a></td><td>If a non-weak service has already been registered for TInterface</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the function returns successfully, from now on a service of the given type can be accessed via the registry for the interface. The service instance is from that point on owned by the registry. No DI is performed on the passed service.</p>
|
|
<p>If the service is registered as weak, registering another service for the same interface will not throw an exception but instead discard (and delete) this one.</p>
|
|
<dl class="section attention"><dt>Attention</dt><dd>Make shure to register TInterface via <a class="el" href="namespace_qt_mvvm.html#ada3398eab54e79982c27bb4b7d8e4b9f" title="Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE. ">QtMvvm::registerInterfaceConverter</a>, otherwise injection for the interface is not possible.</dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5" title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <a class="el" href="namespace_qt_mvvm.html#ada3398eab54e79982c27bb4b7d8e4b9f" title="Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE. ">QtMvvm::registerInterfaceConverter</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6d904ac2abf387eb877dae3aad801848" title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00171">171</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a9c2f2166f4ecbd4b2f3ae0d0e4165ab5"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5">◆ </a></span>registerObject() <span class="overload">[1/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename TService > </div>
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::registerObject </td>
|
|
<td>(</td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>weak</em> = <code>false</code></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Register a service via its type. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">TService</td><td>The service to be registered by its own type. Must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_exists_exception.html" title="Is thrown if a service is beeing registered that is already registered. ">ServiceExistsException</a></td><td>If a non-weak service has already been registered for TService</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the function returns successfully, from now on a service of the given type can be accessed via the registry. The service is lazy initialized an will be created as soon as it is requested for the first time. If it has any injectable properties, they will be automatically injected on construction.</p>
|
|
<p>If the service is registered as weak, registering another service for the same TService will not throw an exception but instead discard (and delete) this one.</p>
|
|
<dl class="section attention"><dt>Attention</dt><dd>In order to be able to create the service, TService must have an invokable constructor with the following signature: <code>Q_INVOKABLE explicit TService(<a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = nullptr);</code></dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#abacfa0d81764df255df41e4ccf175ad8" title="Register a service for its interface via the type. ">ServiceRegistry::registerInterface</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6d904ac2abf387eb877dae3aad801848" title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00185">185</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="afaa2b66fdb3ead00d6b52ef0df4c4f61"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#afaa2b66fdb3ead00d6b52ef0df4c4f61">◆ </a></span>registerObject() <span class="overload">[2/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename TService , typename TFunc > </div>
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::registerObject </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const TFunc & </td>
|
|
<td class="paramname"><em>fn</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>weak</em> = <code>false</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Register a service via a constructor function. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">TService</td><td>The service to be registered by its own type. Must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> </td></tr>
|
|
<tr><td class="paramname">TFunc</td><td>The function type of the <code>fn</code> parameter. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">fn</td><td>The function to be called to construct the service </td></tr>
|
|
<tr><td class="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_exists_exception.html" title="Is thrown if a service is beeing registered that is already registered. ">ServiceExistsException</a></td><td>If a non-weak service has already been registered for TService</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the function returns successfully, from now on a service of the given type can be accessed via the registry. The service is lazy initialized an will be created as soon as it is requested for the first time. It is created by calling the given <code>fn</code> function.</p>
|
|
<p><code>fn</code> must have the following signature: </p><div class="fragment"><div class="line">TService *fn(...);</div></div><!-- fragment --><p> TService is the template parameter of this function. The arguments are variable, but if arguments are present, they all must be pointers of types that are injectable via theregistry. When the function is called internally, the registry will "inject" all services as parameters of this function.</p>
|
|
<p>If the service is registered as weak, registering another service for the same TService will not throw an exception but instead discard (and delete) this one.</p>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#abacfa0d81764df255df41e4ccf175ad8" title="Register a service for its interface via the type. ">ServiceRegistry::registerInterface</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6d904ac2abf387eb877dae3aad801848" title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00192">192</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a25ae0f6bd651835d90455d5540ea533b"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a25ae0f6bd651835d90455d5540ea533b">◆ </a></span>registerObject() <span class="overload">[3/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename TService > </div>
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::registerObject </td>
|
|
<td>(</td>
|
|
<td class="paramtype">TService * </td>
|
|
<td class="paramname"><em>service</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>weak</em> = <code>false</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Register a service via an already existing instance. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">TService</td><td>The service to be registered by its own type. Must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">service</td><td>The service instance to be registered as service </td></tr>
|
|
<tr><td class="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_exists_exception.html" title="Is thrown if a service is beeing registered that is already registered. ">ServiceExistsException</a></td><td>If a non-weak service has already been registered for TService</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the function returns successfully, from now on a service of the given type can be accessed via the registry. The service instance is from that point on owned by the registry. No DI is performed on the passed service.</p>
|
|
<p>If the service is registered as weak, registering another service for the same TService will not throw an exception but instead discard (and delete) this one.</p>
|
|
<dl class="section attention"><dt>Attention</dt><dd>Make shure to register TInterface via <a class="el" href="namespace_qt_mvvm.html#ada3398eab54e79982c27bb4b7d8e4b9f" title="Registers QVariant converters from QObject to an interface type registered with Q_DECLARE_INTERFACE. ">QtMvvm::registerInterfaceConverter</a>, otherwise injection for the interface is not possible.</dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#abacfa0d81764df255df41e4ccf175ad8" title="Register a service for its interface via the type. ">ServiceRegistry::registerInterface</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6d904ac2abf387eb877dae3aad801848" title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31" title="Returns the service for the given interface. ">ServiceRegistry::service</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00201">201</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a6d904ac2abf387eb877dae3aad801848"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a6d904ac2abf387eb877dae3aad801848">◆ </a></span>registerService() <span class="overload">[1/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::registerService </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearray.html">QByteArray</a> & </td>
|
|
<td class="paramname"><em>iid</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qmetaobject.html">QMetaObject</a> * </td>
|
|
<td class="paramname"><em>metaObject</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>weak</em> = <code>false</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Register a service by an iid via their metadata. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">iid</td><td>The interface id of the type to register the service for </td></tr>
|
|
<tr><td class="paramname">metaObject</td><td>The metaobject of the service to be registered for that interface. Must extend <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> and implement the interface of <code>iid</code>, unless it is the id of the service itself </td></tr>
|
|
<tr><td class="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_exists_exception.html" title="Is thrown if a service is beeing registered that is already registered. ">ServiceExistsException</a></td><td>If a non-weak service has already been registered for the iid</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the function returns successfully, from now on a service of the given metobject can be accessed via the registry for the iid. The service is lazy initialized an will be created as soon as it is requested for the first time. If it has any injectable properties, they will be automatically injected on construction.</p>
|
|
<p>If the service is registered as weak, registering another service for the same iid will not throw an exception but instead discard (and delete) this one.</p>
|
|
<dl class="section attention"><dt>Attention</dt><dd>In order to be able to create the service, the class defined by the metaobject must have an invokable constructor with the following signature: <code>Q_INVOKABLE explicit Service(<a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = nullptr);</code></dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5" title="Register a service via its type. ">ServiceRegistry::registerObject</a>, QtMvvm::registerInterface, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080" title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a342a6e90115c9a3657877c31ead01c56"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a342a6e90115c9a3657877c31ead01c56">◆ </a></span>registerService() <span class="overload">[2/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::registerService </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearray.html">QByteArray</a> & </td>
|
|
<td class="paramname"><em>iid</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const std::function< <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *(const QObjectList &)> & </td>
|
|
<td class="paramname"><em>fn</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype"><a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearraylist.html">QByteArrayList</a> </td>
|
|
<td class="paramname"><em>injectables</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>weak</em> = <code>false</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Register a service by an iid via a generalized constructor function. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">iid</td><td>The interface id of the type to register the service for </td></tr>
|
|
<tr><td class="paramname">fn</td><td>The function to be called to construct the service </td></tr>
|
|
<tr><td class="paramname">injectables</td><td>The iids of the parameters to be passed to <code>fn</code> </td></tr>
|
|
<tr><td class="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_exists_exception.html" title="Is thrown if a service is beeing registered that is already registered. ">ServiceExistsException</a></td><td>If a non-weak service has already been registered for the iid</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the function returns successfully, from now on a service of the given type can be accessed via the registry for the interface. The service is lazy initialized an will be created as soon as it is requested for the first time. It is created by calling the given <code>fn</code> function.</p>
|
|
<p>The function must return an object that implements the interface of <code>iid</code>, unless it is the id of the service itself. The arguments are passed as object list and are determined by the <code>injectables</code> parameter. That is a list of iids. When the function is called internally, the registry will "inject" all services found by the iids as parameters of this function, comnined to a list of objects.</p>
|
|
<p>If the service is registered as weak, registering another service for the same iid will not throw an exception but instead discard (and delete) this one.</p>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5" title="Register a service via its type. ">ServiceRegistry::registerObject</a>, QtMvvm::registerInterface, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080" title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a54085d3bac2c39f58c46165827686a31"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a54085d3bac2c39f58c46165827686a31">◆ </a></span>service()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename TInterface > </div>
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::service </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns the service for the given interface. </p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">TInterface</td><td>The interface type get an instance of </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>An object that implements the interface </dd></dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_construction_exception.html" title="Is thrown in case the construction of a service has failed. ">ServiceConstructionException</a></td><td>If the registry failed to create an instance for that interface</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the service is lazy inizialized and not created yet, the registry will do so. The returned service is owned by the registry. Be careful with weak services, as they may be deleted at any time. For normal services, this is never the case.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>TInterface can either be an actual interface or a service type, depending on what you registered it for (i.e. TInterface of the <a class="el" href="class_qt_mvvm_1_1_service_registry.html#abacfa0d81764df255df41e4ccf175ad8" title="Register a service for its interface via the type. ">registerInterface()</a> method and TService of the <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5" title="Register a service via its type. ">registerObject()</a> method</dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a9c2f2166f4ecbd4b2f3ae0d0e4165ab5" title="Register a service via its type. ">ServiceRegistry::registerObject</a>, QtMvvm::registerInterface, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080" title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769" title="Inject services for all injectable properties on object. ">ServiceRegistry::injectServices</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a3db366f49af65a3b7b79a5494bb69f19" title="Constructs a new instance of TClass with properties injected. ">ServiceRegistry::constructInjected</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="serviceregistry_8h_source.html#l00213">213</a> of file <a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="abff2c6776647fdb377860a3c3cca9080"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#abff2c6776647fdb377860a3c3cca9080">◆ </a></span>serviceObj()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">QtMvvm::ServiceRegistry::serviceObj </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const <a class="elRef" target="_blank" doxygen="/home/sky/Qt/Docs/Qt-5.10.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/" href="https://doc.qt.io/qt-5/qbytearray.html">QByteArray</a> & </td>
|
|
<td class="paramname"><em>iid</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns the service for the given iid. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">iid</td><td>The interface id of the type to get an instance of </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>An object that implements the interface specified by iid </dd></dl>
|
|
<dl class="exception"><dt>Exceptions</dt><dd>
|
|
<table class="exception">
|
|
<tr><td class="paramname"><a class="el" href="class_qt_mvvm_1_1_service_construction_exception.html" title="Is thrown in case the construction of a service has failed. ">ServiceConstructionException</a></td><td>If the registry failed to create an instance for that interface</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>If the service is lazy inizialized and not created yet, the registry will do so. The returned service is owned by the registry. Be careful with weak services, as they may be deleted at any time. For normal services, this is never the case.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>iid must be the identity the service has been registered for. This depends on the type itself and how it was registered.</dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6d904ac2abf387eb877dae3aad801848" title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080" title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769" title="Inject services for all injectable properties on object. ">ServiceRegistry::injectServices</a>, <a class="el" href="class_qt_mvvm_1_1_service_registry.html#a3db366f49af65a3b7b79a5494bb69f19" title="Constructs a new instance of TClass with properties injected. ">ServiceRegistry::constructInjected</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<hr/>The documentation for this class was generated from the following files:<ul>
|
|
<li><a class="el" href="serviceregistry_8h_source.html">serviceregistry.h</a></li>
|
|
<li>serviceregistry.dox</li>
|
|
</ul>
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Wed Mar 14 2018 16:19:59 for QtMvvm by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.14
|
|
</small></address>
|
|
</body>
|
|
</html>
|
|
|