<trclass="memdesc:aff6b990faf118b6305c6d6cd4cacb276"><tdclass="mdescLeft"> </td><tdclass="mdescRight">A scope to indicate when a service should be deleted. <ahref="class_qt_mvvm_1_1_service_registry.html#aff6b990faf118b6305c6d6cd4cacb276">More...</a><br/></td></tr>
<trclass="memdesc:a2fddc2077d76404550f037dfbd9029ca"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Checks if a given interface or service is already registered. <br/></td></tr>
<trclass="memdesc:a33106199077763388fabff116dc190e2"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Checks if a given interface or service is already registered. <br/></td></tr>
<trclass="memdesc:ab683dc8ccbb0e0198f0d5664b1f1f9ca"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service for its interface via the type. <ahref="#ab683dc8ccbb0e0198f0d5664b1f1f9ca">More...</a><br/></td></tr>
<trclass="memdesc:afb4dc088a24802160d9f9f01f69eaa2d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service for its interface via a constructor function. <ahref="#afb4dc088a24802160d9f9f01f69eaa2d">More...</a><br/></td></tr>
<trclass="memdesc:a7e0928c964a40cb88495c764d0b8627c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service for its interface via an already existing instance. <ahref="#a7e0928c964a40cb88495c764d0b8627c">More...</a><br/></td></tr>
<trclass="memdesc:ada266f18e940d48ac4030093955c55f9"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service via its type. <ahref="#ada266f18e940d48ac4030093955c55f9">More...</a><br/></td></tr>
<trclass="memdesc:abf7c09845abe552aa47206413ad983f8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service via a constructor function. <ahref="#abf7c09845abe552aa47206413ad983f8">More...</a><br/></td></tr>
<trclass="memdesc:a3cc1bdd66d9ac15b26e22bf1a8a39fd8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service via an already existing instance. <ahref="#a3cc1bdd66d9ac15b26e22bf1a8a39fd8">More...</a><br/></td></tr>
<trclass="memdesc:a24ea425f41f3919488e23c342193626f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service via specifing a plugin to be loaded. <ahref="#a24ea425f41f3919488e23c342193626f">More...</a><br/></td></tr>
<trclass="memdesc:a9fa590672277212bc246251b4a0f7f86"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service by an iid via their metadata. <ahref="#a9fa590672277212bc246251b4a0f7f86">More...</a><br/></td></tr>
<trclass="memdesc:a9f060ea798dc0b476107cbeb7d2fde9b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service by an iid via a generalized constructor function. <ahref="#a9f060ea798dc0b476107cbeb7d2fde9b">More...</a><br/></td></tr>
<trclass="memdesc:a4c75160366482ccae7085aac6821fead"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register a service by an iid via specifing a plugin to be loaded. <ahref="#a4c75160366482ccae7085aac6821fead">More...</a><br/></td></tr>
<trclass="memdesc:a54085d3bac2c39f58c46165827686a31"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the service for the given interface. <ahref="#a54085d3bac2c39f58c46165827686a31">More...</a><br/></td></tr>
<trclass="memdesc:abff2c6776647fdb377860a3c3cca9080"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the service for the given iid. <ahref="#abff2c6776647fdb377860a3c3cca9080">More...</a><br/></td></tr>
<trclass="memdesc:a6c3bf4e06311d321bdea7e78a4899769"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Inject services for all injectable properties on object. <ahref="#a6c3bf4e06311d321bdea7e78a4899769">More...</a><br/></td></tr>
<trclass="memdesc:a3db366f49af65a3b7b79a5494bb69f19"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Constructs a new instance of TClass with properties injected. <ahref="#a3db366f49af65a3b7b79a5494bb69f19">More...</a><br/></td></tr>
<trclass="memdesc:a18479634e9d4ba58ed03231ecf006c48"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Constructs a new instance of metaObject with properties injected. <ahref="#a18479634e9d4ba58ed03231ecf006c48">More...</a><br/></td></tr>
<trclass="memdesc:aabda69c79dc04cebfd2ebaea25e9ee62"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the <aclass="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>
<divclass="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 <aclass="el"href="class_qt_mvvm_1_1_view_model.html"title="The base class for all viewmodels. ">ViewModel</a> created by the <aclass="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>
<dlclass="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>
<divclass="fragment"><divclass="line"><spanclass="comment">// service.h</span></div><divclass="line"><spanclass="keyword">class </span>Service : <spanclass="keyword">public</span><aclass="codeRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a></div><divclass="line">{</div><divclass="line"> Q_OBJECT</div><divclass="line"></div><divclass="line"><spanclass="keyword">public</span>:</div><divclass="line"> Q_INVOKABLE <spanclass="keyword">explicit</span> Service(<aclass="codeRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a> *parent = <spanclass="keyword">nullptr</span>); <spanclass="comment">//required signature</span></div><divclass="line"></div><divclass="line"><spanclass="keyword">public</span> Q_SLOTS:</div><divclass="line"><spanclass="keywordtype">void</span> baum();</div><divclass="line"><spanclass="keywordtype">void</span> qtmvvm_init(); <spanclass="comment">//is called by the registry</span></div><divclass="line">};</div><divclass="line"></div><divclass="line"><spanclass="comment">// myclass.h</span></div><divclass="line"><spanclass="keyword">class </span>MyClass : <spanclass="keyword">public</span><aclass="codeRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtautoupdater/qtautoupdater.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/class_q_object.html">QObject</a></div><divclass="line">{</div><divclass="line"> Q_OBJECT</div><divclass="line"></div><divclass="line"><aclass="code"href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f">QTMVVM_INJECT_PROP</a>(Service*, <aclass="code"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31">service</a>, _service)</div><divclass="line"></div><divclass="line"><spanclass="comment">//...</span></div><divclass="line"><spanclass="keyword">private</span>:</div><divclass="line"> Service *_service;</div><divclass="line">};</div><divclass="line"></div><divclass="line"><spanclass="comment">//main.cpp</span></div><divclass="line"><spanclass="keywordtype">int</span> main(<spanclass="keywordtype">int</span> argc, <spanclass="keywordtype">char</span> *argv[])</div><divclass="line">{</div><divclass="line"><aclass="codeRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><divclass="line"><aclass="code"href="class_qt_mvvm_1_1_service_registry.html#aabda69c79dc04cebfd2ebaea25e9ee62">QtMvvm::ServiceRegistry::instance</a>()-><aclass="code"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9">registerObject</a><Service>();</div><divclass="line"></div><divclass="line"><spanclass="comment">//...</span></div><divclass="line"></div><divclass="line"><spanclass="keyword">auto</span> myObj = <spanclass="keyword">new</span> MyClass(parent);</div><divclass="line"><aclass="code"href="class_qt_mvvm_1_1_service_registry.html#aabda69c79dc04cebfd2ebaea25e9ee62">QtMvvm::ServiceRegistry::instance</a>()-><aclass="code"href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769">injectServices</a>(myObj);</div><divclass="line"><spanclass="comment">// _service is now initialized via a valid Service</span></div><divclass="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>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00017">17</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<p>A scope to indicate when a service should be deleted. </p>
<tableclass="fieldtable">
<tr><thcolspan="2">Enumerator</th></tr><tr><tdclass="fieldname"><aid="aff6b990faf118b6305c6d6cd4cacb276a7aac3331077c91c6ae5fe677b91b35c6"></a>DestroyOnAppQuit </td><tdclass="fielddoc"><p>Destroy when the <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qcoreapplication.html#aboutToQuit">QCoreApplication::aboutToQuit</a> signal is emitted. </p>
</td></tr>
<tr><tdclass="fieldname"><aid="aff6b990faf118b6305c6d6cd4cacb276a7a43a0e97844c62bf966b828fb2b7b45"></a>DestroyOnAppDestroy </td><tdclass="fielddoc"><p>Destroy as soon as the <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qcoreapplication.html">QCoreApplication</a> gets destroyed (typically end of main) </p>
</td></tr>
<tr><tdclass="fieldname"><aid="aff6b990faf118b6305c6d6cd4cacb276a2cf5729a4b8c072676f052b361c6397b"></a>DestroyOnRegistryDestroy </td><tdclass="fielddoc"><p>Destroy together with the service registry instance (static memory, unspecified order!) </p>
</td></tr>
<tr><tdclass="fieldname"><aid="aff6b990faf118b6305c6d6cd4cacb276aab3fbc747b7a7ba03fa19fe2d50704f7"></a>DestroyNever </td><tdclass="fielddoc"><p>Never destroy the instance. </p>
</td></tr>
</table>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00021">21</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
</div>
</div>
<h2class="groupheader">Member Function Documentation</h2>
<tr><tdclass="paramname">TClass</td><td>The type of object to be created, must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">parent</td><td>The parent object of the created object </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>A newly created instance of TClass. </dd></dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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 <aclass="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>
<dlclass="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(<aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769"title="Inject services for all injectable properties on object. ">ServiceRegistry::injectServices</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a>, <aclass="el"href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151"title="Mark a property for injection. ">QTMVVM_INJECT</a>, <aclass="el"href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f"title="Create a for injection marked property based on a member. ">QTMVVM_INJECT_PROP</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00254">254</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">metaObject</td><td>The metaobject of object type to be created, must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">parent</td><td>The parent object of the created object </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>A newly created instance of the given type. </dd></dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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 <aclass="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>
<dlclass="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(<aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769"title="Inject services for all injectable properties on object. ">ServiceRegistry::injectServices</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a>, <aclass="el"href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151"title="Mark a property for injection. ">QTMVVM_INJECT</a>, <aclass="el"href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f"title="Create a for injection marked property based on a member. ">QTMVVM_INJECT_PROP</a></dd></dl>
<p>Inject services for all injectable properties on object. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">object</td><td>The object to inject properties into </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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 <aclass="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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a3db366f49af65a3b7b79a5494bb69f19"title="Constructs a new instance of TClass with properties injected. ">ServiceRegistry::constructInjected</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a>, <aclass="el"href="injection_8h.html#a0a6e278ad53a06df6f32b1b636ec6151"title="Mark a property for injection. ">QTMVVM_INJECT</a>, <aclass="el"href="injection_8h.html#a6fae8ec64f64d9ef355df8d23d1daa6f"title="Create a for injection marked property based on a member. ">QTMVVM_INJECT_PROP</a></dd></dl>
<tr><tdclass="paramname">TService</td><td>The service to be registered for that interface. Must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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>
<dlclass="section attention"><dt>Attention</dt><dd>Make shure to register TInterface via <aclass="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(<aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <aclass="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>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a9fa590672277212bc246251b4a0f7f86"title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00184">184</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">TService</td><td>The service to be registered for that interface. Must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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><divclass="fragment"><divclass="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>
<dlclass="section attention"><dt>Attention</dt><dd>Make shure to register TInterface via <aclass="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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <aclass="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>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a9fa590672277212bc246251b4a0f7f86"title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00191">191</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">TService</td><td>The service to be registered for that interface. Must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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>
<dlclass="section attention"><dt>Attention</dt><dd>Make shure to register TInterface via <aclass="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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <aclass="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>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a9fa590672277212bc246251b4a0f7f86"title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00200">200</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">TService</td><td>The service to be registered by its own type. Must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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>
<dlclass="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(<aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ab683dc8ccbb0e0198f0d5664b1f1f9ca"title="Register a service for its interface via the type. ">ServiceRegistry::registerInterface</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a9fa590672277212bc246251b4a0f7f86"title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00214">214</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">TService</td><td>The service to be registered by its own type. Must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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><divclass="fragment"><divclass="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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ab683dc8ccbb0e0198f0d5664b1f1f9ca"title="Register a service for its interface via the type. ">ServiceRegistry::registerInterface</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a9fa590672277212bc246251b4a0f7f86"title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00221">221</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">TService</td><td>The service to be registered by its own type. Must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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>
<dlclass="section attention"><dt>Attention</dt><dd>Make shure to register TInterface via <aclass="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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ab683dc8ccbb0e0198f0d5664b1f1f9ca"title="Register a service for its interface via the type. ">ServiceRegistry::registerInterface</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a9fa590672277212bc246251b4a0f7f86"title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00230">230</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">TInterface</td><td>The interface type to register the service for </td></tr>
</table>
</dd>
</dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">pluginType</td><td>The kind of plugin to be loaded. Corresponds to the subdirectoy to find the plugin in </td></tr>
<tr><tdclass="paramname">pluginKey</td><td>The key to select the plugin by, if multiple are available </td></tr>
<tr><tdclass="paramname">scope</td><td>The scope at which the service instance should be destroyed </td></tr>
<tr><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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>
<p>To actually create the instance, the registry will try to find a matching plugin to load and instanciate it. The two parameters, pluginType and pluginKey are used to select a plugin.</p>
<p>pluginType referes to the kind of plugin, i.e. "imageformats", "platforms", ... The value can either be a relative path, which means it is resolved relative to the standard plugin directories the application uses to find <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qt.html">Qt</a> plugins (pluginType can be empty to directly look in the root folders). If the path is absolute, only that absolute folder is searched. For both cases, the search is non-recursive.</p>
<p>pluginKey is a key to select the actual plugin files from all the plugins available in the folder identified by pluginType. For that, the "Key" property of the metadata of each plugin is checked to find one that has the given key in the list. If not specified, one of the available plugins is randomly choosen.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ab683dc8ccbb0e0198f0d5664b1f1f9ca"title="Register a service for its interface via the type. ">ServiceRegistry::registerInterface</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <aclass="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>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a9fa590672277212bc246251b4a0f7f86"title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a54085d3bac2c39f58c46165827686a31"title="Returns the service for the given interface. ">ServiceRegistry::service</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00242">242</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">metaObject</td><td>The metaobject of the service to be registered for that interface. Must extend <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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><tdclass="paramname">scope</td><td>The scope at which the service instance should be destroyed </td></tr>
<tr><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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>
<dlclass="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(<aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.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>
<dlclass="section see"><dt>See also</dt><dd>QtMvvm::registerInterface, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080"title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a></dd></dl>
<tr><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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, combined 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>
<dlclass="section see"><dt>See also</dt><dd>QtMvvm::registerInterface, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080"title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a></dd></dl>
<p>Register a service by an iid via specifing a plugin to be loaded. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">iid</td><td>The interface id of the type to register the service for </td></tr>
<tr><tdclass="paramname">pluginType</td><td>The kind of plugin to be loaded. Corresponds to the subdirectoy to find the plugin in </td></tr>
<tr><tdclass="paramname">pluginKey</td><td>The key to select the plugin by, if multiple are available </td></tr>
<tr><tdclass="paramname">scope</td><td>The scope at which the service instance should be destroyed </td></tr>
<tr><tdclass="paramname">weak</td><td>Specifies if the registration should be a weak one or a normal one </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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. 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>
<p>To actually create the instance, the registry will try to find a matching plugin to load and instanciate it. The two parameters, pluginType and pluginKey are used to select a plugin.</p>
<p>pluginType referes to the kind of plugin, i.e. "imageformats", "platforms", ... The value can either be a relative path, which means it is resolved relative to the standard plugin directories the application uses to find <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qt.html">Qt</a> plugins (pluginType can be empty to directly look in the root folders). If the path is absolute, only that absolute folder is searched. For both cases, the search is non-recursive.</p>
<p>pluginKey is a key to select the actual plugin files from all the plugins available in the folder identified by pluginType. For that, the "Key" property of the metadata of each plugin is checked to find one that has the given key in the list. If not specified, one of the available plugins is randomly choosen.</p>
<dlclass="section see"><dt>See also</dt><dd>QtMvvm::registerInterface, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">ServiceRegistry::registerObject</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a24ea425f41f3919488e23c342193626f"title="Register a service via specifing a plugin to be loaded. ">ServiceRegistry::registerPlugin</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080"title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a></dd></dl>
<tr><tdclass="paramname">TInterface</td><td>The interface type get an instance of </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>An object that implements the interface </dd></dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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>
<dlclass="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 <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ab683dc8ccbb0e0198f0d5664b1f1f9ca"title="Register a service for its interface via the type. ">registerInterface()</a> method and TService of the <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">registerObject()</a> method</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#ada266f18e940d48ac4030093955c55f9"title="Register a service via its type. ">ServiceRegistry::registerObject</a>, QtMvvm::registerInterface, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080"title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769"title="Inject services for all injectable properties on object. ">ServiceRegistry::injectServices</a>, <aclass="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>
<pclass="definition">Definition at line <aclass="el"href="serviceregistry_8h_source.html#l00248">248</a> of file <aclass="el"href="serviceregistry_8h_source.html">serviceregistry.h</a>.</p>
<tr><tdclass="paramname">iid</td><td>The interface id of the type to get an instance of </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>An object that implements the interface specified by iid </dd></dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="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>
<dlclass="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>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a9fa590672277212bc246251b4a0f7f86"title="Register a service by an iid via their metadata. ">ServiceRegistry::registerService</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#abff2c6776647fdb377860a3c3cca9080"title="Returns the service for the given iid. ">ServiceRegistry::serviceObj</a>, <aclass="el"href="class_qt_mvvm_1_1_service_registry.html#a6c3bf4e06311d321bdea7e78a4899769"title="Inject services for all injectable properties on object. ">ServiceRegistry::injectServices</a>, <aclass="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>