Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QValueSpaceObject Class Reference
[QtBaseModule]

The QValueSpaceObject class allows applications to add entries to the Value Space. More...

    #include <QValueSpaceObject>

Inherits QObject.

Public Functions

  • 29 public functions inherited from QObject

Public Slots

  • 1 public slot inherited from QObject

Signals

  • void itemRemove ( const QByteArray & attribute )
  • void itemSetValue ( const QByteArray & attribute, const QVariant & value )

Static Public Members

  • 4 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public type inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

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.


Member Function Documentation

QValueSpaceObject::QValueSpaceObject ( const QByteArray & objectPath, QObject * parent = 0 )

Construct a Value Space object rooted at objectPath with the specified parent.

QValueSpaceObject::QValueSpaceObject ( const char * objectPath, QObject * parent = 0 )

Construct a Value Space object rooted at objectPath with the specified parent. This constructor is equivalent to QValueSpaceObject(QByteArray(objectPath), parent).

QValueSpaceObject::QValueSpaceObject ( const QString & objectPath, QObject * parent = 0 )

Construct a Value Space object rooted at objectPath with the specified parent. This constructor is equivalent to QValueSpaceObject(objectPath.toUtf8(), parent).

QValueSpaceObject::~QValueSpaceObject ()

Destroys the Value Space object. This will remove the object and all its attributes from the Value Space.

void QValueSpaceObject::itemRemove ( const QByteArray & attribute )   [signal]

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.

void QValueSpaceObject::itemSetValue ( const QByteArray & attribute, const QVariant & value )   [signal]

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.

QString QValueSpaceObject::objectPath () const

Returns the full path to this object as passed to the QValueSpaceObject constructor.

void QValueSpaceObject::removeAttribute ( const QByteArray & attribute )   [slot]

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();

void QValueSpaceObject::removeAttribute ( const QString & attribute )   [slot]

This is an overloaded member function, provided for convenience.

This is a convenience overload and is equivalent to removeAttribute(attribute.toUtf8()).

void QValueSpaceObject::removeAttribute ( const char * attribute )   [slot]

This is an overloaded member function, provided for convenience.

This is a convenience overload and is equivalent to removeAttribute(QByteArray(attribute)).

void QValueSpaceObject::setAttribute ( const QByteArray & attribute, const QVariant & data )   [slot]

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")

void QValueSpaceObject::setAttribute ( const char * attribute, const QVariant & data )   [slot]

This is an overloaded member function, provided for convenience.

This is a convenience overload and is equivalent to setAttribute(QByteArray(attribute), data).

void QValueSpaceObject::setAttribute ( const QString & attribute, const QVariant & data )   [slot]

This is an overloaded member function, provided for convenience.

This is a convenience overload and is equivalent to setAttribute(attribute.toUtf8(), data).

void QValueSpaceObject::sync ()   [static]

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.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web