|
QtCanpool 3.3.0
|
The meeting point for two plugins that want to cooperate. 更多...
#include <qxplugin/qxobjectpool.h>

Public 成员函数 | |
| QxObjectPool (QObject *parent=Q_NULLPTR) | |
| ~QxObjectPool () override | |
| void | addObject (QObject *object) |
| Publishes object under its objectName(). | |
| void | removeObject (QObject *object) |
| Takes object out. | |
| QList< QObject * > | objects () const |
| Everything published and still alive, in the order it was published. | |
| QObject * | objectByName (const QString &name) const |
| The first live published object whose objectName() is name, or null. | |
| template<typename T > | |
| T * | object () const |
| The first live published object castable to T, or null. | |
| void | objectAdded (QObject *object) |
| Emitted after object joined the pool. | |
| void | aboutToRemoveObject (QObject *object) |
| Emitted just before removeObject() takes object out. | |
The meeting point for two plugins that want to cooperate.
A plugin is handed a QxPluginContext and no handle to its peers, so the two ends of any plugin-to-plugin agreement - "I have a line worth reporting" and "I have somewhere to put it" - have no way to find each other by themselves. This is where the providing end puts what it offers, and where the wanting end looks for it:
What comes back is what somebody chose to put in - publishing is deliberate, so a plugin that publishes nothing stays unreachable - and it is typed only as far as QObject, which is what lets the two ends agree without either including the other's header.
The pool owns nothing. Its entries are guarded pointers, so an object that is destroyed leaves the pool by itself: a publisher that is unloaded mid-session cannot leave a dangling pointer behind, and never has to remember to clean up. Deleting the object is still the business of whoever created it.
A host reaches this through QxPluginContext, which hands over the host's own pool; it is the context - not the manager - that a plugin sees.
在文件 qxobjectpool.h 第 49 行定义.
|
explicit |
在文件 qxobjectpool.cpp 第 9 行定义.
|
overridedefault |
| void QxPlugin::QxObjectPool::aboutToRemoveObject | ( | QObject * | object | ) |
Emitted just before removeObject() takes object out.
An object that is simply destroyed leaves without this - the pool finds out from the pointer going null, by which time there is nothing useful left to announce. Subscribe to that object's own destroyed() signal if the moment of its death matters to you.
| void QxPlugin::QxObjectPool::addObject | ( | QObject * | object | ) |
Publishes object under its objectName().
Publishing the same object twice changes nothing; a null object is ignored.
在文件 qxobjectpool.cpp 第 16 行定义.
|
inline |
The first live published object castable to T, or null.
Use this when the consumer and the provider share a declaration of T - a host service, or a type both sides link the same library for. When they share nothing at all, objectByName() is the lookup that still works, and what comes back is driven through the meta-object.
在文件 qxobjectpool.h 第 77 行定义.
| void QxPlugin::QxObjectPool::objectAdded | ( | QObject * | object | ) |
Emitted after object joined the pool.
| QObject * QxPlugin::QxObjectPool::objectByName | ( | const QString & | name | ) | const |
The first live published object whose objectName() is name, or null.
在文件 qxobjectpool.cpp 第 53 行定义.
| QList< QObject * > QxPlugin::QxObjectPool::objects | ( | ) | const |
Everything published and still alive, in the order it was published.
在文件 qxobjectpool.cpp 第 40 行定义.
| void QxPlugin::QxObjectPool::removeObject | ( | QObject * | object | ) |
Takes object out.
The object is not deleted, and an unknown one is a no-op.
在文件 qxobjectpool.cpp 第 27 行定义.