<commit_before>/****************************************************************************
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact:  Nokia Corporation (<EMAIL>)**
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met:  http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.  
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.  
**
** If you have questions regarding the use of this file, please
** contact Nokia at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qvaluespace.h"
#include "qvaluespace_p.h"
#include "qvaluespacemanager_p.h"
#include "qmallocpool_p.h"
#include "qvaluespaceobject.h"
#include "qpacketprotocol_p.h"

#include <QByteArray>
#include <QObject>
#include <QMap>
#include <QPair>
#include <QCoreApplication>
#include <QThread>
#include <QSet>
#include <QString>
#include <QVarLengthArray>

#include <QtCore/qdebug.h>

QT_BEGIN_NAMESPACE

/*!
    \class QAbstractValueSpaceLayer
    \brief The QAbstractValueSpaceLayer class provides support for adding new logical data layers
           to the Qt Value Space.

    To create a new layer in the Value Space subclass this class and reimplement all of the virtual
    functions.  The new layer is installed by either calling QValueSpace::installLayer() or by
    adding the QVALUESPACE_AUTO_INSTALL_LAYER() macro in your implementation file.
*/

/*!
    \macro QVALUESPACE_AUTO_INSTALL_LAYER(className)

    \relates QAbstractValueSpaceLayer

    This macro installs new value space layer. \a className is the name of the class implementing
    the new layer.

    The method \c {className *className::instance()} must exist and return a pointer to an instance
    of the layer to install.  This method will only be invoked \i {after} QApplication has been
    constructed, making it safe to use any Qt class in your layer's constructor.

    This macro can only be used once for any given class and it should be used where the
    implementation is written rather than in a header file.
*/

/*!
    \typedef QAbstractValueSpaceLayer::Handle

    The Handle type is an opaque, pointer sized contextual handle used to represent paths within
    value space layers.  Handles are only ever created by QAbstractValueSpaceLayer::item() and are
    always released by calls to QAbstractValueSpaceLayer::removeHandle().  The special value,
    \c {InvalidHandle} is reserved to represent an invalid handle.
*/

/*!
    \enum QAbstractValueSpaceLayer::Type

    Value Space layers are initialized in either a "Server" or a "Client" context.  There is only
    a single server in the value space architecture, and its layers are always initialized before
    any clients.  This distinction allows layers to implement Client/Server architecture
    \i {if required}.  If not, layers are free to treat Server and Client contexts identically.

    \value Server The layer is being initialized in the "server" context.
    \value Client The layer is being initialized in the "client" context.
*/

/*!
    \enum QAbstractValueSpaceLayer::Properties

    To allow for efficient layer implementations, expensive handle operations, currently only
    monitoring for changes, are enabled and disabled as needed on a per-handle basis.  The
    Properties enumeration is a bitmask representing the different properties that can exist on a
    handle.

    \value Publish Enable change notification for the handle.  When set, the layer should emit
                   QAbstractValueSpaceLayer::handleChanged() signals when appropriate for the
                   handle.
*/

/*!
    \fn QString QAbstractValueSpaceLayer::name()

    Returns the name of the Value Space layer.  This name is only used for diagnostics purposes.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::startup(Type type)

    Called by the Value Space system to initialize each layer.  The \a type parameter will be set
    accordingly, and layer implementors can use this to implement a client/server architecture if
    desired.

    Returns true upon success; otherwise returns false.
*/

/*!
    \fn QUuid QAbstractValueSpaceLayer::id()

    Returns a globally unique identifier for the layer.  This id is used to break ordering ties.
*/

/*!
    \fn unsigned int QAbstractValueSpaceLayer::order()

    Return the position in the Value Space layer stack that this layer should reside.  Higher
    numbers mean the layer has a higher precedence and its values will "shadow" those below it.
    If two layers specify the same ordering, the id() value is used to break the tie.
*/

/*!
    \fn Handle QAbstractValueSpaceLayer::item(Handle parent, const QByteArray &subPath)

    Returns a new opaque handle for the requested \a subPath of \a parent.  If \a parent is an
    InvalidHandle, \a subPath is interpreted as an absolute path.

    The caller should call removeHandle() to free resources used by the handle when it is no longer
    required.
*/

/*!
    \fn void QAbstractValueSpaceLayer::removeHandle(Handle handle)

    Releases a \a handle previously returned from QAbstractValueSpaceLayer::item().
*/

/*!
    \fn void QAbstractValueSpaceLayer::setProperty(Handle handle, Properties property)

    Apply the specified \a property mask to \a handle.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::value(Handle handle, QVariant *data)

    Returns the value for a particular \a handle.  If a value is available, the layer will set
    \a data and return true.  If no value is available, false is returned.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::value(Handle handle, const QByteArray &subPath, QVariant *data)

    Returns the value for a particular \a subPath of \a handle.  If a value is available, the
    layer will set \a data and return true.  If no value is available, false is returned.
*/

/*!
    \fn QSet<QByteArray> QAbstractValueSpaceLayer::children(Handle handle)

    Returns the set of children of \a handle.  For example, in a layer providing the following
    items:

    \code
        /Device/Configuration/Applications/FocusedApplication
        /Device/Configuration/Buttons/PrimaryInput
        /Device/Configuration/Name
    \endcode

    a request for children of "/Device/Configuration" will return
    { "Applications", "Buttons", "Name" }.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::supportsRequests() const

    Returns true if the layer supports sending requests via the requestSetValue() and
    requestRemoveValue() functions; otherwise returns false.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::requestSetValue(Handle handle, const QVariant &value)

    Process a client side QValueSpaceItem::setValue() call by sending a request to the provider of
    the value space item identified by \a handle to set it to \a value.

    Returns true if the request was successfully sent; otherwise returns false.

    \sa handleChanged()
*/

/*!
    \fn bool QAbstractValueSpaceLayer::requestSetValue(Handle handle, const QByteArray &subPath, const QVariant &value)

    Process a client side QValueSpaceItem::setValue() call by sending a request to the provider of
    the value space item identified by \a handle and \a subPath to set the value to \a value.
<commit_msg>Document layerOptions().<commit_after>/****************************************************************************
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact:  Nokia Corporation (<EMAIL>)**
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met:  http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.  
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.  
**
** If you have questions regarding the use of this file, please
** contact Nokia at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qvaluespace.h"
#include "qvaluespace_p.h"
#include "qvaluespacemanager_p.h"
#include "qmallocpool_p.h"
#include "qvaluespaceobject.h"
#include "qpacketprotocol_p.h"

#include <QByteArray>
#include <QObject>
#include <QMap>
#include <QPair>
#include <QCoreApplication>
#include <QThread>
#include <QSet>
#include <QString>
#include <QVarLengthArray>

#include <QtCore/qdebug.h>

QT_BEGIN_NAMESPACE

/*!
    \class QAbstractValueSpaceLayer
    \brief The QAbstractValueSpaceLayer class provides support for adding new logical data layers
           to the Qt Value Space.

    To create a new layer in the Value Space subclass this class and reimplement all of the virtual
    functions.  The new layer is installed by either calling QValueSpace::installLayer() or by
    adding the QVALUESPACE_AUTO_INSTALL_LAYER() macro in your implementation file.
*/

/*!
    \enum QAbstractValueSpaceLayer::LayerOption

    This enum describes the behaviour of the Value Space layer.  In addition this enum is used as
    a filter when constructing a QValueSpaceObject or QValueSpaceItem.

    \value UnspecifiedLayer     Used as a filter to specify that any layer should be used.
    \value PermanentLayer       Indicates that the layer uses a permanent backing store.  When used
                                as a filter only layers that use a permanent backing store will be
                                used.
    \value NonPermanentLayer    Indicates that the layer does not use a permanent backing store.
                                When used as a filter only layers that do not use permanent backing
                                stores will be used.
    \value WriteableLayer       Indicates that the layer can update its contents.  When used as a
                                filter only layers that are writeable will be used.
    \value NonWriteableLayer    Indicates that the layer cannot update its contents.  When used as
                                a filter only layers that are read-only will be used.
*/

/*!
    \macro QVALUESPACE_AUTO_INSTALL_LAYER(className)

    \relates QAbstractValueSpaceLayer

    This macro installs new value space layer. \a className is the name of the class implementing
    the new layer.

    The method \c {className *className::instance()} must exist and return a pointer to an instance
    of the layer to install.  This method will only be invoked \i {after} QApplication has been
    constructed, making it safe to use any Qt class in your layer's constructor.

    This macro can only be used once for any given class and it should be used where the
    implementation is written rather than in a header file.
*/

/*!
    \typedef QAbstractValueSpaceLayer::Handle

    The Handle type is an opaque, pointer sized contextual handle used to represent paths within
    value space layers.  Handles are only ever created by QAbstractValueSpaceLayer::item() and are
    always released by calls to QAbstractValueSpaceLayer::removeHandle().  The special value,
    \c {InvalidHandle} is reserved to represent an invalid handle.
*/

/*!
    \enum QAbstractValueSpaceLayer::Type

    Value Space layers are initialized in either a "Server" or a "Client" context.  There is only
    a single server in the value space architecture, and its layers are always initialized before
    any clients.  This distinction allows layers to implement Client/Server architecture
    \i {if required}.  If not, layers are free to treat Server and Client contexts identically.

    \value Server The layer is being initialized in the "server" context.
    \value Client The layer is being initialized in the "client" context.
*/

/*!
    \enum QAbstractValueSpaceLayer::Properties

    To allow for efficient layer implementations, expensive handle operations, currently only
    monitoring for changes, are enabled and disabled as needed on a per-handle basis.  The
    Properties enumeration is a bitmask representing the different properties that can exist on a
    handle.

    \value Publish Enable change notification for the handle.  When set, the layer should emit
                   QAbstractValueSpaceLayer::handleChanged() signals when appropriate for the
                   handle.
*/

/*!
    \fn QString QAbstractValueSpaceLayer::name()

    Returns the name of the Value Space layer.  This name is only used for diagnostics purposes.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::startup(Type type)

    Called by the Value Space system to initialize each layer.  The \a type parameter will be set
    accordingly, and layer implementors can use this to implement a client/server architecture if
    desired.

    Returns true upon success; otherwise returns false.
*/

/*!
    \fn QUuid QAbstractValueSpaceLayer::id()

    Returns a globally unique identifier for the layer.  This id is used to break ordering ties.
*/

/*!
    \fn unsigned int QAbstractValueSpaceLayer::order()

    Return the position in the Value Space layer stack that this layer should reside.  Higher
    numbers mean the layer has a higher precedence and its values will "shadow" those below it.
    If two layers specify the same ordering, the id() value is used to break the tie.
*/

/*!
    \fn Handle QAbstractValueSpaceLayer::item(Handle parent, const QByteArray &subPath)

    Returns a new opaque handle for the requested \a subPath of \a parent.  If \a parent is an
    InvalidHandle, \a subPath is interpreted as an absolute path.

    The caller should call removeHandle() to free resources used by the handle when it is no longer
    required.
*/

/*!
    \fn void QAbstractValueSpaceLayer::removeHandle(Handle handle)

    Releases a \a handle previously returned from QAbstractValueSpaceLayer::item().
*/

/*!
    \fn void QAbstractValueSpaceLayer::setProperty(Handle handle, Properties property)

    Apply the specified \a property mask to \a handle.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::value(Handle handle, QVariant *data)

    Returns the value for a particular \a handle.  If a value is available, the layer will set
    \a data and return true.  If no value is available, false is returned.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::value(Handle handle, const QByteArray &subPath, QVariant *data)

    Returns the value for a particular \a subPath of \a handle.  If a value is available, the
    layer will set \a data and return true.  If no value is available, false is returned.
*/

/*!
    \fn QSet<QByteArray> QAbstractValueSpaceLayer::children(Handle handle)

    Returns the set of children of \a handle.  For example, in a layer providing the following
    items:

    \code
        /Device/Configuration/Applications/FocusedApplication
        /Device/Configuration/Buttons/PrimaryInput
        /Device/Configuration/Name
    \endcode

    a request for children of "/Device/Configuration" will return
    { "Applications", "Buttons", "Name" }.
*/

/*!
    \fn QAbstractValueSpaceLayer::LayerOptions QAbstractValueSpaceLayer::layerOptions() const

    Returns the LayerOptions describing this layer.

    \sa LayerOption
*/

/*!
    \fn bool QAbstractValueSpaceLayer::supportsRequests() const

    Returns true if the layer supports sending requests via the requestSetValue() and
    requestRemoveValue() functions; otherwise returns false.
*/

/*!
    \fn bool QAbstractValueSpaceLayer::requestSetValue(Handle handle, const QVariant &value)

    Process a client side QValueSpaceItem::setValue() call by sending a request to the provider of
    the value space item identified by \a handle to set it to \a value.

    Returns true if the request was successfully sent; otherwise returns false.

    \sa handleChanged()
*/

/*!
    \fn bool QAbstractValueSpaceLayer::requestSetValue(Handle handle, const QByteArray &subPath, const QVariant &value)

    Process a client side QValueSpaceItem::setValue() call by sending a request to the provider of
    the value space item identified by \a handle and \a subPath to set the value to \a value.

{'fraction_non_alphanumeric': 0.08244153785176378, 'fraction_numerical': 0.001811901930807995, 'mean_word_length': 3.5756476683937826, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '478439', 'n_tokens_mistral': 4530, 'n_tokens_neox': 4352, 'n_words': 2116}