Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
The QValueSpaceObject class allows applications to add entries to the Value Space. More...
#include <QValueSpaceObject>
Inherits QObject.
The QValueSpaceObject class allows applications to add entries to the Value Space.
For an overview of the Qt Extended Value Space, please see the QValueSpaceItem documentation.
The QValueSpaceObject class allows applications to write entries into the Value Space that are automatically removed when the QValueSpaceObject is destroyed, or the application exits either cleanly or abnormally. All applications in the system will have access to the data set through QValueSpaceObject and, if desired, can be notified when the data changes.
Although, logically, the Value Space is a simple collection of hierarchical paths, these paths can conceptually be visualized as a set of objects with attributes. For example, rather than viewing the following list as 12 distinct Value Space paths:
/Device/Network/Interfaces/eth0/Name /Device/Network/Interfaces/eth0/Type /Device/Network/Interfaces/eth0/Status /Device/Network/Interfaces/eth0/BytesSent /Device/Network/Interfaces/eth0/BytesReceived /Device/Network/Interfaces/eth0/Time /Device/Network/Interfaces/ppp0/Name /Device/Network/Interfaces/ppp0/Type /Device/Network/Interfaces/ppp0/Status /Device/Network/Interfaces/ppp0/BytesSent /Device/Network/Interfaces/ppp0/BytesReceived /Device/Network/Interfaces/ppp0/Time
it can be thought of as describing two Value Space objects, { /Device/Network/Interfaces/eth0, /Device/Network/Interfaces/ppp0 }, each with the six attributes {Name, Type, Status, BytesSent, BytesReceived, Time}. The QValueSpaceObject class encapsulates this abstraction.
In the case of two or more applications creating an application object with overlapping attributes, only the first is visible to observers in the system. The other attributes are not discarded, but are buffered until the first releases its hold on the attribute, either by manually removing it, destroying the QValueSpaceObject or by terminating. For example:
QValueSpaceObject * object1 = new QValueSpaceObject("/Device"); object1->setAttribute("Buttons", 2); // QValueSpaceItem("/Device/Buttons") == QVariant(2) QValueSpaceObject * object2 = new QValueSpaceObject("/Device"); object2->setAttribute("Buttons", 3); // QValueSpaceItem("/Device/Buttons") == QVariant(2) object2->removeAttribute("Buttons"); // QValueSpaceItem("/Device/Buttons") == QVariant(3)
For performance reasons the setting of and removing of attributes is buffered internally by the QValueSpaceObject and applied as a batch sometime later. Normally this occurs the next time the application enters the Qt event loop, but this behaviour should not be relied apon. If an application must synchronize application objects with others, the QValueSpaceObject::sync() method can be used to force the application of changes. This call is generally unnecessary, and should be used sparingly to prevent unnecessary load on the system.
Note: The QValueSpaceObject class is not thread safe and may only be used from an application's main thread.
See also QValueSpaceItem.
Construct a Value Space object rooted at objectPath with the specified parent.
Construct a Value Space object rooted at objectPath with the specified parent. This constructor is equivalent to QValueSpaceObject(QByteArray(objectPath), parent).
Construct a Value Space object rooted at objectPath with the specified parent. This constructor is equivalent to QValueSpaceObject(objectPath.toUtf8(), parent).
Destroys the Value Space object. This will remove the object and all its attributes from the Value Space.
Emitted whenever a client requests that the attribute be removed through a call to QValueSpaceItem::remove(). The provider of this object may choose to honor, ignore or transform the remove request.
Emitted whenever a client requests that the attribute value be changed to value through a call to QValueSpaceItem::setValue(). The provider of this object may chose to honor, ignore or transform the set value request.
Returns the full path to this object as passed to the QValueSpaceObject constructor.
Removes the object attribute and all sub-attributes from the system.
For example:
QValueSpaceObject object("/Device"); object.setAttribute("State", "Starting"); object.setAttribute("State/Memory", "1000"); object.sync(); // QValueSpaceItem("/Device/State").value() == QVariant("Starting") // QValueSpaceItem("/Device/State/Memory").value() == QVariant("1000") object.removeAttribute("State"); object.sync(); // QValueSpaceItem("/Device/State").value() == QVariant(); // QValueSpaceItem("/Device/State/Memory").value() == QVariant();
This is an overloaded member function, provided for convenience.
This is a convenience overload and is equivalent to removeAttribute(attribute.toUtf8()).
This is an overloaded member function, provided for convenience.
This is a convenience overload and is equivalent to removeAttribute(QByteArray(attribute)).
Set an attribute on the object to data. If attribute is empty, this call will set the object's value.
For example:
QValueSpaceObject object("/Device");
object.setAttribute("State", "Starting");
object.sync();
// QValueSpaceItem("/Device/State").value() == QVariant("Starting")
This is an overloaded member function, provided for convenience.
This is a convenience overload and is equivalent to setAttribute(QByteArray(attribute), data).
This is an overloaded member function, provided for convenience.
This is a convenience overload and is equivalent to setAttribute(attribute.toUtf8(), data).
Forcibly sync all Value Space objects.
For performance reasons attribute changes are batched internally by QValueSpaceObject instances. In cases where the visibility of changes must be synchronized with other processes, calling QValueSpaceObject::sync() will flush these batches. By the time sync() returns, all other processes in the system will be able to see the attribute changes.
In the common asynchronous case, calling sync() is unnecessary.
Copyright © 2009 Trolltech | Trademarks | Qt Extended 4.4.3 |