<commit_before>/*************************************************************************
 *
 *  $RCSfile: constant.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: kz $ $Date: 2004-01-28 15:11:03 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License") You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _FILTER_CONFIG_CONSTANT_HXX_
#define _FILTER_CONFIG_CONSTANT_HXX_

#include "macros.hxx"

/*  disable impl_loadOnDemand function of BaseContainer for certain
    functions, where it the feature "impl_loadItemOnDemand() of class FilterCache
    can be used instead of loadAll()!*/
#define LOAD_IMPLICIT

//_______________________________________________

/** @short  used to identify a some generic item properties against the
            configuration API and can be used at all name containers
            (based on this filtercache) too.
 */
#define  PROPNAME_NAME  _FILTER_CONFIG_FROM_ASCII_("Name")

/** @short  used to identify a type item property against the
            configuration API and can be used at all name containers
            (based on this filtercache) too.
 */
#define  PROPNAME_UINAME            _FILTER_CONFIG_FROM_ASCII_("UIName"          )
#define  PROPNAME_UINAMES           _FILTER_CONFIG_FROM_ASCII_("UINames"         )
#define  PROPNAME_PREFERRED         _FILTER_CONFIG_FROM_ASCII_("Preferred"       )
#define  PROPNAME_PREFERREDFILTER   _FILTER_CONFIG_FROM_ASCII_("PreferredFilter" )
#define  PROPNAME_DETECTSERVICE     _FILTER_CONFIG_FROM_ASCII_("DetectService"   )
#define  PROPNAME_MEDIATYPE         _FILTER_CONFIG_FROM_ASCII_("MediaType"       )
#define  PROPNAME_CLIPBOARDFORMAT   _FILTER_CONFIG_FROM_ASCII_("ClipboardFormat" )
#define  PROPNAME_URLPATTERN        _FILTER_CONFIG_FROM_ASCII_("URLPattern"      )
#define  PROPNAME_EXTENSIONS        _FILTER_CONFIG_FROM_ASCII_("Extensions"      )

/** @short  used to identify a filter item property against the
            configuration API and can be used at all name containers
            (based on this filtercache) too.
 */
#define  PROPNAME_TYPE              _FILTER_CONFIG_FROM_ASCII_("Type"             )
#define  PROPNAME_DOCUMENTSERVICE   _FILTER_CONFIG_FROM_ASCII_("DocumentService"  )
#define  PROPNAME_FILTERSERVICE     _FILTER_CONFIG_FROM_ASCII_("FilterService"    )
#define  PROPNAME_UICOMPONENT       _FILTER_CONFIG_FROM_ASCII_("UIComponent"      )
#define  PROPNAME_FLAGS             _FILTER_CONFIG_FROM_ASCII_("Flags"            )
#define  PROPNAME_USERDATA          _FILTER_CONFIG_FROM_ASCII_("UserData"         )
#define  PROPNAME_TEMPLATENAME      _FILTER_CONFIG_FROM_ASCII_("TemplateName"     )
#define  PROPNAME_FILEFORMATVERSION _FILTER_CONFIG_FROM_ASCII_("FileFormatVersion")

/** @short  used to identify a frame loader or detect service item
            property against the configuration API and can be used
            at all name containers (based on this filtercache) too.
 */
#define  PROPNAME_TYPES     _FILTER_CONFIG_FROM_ASCII_("Types")

/** @short  used to identify a set of items against the configuration API. */
#define  CFGSET_TYPES               _FILTER_CONFIG_FROM_ASCII_("Types"          )
#define  CFGSET_FILTERS             _FILTER_CONFIG_FROM_ASCII_("Filters"        )
#define  CFGSET_FRAMELOADERS        _FILTER_CONFIG_FROM_ASCII_("FrameLoaders"   )
#define  CFGSET_CONTENTHANDLERS     _FILTER_CONFIG_FROM_ASCII_("ContentHandlers")

/** @short  used to adress some configuration keys directly.

    @descr  Such direct keys should be used with function
            FilterCache::impl_getDirectCFGValue() only!

    @TODO   define these direct keys ...
 */
#define  CFGDIRECTKEY_OFFICELOCALE          _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/L10N/ooLocale"                           )
#define  CFGDIRECTKEY_DEFAULTFRAMELOADER    _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.TypeDetection.Misc/Defaults/DefaultFrameLoader")
#define  CFGDIRECTKEY_OFFICELOCALE          _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/L10N/ooLocale"                           )
#define  CFGDIRECTKEY_FORMATNAME            _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/Product/ooXMLFileFormatName"             )
#define  CFGDIRECTKEY_FORMATVERSION         _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/Product/ooXMLFileFormatVersion"          )
#define  CFGDIRECTKEY_PRODUCTNAME           _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/Product/ooName"                          )

/** @short  names of filter flags. */
#define  FLAGNAME_3RDPARTYFILTER    _FILTER_CONFIG_FROM_ASCII_("3RDPARTYFILTER"   )
#define  FLAGNAME_ALIEN             _FILTER_CONFIG_FROM_ASCII_("ALIEN"            )
#define  FLAGNAME_ASYNCHRON         _FILTER_CONFIG_FROM_ASCII_("ASYNCHRON"        )
#define  FLAGNAME_BROWSERPREFERRED  _FILTER_CONFIG_FROM_ASCII_("BROWSERPREFERRED" )
#define  FLAGNAME_CONSULTSERVICE    _FILTER_CONFIG_FROM_ASCII_("CONSULTSERVICE"   )
#define  FLAGNAME_DEFAULT           _FILTER_CONFIG_FROM_ASCII_("DEFAULT"          )
#define  FLAGNAME_EXPORT            _FILTER_CONFIG_FROM_ASCII_("EXPORT"           )
#define  FLAGNAME_IMPORT            _FILTER_CONFIG_FROM_ASCII_("IMPORT"           )
#define  FLAGNAME_INTERNAL          _FILTER_CONFIG_FROM_ASCII_("INTERNAL"         )
#define  FLAGNAME_NOTINCHOOSER      _FILTER_CONFIG_FROM_ASCII_("NOTINCHOOSER"     )
#define  FLAGNAME_NOTINFILEDIALOG   _FILTER_CONFIG_FROM_ASCII_("NOTINFILEDIALOG"  )
#define  FLAGNAME_NOTINSTALLED      _FILTER_CONFIG_FROM_ASCII_("NOTINSTALLED"     )
#define  FLAGNAME_OWN               _FILTER_CONFIG_FROM_ASCII_("OWN"              )
#define  FLAGNAME_PACKED            _FILTER_CONFIG_FROM_ASCII_("PACKED"           )
#define  FLAGNAME_PREFERRED         _FILTER_CONFIG_FROM_ASCII_("PREFERRED"        )
#define  FLAGNAME_READONLY          _FILTER_CONFIG_FROM_ASCII_("READONLY"         )
#define  FLAGNAME_SILENTEXPORT      _FILTER_CONFIG_FROM_ASCII_("SILENTEXPORT"     )
#define  FLAGNAME_SUPPORTSSELECTION _FILTER_CONFIG_FROM_ASCII_("SUPPORTSSELECTION")
#define  FLAGNAME_TEMPLATE          _FILTER_CONFIG_FROM_ASCII_("TEMPLATE"         )
#define  FLAGNAME_TEMPLATEPATH      _FILTER_CONFIG_FROM_ASCII_("TEMPLATEPATH"     )
#define  FLAGNAME_USESOPTIONS       _FILTER_CONFIG_FROM_ASCII_("USESOPTIONS"      )
#define  FLAGNAME_COMBINED          _FILTER_CONFIG_FROM_ASCII_("COMBINED"         )

/** @short  values of filter flags */
#define  FLAGVAL_3RDPARTYFILTER    0x00080000 // 524288
#define  FLAGVAL_ALIEN             0x00000040 // 64
#define  FLAGVAL_ALL               0xffffffff // 4294967295
#define  FLAGVAL_ASYNCHRON         0x00004000 // 16384
#define  FLAGVAL_BROWSERPREFERRED  0x00400000 // 4194304
#define  FLAGVAL_CONSULTSERVICE    0x00040000 // 262144
#define  FLAGVAL_DEFAULT           0x00000100 // 256
#define  FLAGVAL_EXPORT            0x00000002 // 2
#define  FLAGVAL_IMPORT            0x00000001 // 1
#define  FLAGVAL_INTERNAL          0x00000008 // 8
#define  FLAGVAL_NOTINCHOOSER      0x00002000 // 8192
#define  FLAGVAL_NOTINFILEDIALOG   0x00001000 // 4096
#define  FLAGVAL_NOTINSTALLED      0x00020000 // 131072
#define  FLAGVAL_OWN               0x00000020 // 32
#define  FLAGVAL_PACKED            0x00100000 // 1048576
#define  FLAGVAL_PREFERRED         0x10000000 // 268435456
#define  FLAGVAL_READONLY          0x00010000 // 65536
#define  FLAGVAL_SILENTEXPORT      0x00200000 // 2097152
#define  FLAGVAL_SUPPORTSSELECTION 0x00000400 // 1024
#define  FLAGVAL_TEMPLATE          0x00000004 // 4
#define  FLAGVAL_TEMPLATEPATH      0x00000010 // 16
#define  FLAGVAL_USESOPTIONS       0x00000080 // 128
#define  FLAGVAL_COMBINED          0x00800000 // 8388608

/** @short  uno service names of our document services
            provided by our application modules.
 */
#define  DOCUMENTSERVICE_WRITER         _FILTER_CONFIG_FROM_ASCII_("com.sun.star.text.TextDocument"                )
#define  DOCUMENTSERVICE_WRITER_WEB     _FILTER_CONFIG_FROM_ASCII_("com.sun.star.text.WebDocument"                 )
#define  DOCUMENTSERVICE_WRITER_GLOBAL  _FILTER_CONFIG_FROM_ASCII_("com.sun.star.text.GlobalDocument"              )
#define  DOCUMENTSERVICE_CALC           _FILTER_CONFIG_FROM_ASCII_("com.sun.star.sheet.SpreadsheetDocument"        )
#define  DOCUMENTSERVICE_DRAW           _FILTER_CONFIG_FROM_ASCII_("com.sun.star.drawing.DrawingDocument"          )
#define  DOCUMENTSERVICE_IMPRESS        _FILTER_CONFIG_FROM_ASCII_("com.sun.star.presentation.PresentationDocument")
#define  DOCUMENTSERVICE_CHART          _FILTER_CONFIG_FROM_ASCII_("com.sun.star.chart.ChartDocument"              )
#define  DOCUMENTSERVICE_MATH           _FILTER_CONFIG_FROM_ASCII_("com.sun.star.formula.FormulaProperties"        )

/** @short  some uno service names.
 */
#define  SERVICE_CONFIGURATIONPROVIDER      _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationProvider"     )
#define  SERVICE_CONFIGURATIONUPDATEACCESS  _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationUpdateAccess" )
#define  SERVICE_CONFIGURATIONACCESS        _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationAccess"       )
#define  SERVICE_URLTRANSFORMER             _FILTER_CONFIG_FROM_ASCII_("com.sun.star.util.URLTransformer"                     )

/** @short  some configuration pathes.
 */
#define  CFGPACKAGE_TD_TYPES           _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.TypeDetection.Types" )
#define  CFGPACKAGE_TD_FILTERS         _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.TypeDetection.Filter")
#define  CFGPACKAGE_TD_OTHERS          _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.TypeDetection.Misc"  )

/** @short  some default values.
 */
#define  DEFAULT_OFFICELOCALE       _FILTER_CONFIG_FROM_ASCII_("en-US")
#define  DEFAULT_FORMATNAME         _FILTER_CONFIG_FROM_ASCII_("OpenOffice")
#define  DEFAULT_FORMATVERSION      _FILTER_CONFIG_FROM_ASCII_("1.0")

#endif // _FILTER_CONFIG_static constANT_HXX_
<commit_msg>INTEGRATION: CWS loadenv01 (1.2.28); FILE MERGED 2004/03/15 06:04:05 as 1.2.28.1: #i24378# use new MediaDescriptor class and constants<commit_after>/*************************************************************************
 *
 *  $RCSfile: constant.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: svesik $ $Date: 2004-04-21 11:58:54 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License") You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _FILTER_CONFIG_CONSTANT_HXX_
#define _FILTER_CONFIG_CONSTANT_HXX_

#include "macros.hxx"

/*  disable impl_loadOnDemand function of BaseContainer for certain
    functions, where it the feature "impl_loadItemOnDemand() of class FilterCache
    can be used instead of loadAll()!*/
// #define LOAD_IMPLICIT

//_______________________________________________

/** @short  used to identify a some generic item properties against the
            configuration API and can be used at all name containers
            (based on this filtercache) too.
 */
#define  PROPNAME_NAME  _FILTER_CONFIG_FROM_ASCII_("Name")

/** @short  used to identify a type item property against the
            configuration API and can be used at all name containers
            (based on this filtercache) too.
 */
#define  PROPNAME_UINAME            _FILTER_CONFIG_FROM_ASCII_("UIName"          )
#define  PROPNAME_UINAMES           _FILTER_CONFIG_FROM_ASCII_("UINames"         )
#define  PROPNAME_PREFERRED         _FILTER_CONFIG_FROM_ASCII_("Preferred"       )
#define  PROPNAME_PREFERREDFILTER   _FILTER_CONFIG_FROM_ASCII_("PreferredFilter" )
#define  PROPNAME_DETECTSERVICE     _FILTER_CONFIG_FROM_ASCII_("DetectService"   )
#define  PROPNAME_MEDIATYPE         _FILTER_CONFIG_FROM_ASCII_("MediaType"       )
#define  PROPNAME_CLIPBOARDFORMAT   _FILTER_CONFIG_FROM_ASCII_("ClipboardFormat" )
#define  PROPNAME_URLPATTERN        _FILTER_CONFIG_FROM_ASCII_("URLPattern"      )
#define  PROPNAME_EXTENSIONS        _FILTER_CONFIG_FROM_ASCII_("Extensions"      )

/** @short  used to identify a filter item property against the
            configuration API and can be used at all name containers
            (based on this filtercache) too.
 */
#define  PROPNAME_TYPE              _FILTER_CONFIG_FROM_ASCII_("Type"             )
#define  PROPNAME_DOCUMENTSERVICE   _FILTER_CONFIG_FROM_ASCII_("DocumentService"  )
#define  PROPNAME_FILTERSERVICE     _FILTER_CONFIG_FROM_ASCII_("FilterService"    )
#define  PROPNAME_UICOMPONENT       _FILTER_CONFIG_FROM_ASCII_("UIComponent"      )
#define  PROPNAME_FLAGS             _FILTER_CONFIG_FROM_ASCII_("Flags"            )
#define  PROPNAME_USERDATA          _FILTER_CONFIG_FROM_ASCII_("UserData"         )
#define  PROPNAME_TEMPLATENAME      _FILTER_CONFIG_FROM_ASCII_("TemplateName"     )
#define  PROPNAME_FILEFORMATVERSION _FILTER_CONFIG_FROM_ASCII_("FileFormatVersion")

/** @short  used to identify a frame loader or detect service item
            property against the configuration API and can be used
            at all name containers (based on this filtercache) too.
 */
#define  PROPNAME_TYPES     _FILTER_CONFIG_FROM_ASCII_("Types")

/** @short  used to identify a set of items against the configuration API. */
#define  CFGSET_TYPES               _FILTER_CONFIG_FROM_ASCII_("Types"          )
#define  CFGSET_FILTERS             _FILTER_CONFIG_FROM_ASCII_("Filters"        )
#define  CFGSET_FRAMELOADERS        _FILTER_CONFIG_FROM_ASCII_("FrameLoaders"   )
#define  CFGSET_CONTENTHANDLERS     _FILTER_CONFIG_FROM_ASCII_("ContentHandlers")

/** @short  used to adress some configuration keys directly.

    @descr  Such direct keys should be used with function
            FilterCache::impl_getDirectCFGValue() only!

    @TODO   define these direct keys ...
 */
#define  CFGDIRECTKEY_OFFICELOCALE          _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/L10N/ooLocale"                           )
#define  CFGDIRECTKEY_DEFAULTFRAMELOADER    _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.TypeDetection.Misc/Defaults/DefaultFrameLoader")
#define  CFGDIRECTKEY_OFFICELOCALE          _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/L10N/ooLocale"                           )
#define  CFGDIRECTKEY_FORMATNAME            _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/Product/ooXMLFileFormatName"             )
#define  CFGDIRECTKEY_FORMATVERSION         _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/Product/ooXMLFileFormatVersion"          )
#define  CFGDIRECTKEY_PRODUCTNAME           _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.Setup/Product/ooName"                          )

/** @short  names of filter flags. */
#define  FLAGNAME_3RDPARTYFILTER    _FILTER_CONFIG_FROM_ASCII_("3RDPARTYFILTER"   )
#define  FLAGNAME_ALIEN             _FILTER_CONFIG_FROM_ASCII_("ALIEN"            )
#define  FLAGNAME_ASYNCHRON         _FILTER_CONFIG_FROM_ASCII_("ASYNCHRON"        )
#define  FLAGNAME_BROWSERPREFERRED  _FILTER_CONFIG_FROM_ASCII_("BROWSERPREFERRED" )
#define  FLAGNAME_CONSULTSERVICE    _FILTER_CONFIG_FROM_ASCII_("CONSULTSERVICE"   )
#define  FLAGNAME_DEFAULT           _FILTER_CONFIG_FROM_ASCII_("DEFAULT"          )
#define  FLAGNAME_EXPORT            _FILTER_CONFIG_FROM_ASCII_("EXPORT"           )
#define  FLAGNAME_IMPORT            _FILTER_CONFIG_FROM_ASCII_("IMPORT"           )
#define  FLAGNAME_INTERNAL          _FILTER_CONFIG_FROM_ASCII_("INTERNAL"         )
#define  FLAGNAME_NOTINCHOOSER      _FILTER_CONFIG_FROM_ASCII_("NOTINCHOOSER"     )
#define  FLAGNAME_NOTINFILEDIALOG   _FILTER_CONFIG_FROM_ASCII_("NOTINFILEDIALOG"  )
#define  FLAGNAME_NOTINSTALLED      _FILTER_CONFIG_FROM_ASCII_("NOTINSTALLED"     )
#define  FLAGNAME_OWN               _FILTER_CONFIG_FROM_ASCII_("OWN"              )
#define  FLAGNAME_PACKED            _FILTER_CONFIG_FROM_ASCII_("PACKED"           )
#define  FLAGNAME_PREFERRED         _FILTER_CONFIG_FROM_ASCII_("PREFERRED"        )
#define  FLAGNAME_READONLY          _FILTER_CONFIG_FROM_ASCII_("READONLY"         )
#define  FLAGNAME_SILENTEXPORT      _FILTER_CONFIG_FROM_ASCII_("SILENTEXPORT"     )
#define  FLAGNAME_SUPPORTSSELECTION _FILTER_CONFIG_FROM_ASCII_("SUPPORTSSELECTION")
#define  FLAGNAME_TEMPLATE          _FILTER_CONFIG_FROM_ASCII_("TEMPLATE"         )
#define  FLAGNAME_TEMPLATEPATH      _FILTER_CONFIG_FROM_ASCII_("TEMPLATEPATH"     )
#define  FLAGNAME_USESOPTIONS       _FILTER_CONFIG_FROM_ASCII_("USESOPTIONS"      )
#define  FLAGNAME_COMBINED          _FILTER_CONFIG_FROM_ASCII_("COMBINED"         )

/** @short  values of filter flags */
#define  FLAGVAL_3RDPARTYFILTER    0x00080000 // 524288
#define  FLAGVAL_ALIEN             0x00000040 // 64
#define  FLAGVAL_ALL               0xffffffff // 4294967295
#define  FLAGVAL_ASYNCHRON         0x00004000 // 16384
#define  FLAGVAL_BROWSERPREFERRED  0x00400000 // 4194304
#define  FLAGVAL_CONSULTSERVICE    0x00040000 // 262144
#define  FLAGVAL_DEFAULT           0x00000100 // 256
#define  FLAGVAL_EXPORT            0x00000002 // 2
#define  FLAGVAL_IMPORT            0x00000001 // 1
#define  FLAGVAL_INTERNAL          0x00000008 // 8
#define  FLAGVAL_NOTINCHOOSER      0x00002000 // 8192
#define  FLAGVAL_NOTINFILEDIALOG   0x00001000 // 4096
#define  FLAGVAL_NOTINSTALLED      0x00020000 // 131072
#define  FLAGVAL_OWN               0x00000020 // 32
#define  FLAGVAL_PACKED            0x00100000 // 1048576
#define  FLAGVAL_PREFERRED         0x10000000 // 268435456
#define  FLAGVAL_READONLY          0x00010000 // 65536
#define  FLAGVAL_SILENTEXPORT      0x00200000 // 2097152
#define  FLAGVAL_SUPPORTSSELECTION 0x00000400 // 1024
#define  FLAGVAL_TEMPLATE          0x00000004 // 4
#define  FLAGVAL_TEMPLATEPATH      0x00000010 // 16
#define  FLAGVAL_USESOPTIONS       0x00000080 // 128
#define  FLAGVAL_COMBINED          0x00800000 // 8388608

/** @short  uno service names of our document services
            provided by our application modules.
 */
#define  DOCUMENTSERVICE_WRITER         _FILTER_CONFIG_FROM_ASCII_("com.sun.star.text.TextDocument"                )
#define  DOCUMENTSERVICE_WRITER_WEB     _FILTER_CONFIG_FROM_ASCII_("com.sun.star.text.WebDocument"                 )
#define  DOCUMENTSERVICE_WRITER_GLOBAL  _FILTER_CONFIG_FROM_ASCII_("com.sun.star.text.GlobalDocument"              )
#define  DOCUMENTSERVICE_CALC           _FILTER_CONFIG_FROM_ASCII_("com.sun.star.sheet.SpreadsheetDocument"        )
#define  DOCUMENTSERVICE_DRAW           _FILTER_CONFIG_FROM_ASCII_("com.sun.star.drawing.DrawingDocument"          )
#define  DOCUMENTSERVICE_IMPRESS        _FILTER_CONFIG_FROM_ASCII_("com.sun.star.presentation.PresentationDocument")
#define  DOCUMENTSERVICE_CHART          _FILTER_CONFIG_FROM_ASCII_("com.sun.star.chart.ChartDocument"              )
#define  DOCUMENTSERVICE_MATH           _FILTER_CONFIG_FROM_ASCII_("com.sun.star.formula.FormulaProperties"        )

/** @short  some uno service names.
 */
#define  SERVICE_CONFIGURATIONPROVIDER      _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationProvider"     )
#define  SERVICE_CONFIGURATIONUPDATEACCESS  _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationUpdateAccess" )
#define  SERVICE_CONFIGURATIONACCESS        _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationAccess"       )
#define  SERVICE_URLTRANSFORMER             _FILTER_CONFIG_FROM_ASCII_("com.sun.star.util.URLTransformer"                     )

/** @short  some configuration pathes.
 */
#define  CFGPACKAGE_TD_TYPES           _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.TypeDetection.Types" )
#define  CFGPACKAGE_TD_FILTERS         _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.TypeDetection.Filter")
#define  CFGPACKAGE_TD_OTHERS          _FILTER_CONFIG_FROM_ASCII_("/org.openoffice.TypeDetection.Misc"  )

/** @short  some default values.
 */
#define  DEFAULT_OFFICELOCALE       _FILTER_CONFIG_FROM_ASCII_("en-US")
#define  DEFAULT_FORMATNAME         _FILTER_CONFIG_FROM_ASCII_("OpenOffice")
#define  DEFAULT_FORMATVERSION      _FILTER_CONFIG_FROM_ASCII_("1.0")

#endif // _FILTER_CONFIG_static constANT_HXX_
<|endoftext|>


<commit_before>/**
 * Copyright 2014 Open Connectome Project (http://openconnecto.me)
 * Written by Disa Mhembere (disa)
 *
 * This file is part of FlashGraph.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdlib.h>
#include "matrix/kmeans_thread.h"
#include "matrix/kmeans_thread.cpp"
#include "libgraph-algs/sem_kmeans_util.h"

void test_thread_creation(const unsigned NTHREADS, const unsigned nnodes) {
    std::vector<kmeans_thread::ptr> thds;

    // Always: Build state alone
    for (unsigned i = 0; i < NTHREADS; i++) {
        clusters::ptr cl = clusters::create(2,2);
        thds.push_back(kmeans_thread::create
                (i%nnodes, i, 69, 200, 1, 2, cl, NULL, "/dev/null"));
    }

    // Always: Start threads alone
    for (unsigned i = 0; i < NTHREADS; i++)
        thds[i]->start(TEST);

    // Always: join threads alone
    unsigned sum = 0;
    unsigned verification = 0;
    for (unsigned i = 0; i < thds.size(); i++) {
        thds[i]->join();
        sum += thds[i]->get_val(); // OK to do together
        verification += i;
    }
    BOOST_VERIFY(sum == verification);
    std::cout << "SUCCESS: The sum is: " << sum << "\n";
}

void test_numa_populate_data() {
    constexpr unsigned NTHREADS = 10;
    constexpr unsigned nnodes = 4;
    constexpr unsigned nrow = 50;
    const unsigned nprocrows = nrow/NTHREADS;
    constexpr unsigned ncol = 5;
    const std::string fn = "/mnt/nfs/disa/data/tiny/matrix_r50_c5_rrw.bin";

    std::vector<kmeans_thread::ptr> thds;

    // Always: Build state alone
    for (unsigned i = 0; i < NTHREADS; i++) {
        clusters::ptr cl = clusters::create(2,2);
        thds.push_back(kmeans_thread::create
                (i%nnodes, i, i*nprocrows*ncol, nprocrows, nprocrows, ncol,
                 cl, NULL, fn));
    }

    bin_reader<double> br(fn, nrow, ncol);
    double* data = new double [nrow*ncol];
    printf("Bin read data\n");
    br.read(data);

    // Allocate & move
    std::vector<kmeans_thread::ptr>::iterator it = thds.begin();
    for (; it != thds.end(); ++it)
        (*it)->start(ALLOC_DATA);

    for (it = thds.begin(); it != thds.end(); ++it)
        (*it)->join();

    // Print it back
    for (it = thds.begin(); it != thds.end(); ++it) {
        double *dp = &data[(*it)->get_thd_id()*ncol*nprocrows];
        BOOST_VERIFY(eq_all(dp, (*it)->get_local_data(), nprocrows*ncol));
        printf("Thread %u PASSED numa_mem_alloc()\n", (*it)->get_thd_id());
    }
    delete [] data;
}

int main(int argc, char* argv[]) {

    if (argc < 2) {
        fprintf(stderr, "usage: ./test_kmeans_thread nthreads nnodes\n");
        exit(EXIT_FAILURE);
    }

#if KM_TEST
    test_thread_creation(atoi(argv[1]), atoi(argv[2]));
#else
    printf("[FATAL]: Set KM_TEST 1 in kmeans.h\n");
    exit(EXIT_FAILURE);
#endif
    test_numa_populate_data();

    return (EXIT_SUCCESS);
}
<commit_msg>[Test]: getting rid of testing variable from thread<commit_after>/**
 * Copyright 2014 Open Connectome Project (http://openconnecto.me)
 * Written by Disa Mhembere (disa)
 *
 * This file is part of FlashGraph.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdlib.h>
#include "matrix/kmeans_thread.h"
#include "matrix/kmeans_thread.cpp"
#include "libgraph-algs/sem_kmeans_util.h"

void test_thread_creation(const unsigned NTHREADS, const unsigned nnodes) {
    std::vector<kmeans_thread::ptr> thds;

    // Always: Build state alone
    for (unsigned i = 0; i < NTHREADS; i++) {
        clusters::ptr cl = clusters::create(2,2);
        thds.push_back(kmeans_thread::create
                (i%nnodes, i, 69, 200, 1, 2, cl, NULL, "/dev/null"));
    }

    // Always: Start threads alone
    for (unsigned i = 0; i < NTHREADS; i++)
        thds[i]->start(TEST);

    // Always: join threads alone
    for (unsigned i = 0; i < thds.size(); i++) {
        thds[i]->join();
    }
    std::cout << "SUCCESS: for creation & join\n";
}

void test_numa_populate_data() {
    constexpr unsigned NTHREADS = 10;
    constexpr unsigned nnodes = 4;
    constexpr unsigned nrow = 50;
    const unsigned nprocrows = nrow/NTHREADS;
    constexpr unsigned ncol = 5;
    const std::string fn = "/mnt/nfs/disa/data/tiny/matrix_r50_c5_rrw.bin";

    std::vector<kmeans_thread::ptr> thds;

    // Always: Build state alone
    for (unsigned i = 0; i < NTHREADS; i++) {
        clusters::ptr cl = clusters::create(2,2);
        thds.push_back(kmeans_thread::create
                (i%nnodes, i, i*nprocrows*ncol, nprocrows, nprocrows, ncol,
                 cl, NULL, fn));
    }

    bin_reader<double> br(fn, nrow, ncol);
    double* data = new double [nrow*ncol];
    printf("Bin read data\n");
    br.read(data);

    // Allocate & move
    std::vector<kmeans_thread::ptr>::iterator it = thds.begin();
    for (; it != thds.end(); ++it)
        (*it)->start(ALLOC_DATA);

    for (it = thds.begin(); it != thds.end(); ++it)
        (*it)->join();

    // Print it back
    for (it = thds.begin(); it != thds.end(); ++it) {
        double *dp = &data[(*it)->get_thd_id()*ncol*nprocrows];
        BOOST_VERIFY(eq_all(dp, (*it)->get_local_data(), nprocrows*ncol));
        printf("Thread %u PASSED numa_mem_alloc()\n", (*it)->get_thd_id());
    }
    delete [] data;
}

int main(int argc, char* argv[]) {

    if (argc < 2) {
        fprintf(stderr, "usage: ./test_kmeans_thread nthreads nnodes\n");
        exit(EXIT_FAILURE);
    }

#if KM_TEST
    test_thread_creation(atoi(argv[1]), atoi(argv[2]));
#else
    printf("[FATAL]: Set KM_TEST 1 in kmeans.h\n");
    exit(EXIT_FAILURE);
#endif
    test_numa_populate_data();

    return (EXIT_SUCCESS);
}
<|endoftext|>


<commit_before>#ifndef READ_MDATA_11
#define READ_MDATA_11
#include "mordorBinaryReader.hpp"

const int MAX_LAIRS_PER_LEVEL = 200;
const int MAX_WIDTH = 30;
const int MAX_HEIGHT = 30;

struct levelHeader {
  WORD width;
  WORD height;
  WORD levelNumber;
  WORD numLairs;
  WORD numChutes;
  WORD numTeleports;
};

struct fieldRecord {
  WORD spawnAreaID;
  BYTE fieldMask[8];    // 8 bytes
};

struct areaRecord {
  DWORD spawnTypeMask; // 4 bytes
  WORD lairID;
};

struct teleporterRecord{
  WORD srcX;
  WORD srcY;
  WORD destX;
  WORD destY;
  WORD destZ;
};

struct chuteRecord {
  WORD x;
  WORD y;
  WORD dropDepth;
};

struct monsterLair{
  DWORD monsterType;
  WORD monsterID;
};

#endif
<commit_msg>added field, spawn masks to struct sets<commit_after>#ifndef READ_MDATA_11
#define READ_MDATA_11
#include "mordorBinaryReader.hpp"

const int MAX_LAIRS_PER_LEVEL = 200;
const int MAX_WIDTH = 30;
const int MAX_HEIGHT = 30;

struct levelHeader {
  WORD width;
  WORD height;
  WORD levelNumber;
  WORD numLairs;
  WORD numChutes;
  WORD numTeleports;
};

struct fieldRecord {
  WORD spawnAreaID;
  BYTE fieldMask[8];    // 8 bytes
};

struct fieldMask{
  bool eastWall;
  bool northWoll;
  bool eastDoor;
  bool northDoor;
  bool eastSecretDoor;
  bool northSecterDoor;
  bool faceNorth;
  bool faceEast;
  bool faceSouth;
  bool faceWest;
  bool extingusher;
  bool pit;
  bool stairsUp;
  bool stairsDown;
  bool teleporter;
  bool water;
  bool quicksand;
  bool rotator;
  bool antimagic;
  bool rock;
  bool fog;
  bool chute;
  bool stud;
};

struct areaRecord {
  DWORD spawnTypeMask; // 4 bytes
  WORD lairID;
};

struct spawnMask{
  bool humanoid;
  bool cleanup;
  bool demon;
  bool devil;
  bool elemental;
  bool reptile;
  bool dragon;
  bool animal;
  bool insect;
  bool undead;
  bool water;
  bool giant;
  bool mythical;
  bool lycanthrope;
  bool thief;
  bool mage;
  bool warrior;
  bool indigini;
};

struct teleporterRecord{
  WORD srcX;
  WORD srcY;
  WORD destX;
  WORD destY;
  WORD destZ;
};

struct chuteRecord {
  WORD x;
  WORD y;
  WORD dropDepth;
};

struct monsterLair{
  DWORD monsterType;
  WORD monsterID;
};

#endif
<|endoftext|>


<commit_before>//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.

#include <cassert>
#include <vector>
#include <set>

#include "llvm/IR/DataLayout.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/IR/Type.h"
#if LLVM_VERSION_MAJOR >= 4 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
  #include "llvm/IR/InstIterator.h"
#else
  #include "llvm/Support/InstIterator.h"
#endif
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include <llvm/IR/DebugInfoMetadata.h>

using namespace llvm;

bool CloneMetadata(const llvm::Instruction *i1, llvm::Instruction *i2);

namespace {

class FindExits : public FunctionPass {
  public:
    static char ID;

    FindExits() : FunctionPass(ID) {}

    bool runOnFunction(Function &F) override;
    bool processBlock(BasicBlock& B);
};

bool FindExits::runOnFunction(Function &F)
{
  bool modified = false;

  for (auto& B : F) {
      modified |= processBlock(B);
  }

  return modified;
}

bool FindExits::processBlock(BasicBlock& B) {
  bool modified = false;
  Module *M = B.getParent()->getParent();
  LLVMContext& Ctx = M->getContext();

  Type *argTy = Type::getInt32Ty(Ctx);
  auto exitC = M->getOrInsertFunction("__VERIFIER_silent_exit",
                                       Type::getVoidTy(Ctx), argTy
#if LLVM_VERSION_MAJOR < 5
                                       , nullptr
#endif
                                       );
#if LLVM_VERSION_MAJOR >= 9
        auto exitF = cast<Function>(exitC.getCallee());
#else
        auto exitF = cast<Function>(exitC);
#endif
  exitF->addFnAttr(Attribute::NoReturn);

  if (succ_begin(&B) == succ_end(&B)) {
    auto& BI = B.back();
    if (!isa<ReturnInst>(&BI)) { // return inst does not abort the program,
                                 // just returns to the caller
        auto new_CI = CallInst::Create(exitF, {ConstantInt::get(argTy, 0)});
        CloneMetadata(&BI, new_CI);
        new_CI->insertBefore(&BI);
    }
  }

  /*
  for (auto I = B.begin(), E = B.end(); I != E;) {
    Instruction *ins = &*I;
    ++I;
    if (auto CI = dyn_cast<CallInst>(ins)) {
      auto calledFun = dyn_cast<Function>(CI->getCalledValue()->stripPointerCasts());
      if (!calledFun)
          continue;

      if (calledFun->hasFnAttribute(Attribute::NoReturn))
          ...

      auto new_CI = CallInst::Create(exitF);
      CloneMetadata(CI, new_CI);
      new_CI->insertAfter(CI);

      modified = true;
    }
  }
  */

  return modified;
}

} // namespace

static RegisterPass<FindExits> DM("find-exits",
                                  "Put calls to __VERIFIER_silent_exit into bitcode "
                                  "before any exit from the program.");
char FindExits::ID;
<commit_msg>Fix -find-exits<commit_after>//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.

#include <cassert>
#include <vector>
#include <set>

#include "llvm/IR/DataLayout.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/IR/Type.h"
#if LLVM_VERSION_MAJOR >= 4 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
  #include "llvm/IR/InstIterator.h"
#else
  #include "llvm/Support/InstIterator.h"
#endif
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include <llvm/IR/DebugInfoMetadata.h>

using namespace llvm;

bool CloneMetadata(const llvm::Instruction *i1, llvm::Instruction *i2);

namespace {

class FindExits : public FunctionPass {
  public:
    static char ID;

    FindExits() : FunctionPass(ID) {}

    bool runOnFunction(Function &F) override;
    bool processBlock(BasicBlock& B);
};

bool FindExits::runOnFunction(Function &F)
{
  bool modified = false;

  for (auto& B : F) {
      modified |= processBlock(B);
  }

  return modified;
}

bool FindExits::processBlock(BasicBlock& B) {
  bool modified = false;
  Module *M = B.getParent()->getParent();
  LLVMContext& Ctx = M->getContext();
  bool isMain = B.getParent()->getName().equals("main");

  Type *argTy = Type::getInt32Ty(Ctx);
  auto exitC = M->getOrInsertFunction("__VERIFIER_silent_exit",
                                       Type::getVoidTy(Ctx), argTy
#if LLVM_VERSION_MAJOR < 5
                                       , nullptr
#endif
                                       );
#if LLVM_VERSION_MAJOR >= 9
        auto exitF = cast<Function>(exitC.getCallee());
#else
        auto exitF = cast<Function>(exitC);
#endif
  exitF->addFnAttr(Attribute::NoReturn);

  if (succ_begin(&B) == succ_end(&B)) {
    auto& BI = B.back();
    if (isMain || !isa<ReturnInst>(&BI)) { // return inst does not abort the program
                                           // (unless in main) just returns to the caller
        auto new_CI = CallInst::Create(exitF, {ConstantInt::get(argTy, 0)});
        CloneMetadata(&BI, new_CI);
        new_CI->insertBefore(&BI);
    }
  }

  /*
  for (auto I = B.begin(), E = B.end(); I != E;) {
    Instruction *ins = &*I;
    ++I;
    if (auto CI = dyn_cast<CallInst>(ins)) {
      auto calledFun = dyn_cast<Function>(CI->getCalledValue()->stripPointerCasts());
      if (!calledFun)
          continue;

      if (calledFun->hasFnAttribute(Attribute::NoReturn))
          ...

      auto new_CI = CallInst::Create(exitF);
      CloneMetadata(CI, new_CI);
      new_CI->insertAfter(CI);

      modified = true;
    }
  }
  */

  return modified;
}

} // namespace

static RegisterPass<FindExits> DM("find-exits",
                                  "Put calls to __VERIFIER_silent_exit into bitcode "
                                  "before any exit from the program.");
char FindExits::ID;
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: MQuery.hxx,v $
 *
 *  $Revision: 1.14 $
 *
 *  last change: $Author: obo $ $Date: 2006-03-29 12:19:19 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _CONNECTIVITY_MAB_QUERY_HXX_
#define _CONNECTIVITY_MAB_QUERY_HXX_

#ifndef _CONNECTIVITY_MAB_COLUMNALIAS_HXX_
#include "MColumnAlias.hxx"
#endif
#ifndef CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX
#include "MErrorResource.hxx"
#endif
#include <connectivity/FValue.hxx>
#ifndef _CONNECTIVITY_MAB_NS_DECLARES_HXX_
#include "MNSDeclares.hxx"
#endif
#ifndef _THREAD_HXX_
#include <osl/thread.hxx>
#endif
#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
#include <com/sun/star/mozilla/MozillaProductType.hpp>
#endif

namespace connectivity
{
    namespace mozab
    {

        class  MQueryHelper;
        struct MQueryDirectory;

        namespace MQueryOp {
             typedef enum {
                 Exists         = 0,
                 DoesNotExist   = 1,
                 Contains       = 2,
                 DoesNotContain = 3,
                 Is             = 4,
                 IsNot          = 5,
                 BeginsWith     = 6,
                 EndsWith       = 7,
                 SoundsLike     = 8,
                 RegExp         = 9
            } cond_type;
        }

        class MQueryExpressionBase {
        public:
            typedef enum {
                Unknown,
                StringExpr,
                Expr
            } node_type;

        protected:
            node_type   m_eNodeType;

            MQueryExpressionBase() : m_eNodeType( Unknown ) {}
            MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}

        public:
            sal_Bool   isUnknown( ) { return m_eNodeType == Unknown; }
            sal_Bool   isStringExpr( ) { return m_eNodeType == StringExpr; }
            sal_Bool   isExpr( ) { return m_eNodeType == Expr; }
        };

        class MQueryExpressionString : public MQueryExpressionBase {
        protected:
            ::rtl::OUString     m_aName;         // LHS
            MQueryOp::cond_type m_aBooleanCondition;
            ::rtl::OUString     m_aValue;        // RHS

        public:

            MQueryExpressionString( ::rtl::OUString&    lhs,
                                    MQueryOp::cond_type cond,
                                    ::rtl::OUString     rhs )
                : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
                , m_aName( lhs )
                , m_aBooleanCondition( cond )
                , m_aValue( rhs )
            {
            }

            MQueryExpressionString( ::rtl::OUString&    lhs,
                                    MQueryOp::cond_type cond )
                : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
                , m_aName( lhs )
                , m_aBooleanCondition( cond )
                , m_aValue( ::rtl::OUString() )
            {
            }

            const ::rtl::OUString&    getName()  { return m_aName; }
            const MQueryOp::cond_type getCond()  { return m_aBooleanCondition; }
            const ::rtl::OUString&    getValue() { return m_aValue; }
        };

        class MQuery;

        class MQueryExpression : public MQueryExpressionBase
        {
            friend class MQuery;

        public:
            typedef ::std::vector< MQueryExpressionBase* > ExprVector;

            typedef enum {
                AND,
                OR
            } bool_cond;

            void setExpressions( ExprVector& _exprVector )
                            { m_aExprVector = _exprVector; }

            // All expressions on a peer level use same condition operator
            void setExpressionCondition( bool_cond _cond )
                            { m_aExprCondType = _cond; }

            ExprVector& getExpressions( )
                            { return m_aExprVector; }

            // All expressions on a peer level use same condition operator
            bool_cond getExpressionCondition( )
                            { return m_aExprCondType; }

            MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
                                 m_aExprCondType( OR )
                            { m_aExprVector.clear(); }

        protected:
            ExprVector          m_aExprVector;
            bool_cond           m_aExprCondType;

        };

        //
        class MQuery : public ErrorResourceAccess
        {
            /*
             * A query resultset with a maximum limit of
             * m_nMaxNrOfReturns return items, is created from
             * the following SQL statement:
             *
             * -------------------------------------------------
             * SELECT m_aAttributes FROM m_aAddressbook
             * WHERE  m_aMatchItems SQL_OPR m_aMatchValue
             * -------------------------------------------------
             *
             * We are\are not, depending on boolean m_bQuerySubDirs,
             * interested in querying the sub-directories of the
             * addressbook directory, if any.
             *
             * SQL_OPR:
             * m_aSqlOppr contains the SQL operations for every
             * attribute in m_aAttributes.
             * This member must be initialised together with
             * m_aAttributes.
             *
             * The SQL operations defined for 'SQL_OPR' are:
             * matchExists         = 0,
             * matchDoesNotExist   = 1,
             * matchContains       = 2,
             * matchDoesNotContain = 3,
             * matchIs             = 4,
             * matchIsNot          = 5,
             * matchBeginsWith     = 6,
             * matchEndsWith       = 7,
             * matchSoundsLike     = 8,
             * matchRegExp         = 9.
             * There must be mapping to one of these values.
             *
             * The following members MUST be initialised before
             * a query is executed:
             * m_Attributes, m_aMapAttrOppr, m_aAddressbook,
             * m_aMatchItems and m_aMatchValue.
             *
             * m_bQuerySubDirs and m_nMaxNrReturns are set to a
             * default value in the constructor which can be
             * overridden. If (element of) m_aSqlOppr is not set,
             * the default SQL operation is 'matchIs'.
             *
             */
        private:
            MQueryDirectory                *m_aQueryDirectory;
            MQueryHelper                   *m_aQueryHelper;
            ::std::vector< ::rtl::OUString> m_aAttributes;
            ::rtl::OUString                 m_aAddressbook;
            sal_Int32                       m_nMaxNrOfReturns;
            sal_Bool                        m_bQuerySubDirs;
            MQueryExpression                m_aExpr;
            ::std::map< ::rtl::OUString,
                        ::rtl::OUString>    m_aColumnAliasMap;
            mutable sal_Bool                m_aErrorOccurred;
            ::com::sun::star::mozilla::MozillaProductType m_Product;
            ::rtl::OUString                               m_Profile;
            void construct();
        protected:
            ::osl::Mutex                    m_aMutex;
#if OSL_DEBUG_LEVEL > 0
            oslThreadIdentifier m_oThreadID;
#endif

        public:
            /*
             * - Contains accessors to the members of this class.
             * - executeQuery() initiates a non-blocking query.
             */
            sal_Int32                       executeQuery(OConnection* _pCon);    //
            sal_Int32                       executeQueryProxied(OConnection* _pCon); //Used only by MNSMozabProxy

            sal_Int32                       createNewCard(); //return Row count number
            sal_Int32                       deleteRow(const sal_Int32 rowIndex); //
            sal_Int32                       commitRow(const sal_Int32 rowIndex); //
            sal_Bool                        resyncRow(sal_Int32 nDBRow);         //

            sal_Bool                        isWritable(OConnection* _pCon);                      //

            sal_uInt32                      InsertLoginInfo(OConnection* _pCon); //

            void                            setAttributes( ::std::vector< ::rtl::OUString>&);           //
            const                           ::std::vector< ::rtl::OUString> &getAttributes(void) const; //

            void                            setAddressbook( ::rtl::OUString&);  //
            ::rtl::OUString                 getAddressbook(void) const;         //

            const ::std::map< ::rtl::OUString,::rtl::OUString>&
                                            getColumnAliasMap() const { return m_aColumnAliasMap; }

            void                            setExpression( MQueryExpression &_expr );

            void                            setMaxNrOfReturns( const sal_Int32); //
            sal_Int32                       getMaxNrOfReturns(void) const;       //

            void                            setQuerySubDirs( sal_Bool&);         //
            sal_Bool                        getQuerySubDirs(void) const;         //

            sal_Int32                       getRowCount( void );                 //
            sal_uInt32                      getRealRowCount( void );             //
            sal_Bool                        queryComplete( void );               //
            sal_Bool                        waitForQueryComplete( void );        //
            sal_Bool                        checkRowAvailable( sal_Int32 nDBRow );//
            sal_Bool                        getRowValue( connectivity::ORowSetValue& rValue,
                                                         sal_Int32 nDBRow,
                                                         const rtl::OUString& aDBColumnName,
                                                         sal_Int32 nType ) const;//
            sal_Bool                        setRowValue( connectivity::ORowSetValue& rValue,
                                                         sal_Int32 nDBRow,
                                                         const rtl::OUString& aDBColumnName,
                                                         sal_Int32 nType ) const;//
            sal_Int32                       getRowStates(sal_Int32 nDBRow);      //
            sal_Bool                        setRowStates(sal_Int32 nDBRow,sal_Int32 aState); //

            sal_Bool                        errorOccurred() const   //
                                            { return m_aErrorOccurred; };

        public:
            MQuery();                                                       //
            MQuery(const ::std::map< ::rtl::OUString, ::rtl::OUString> &);  //
            virtual ~MQuery();                                              //
            static MNameMapper* CreateNameMapper(); //
            static void FreeNameMapper( MNameMapper* _ptr ); //
        };
    }
}

#endif // _CONNECTIVITY_MAB_QUERY_HXX_

<commit_msg>INTEGRATION: CWS dba205b (1.14.78); FILE MERGED 2006/08/09 19:52:38 fs 1.14.78.1: refactored the OColumnAlias class, in preparation of fixing #b6248060#<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: MQuery.hxx,v $
 *
 *  $Revision: 1.15 $
 *
 *  last change: $Author: ihi $ $Date: 2006-10-18 13:11:02 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _CONNECTIVITY_MAB_QUERY_HXX_
#define _CONNECTIVITY_MAB_QUERY_HXX_

#ifndef _CONNECTIVITY_MAB_COLUMNALIAS_HXX_
#include "MColumnAlias.hxx"
#endif
#ifndef CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX
#include "MErrorResource.hxx"
#endif
#include <connectivity/FValue.hxx>
#ifndef _CONNECTIVITY_MAB_NS_DECLARES_HXX_
#include "MNSDeclares.hxx"
#endif
#ifndef _THREAD_HXX_
#include <osl/thread.hxx>
#endif
#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
#include <com/sun/star/mozilla/MozillaProductType.hpp>
#endif

namespace connectivity
{
    namespace mozab
    {

        class  MQueryHelper;
        struct MQueryDirectory;

        namespace MQueryOp {
             typedef enum {
                 Exists         = 0,
                 DoesNotExist   = 1,
                 Contains       = 2,
                 DoesNotContain = 3,
                 Is             = 4,
                 IsNot          = 5,
                 BeginsWith     = 6,
                 EndsWith       = 7,
                 SoundsLike     = 8,
                 RegExp         = 9
            } cond_type;
        }

        class MQueryExpressionBase {
        public:
            typedef enum {
                Unknown,
                StringExpr,
                Expr
            } node_type;

        protected:
            node_type   m_eNodeType;

            MQueryExpressionBase() : m_eNodeType( Unknown ) {}
            MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}

        public:
            sal_Bool   isUnknown( ) { return m_eNodeType == Unknown; }
            sal_Bool   isStringExpr( ) { return m_eNodeType == StringExpr; }
            sal_Bool   isExpr( ) { return m_eNodeType == Expr; }
        };

        class MQueryExpressionString : public MQueryExpressionBase {
        protected:
            ::rtl::OUString     m_aName;         // LHS
            MQueryOp::cond_type m_aBooleanCondition;
            ::rtl::OUString     m_aValue;        // RHS

        public:

            MQueryExpressionString( ::rtl::OUString&    lhs,
                                    MQueryOp::cond_type cond,
                                    ::rtl::OUString     rhs )
                : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
                , m_aName( lhs )
                , m_aBooleanCondition( cond )
                , m_aValue( rhs )
            {
            }

            MQueryExpressionString( ::rtl::OUString&    lhs,
                                    MQueryOp::cond_type cond )
                : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
                , m_aName( lhs )
                , m_aBooleanCondition( cond )
                , m_aValue( ::rtl::OUString() )
            {
            }

            const ::rtl::OUString&    getName()  { return m_aName; }
            const MQueryOp::cond_type getCond()  { return m_aBooleanCondition; }
            const ::rtl::OUString&    getValue() { return m_aValue; }
        };

        class MQuery;

        class MQueryExpression : public MQueryExpressionBase
        {
            friend class MQuery;

        public:
            typedef ::std::vector< MQueryExpressionBase* > ExprVector;

            typedef enum {
                AND,
                OR
            } bool_cond;

            void setExpressions( ExprVector& _exprVector )
                            { m_aExprVector = _exprVector; }

            // All expressions on a peer level use same condition operator
            void setExpressionCondition( bool_cond _cond )
                            { m_aExprCondType = _cond; }

            ExprVector& getExpressions( )
                            { return m_aExprVector; }

            // All expressions on a peer level use same condition operator
            bool_cond getExpressionCondition( )
                            { return m_aExprCondType; }

            MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
                                 m_aExprCondType( OR )
                            { m_aExprVector.clear(); }

        protected:
            ExprVector          m_aExprVector;
            bool_cond           m_aExprCondType;

        };

        class MQuery : public ErrorResourceAccess
        {
            /*
             * A query resultset with a maximum limit of
             * m_nMaxNrOfReturns return items, is created from
             * the following SQL statement:
             *
             * -------------------------------------------------
             * SELECT m_aAttributes FROM m_aAddressbook
             * WHERE  m_aMatchItems SQL_OPR m_aMatchValue
             * -------------------------------------------------
             *
             * We are\are not, depending on boolean m_bQuerySubDirs,
             * interested in querying the sub-directories of the
             * addressbook directory, if any.
             *
             * SQL_OPR:
             * m_aSqlOppr contains the SQL operations for every
             * attribute in m_aAttributes.
             * This member must be initialised together with
             * m_aAttributes.
             *
             * The SQL operations defined for 'SQL_OPR' are:
             * matchExists         = 0,
             * matchDoesNotExist   = 1,
             * matchContains       = 2,
             * matchDoesNotContain = 3,
             * matchIs             = 4,
             * matchIsNot          = 5,
             * matchBeginsWith     = 6,
             * matchEndsWith       = 7,
             * matchSoundsLike     = 8,
             * matchRegExp         = 9.
             * There must be mapping to one of these values.
             *
             * The following members MUST be initialised before
             * a query is executed:
             * m_Attributes, m_aMapAttrOppr, m_aAddressbook,
             * m_aMatchItems and m_aMatchValue.
             *
             * m_bQuerySubDirs and m_nMaxNrReturns are set to a
             * default value in the constructor which can be
             * overridden. If (element of) m_aSqlOppr is not set,
             * the default SQL operation is 'matchIs'.
             *
             */
        private:
            MQueryDirectory                *m_aQueryDirectory;
            MQueryHelper                   *m_aQueryHelper;
            ::std::vector< ::rtl::OUString> m_aAttributes;
            ::rtl::OUString                 m_aAddressbook;
            sal_Int32                       m_nMaxNrOfReturns;
            sal_Bool                        m_bQuerySubDirs;
            MQueryExpression                m_aExpr;
            const OColumnAlias&             m_rColumnAlias;
            mutable sal_Bool                m_aErrorOccurred;
            ::com::sun::star::mozilla::MozillaProductType m_Product;
            ::rtl::OUString                               m_Profile;
            void construct();
        protected:
            ::osl::Mutex                    m_aMutex;
#if OSL_DEBUG_LEVEL > 0
            oslThreadIdentifier m_oThreadID;
#endif

        public:
            /*
             * - Contains accessors to the members of this class.
             * - executeQuery() initiates a non-blocking query.
             */
            sal_Int32                       executeQuery(OConnection* _pCon);
            sal_Int32                       executeQueryProxied(OConnection* _pCon); //Used only by MNSMozabProxy

            sal_Int32                       createNewCard(); //return Row count number
            sal_Int32                       deleteRow(const sal_Int32 rowIndex);
            sal_Int32                       commitRow(const sal_Int32 rowIndex);
            sal_Bool                        resyncRow(sal_Int32 nDBRow);

            sal_Bool                        isWritable(OConnection* _pCon);

            sal_uInt32                      InsertLoginInfo(OConnection* _pCon);

            void                            setAttributes( ::std::vector< ::rtl::OUString>&);
            const                           ::std::vector< ::rtl::OUString> &getAttributes(void) const;

            void                            setAddressbook( ::rtl::OUString&);
            ::rtl::OUString                 getAddressbook(void) const;

            const OColumnAlias&             getColumnAlias() const { return m_rColumnAlias; }

            void                            setExpression( MQueryExpression &_expr );

            void                            setMaxNrOfReturns( const sal_Int32);
            sal_Int32                       getMaxNrOfReturns(void) const;

            void                            setQuerySubDirs( sal_Bool&);
            sal_Bool                        getQuerySubDirs(void) const;

            sal_Int32                       getRowCount( void );
            sal_uInt32                      getRealRowCount( void );
            sal_Bool                        queryComplete( void );
            sal_Bool                        waitForQueryComplete( void );
            sal_Bool                        checkRowAvailable( sal_Int32 nDBRow );
            sal_Bool                        getRowValue( connectivity::ORowSetValue& rValue,
                                                         sal_Int32 nDBRow,
                                                         const rtl::OUString& aDBColumnName,
                                                         sal_Int32 nType ) const;
            sal_Bool                        setRowValue( connectivity::ORowSetValue& rValue,
                                                         sal_Int32 nDBRow,
                                                         const rtl::OUString& aDBColumnName,
                                                         sal_Int32 nType ) const;
            sal_Int32                       getRowStates(sal_Int32 nDBRow);
            sal_Bool                        setRowStates(sal_Int32 nDBRow,sal_Int32 aState);

            sal_Bool                        errorOccurred() const
                                            { return m_aErrorOccurred; };

        public:
//          MQuery();
            MQuery( const OColumnAlias& _ca );
            virtual ~MQuery();
            static MNameMapper* CreateNameMapper();
            static void FreeNameMapper( MNameMapper* _ptr );
        };
    }
}

#endif // _CONNECTIVITY_MAB_QUERY_HXX_

<|endoftext|>


<commit_before>// Ouzel by Elviss Strazdins

#ifndef OUZEL_THREAD_CHANNEL_HPP
#define OUZEL_THREAD_CHANNEL_HPP

#include <condition_variable>
#include <memory>
#include <mutex>
#include <vector>
#include "Semaphore.hpp"

namespace ouzel::thread
{
    template <class Type>
    class ChannelContainer final
    {
    public:
        ChannelContainer(std::ptrdiff_t c):
            capacity{c},
            semaphore{c}
        {}

        ~ChannelContainer()
        {
            std::unique_lock lock(queueMutex);
            closed = true;
            lock.unlock();
            if (capacity > 0) semaphore.acquire();
            queueCondition.notify_all();
        }

        ChannelContainer(const ChannelContainer&) = delete;
        ChannelContainer& operator=(const ChannelContainer&) = delete;
        ChannelContainer(ChannelContainer&&) = delete;
        ChannelContainer& operator=(ChannelContainer&&) = delete;

        template <class T>
        void send(T&& entry)
        {
            std::unique_lock lock(queueMutex);
            if (!closed) queue.push(std::forward<T>(entry));
            lock.unlock();
            if (capacity > 0) semaphore.acquire();
            queueCondition.notify_all();
        }

        void close()
        {
            std::unique_lock lock(queueMutex);
            closed = true;
            lock.unlock();
            if (capacity > 0) semaphore.acquire();
            queueCondition.notify_all();
        }

        std::unique_ptr<Type> next() const
        {
            std::unique_lock lock(queueMutex);
            while (!closed && queue.empty()) queueCondition.wait(lock);

            if (!queue.empty())
            {
                auto result = std::make_unique<Type>(std::move(queue.front()));
                queue.pop();
                lock.unlock();
                if (capacity > 0) semaphore.release();
                return result;
            }
            else
                return std::unique_ptr<Type>{};
        }

    private:
        bool closed = false;
        mutable std::queue<Type> queue;
        mutable std::mutex queueMutex;
        mutable std::condition_variable queueCondition;
        std::ptrdiff_t capacity = 0;
        mutable Semaphore semaphore;
    };

    template <class Type>
    class ChannelIterator final
    {
    public:
        explicit ChannelIterator(const ChannelContainer<Type>& c) noexcept:
            container{c} {}
        ChannelIterator(const ChannelContainer<Type>& c, std::unique_ptr<Type> p) noexcept:
            container{c}, ptr{std::move(p)} {}

        operator bool() const noexcept { return ptr != nullptr; }

        bool operator==(const ChannelIterator& i) const noexcept { return ptr == i.ptr; }
        bool operator!=(const ChannelIterator& i) const noexcept { return ptr != i.ptr; }

        Type& operator*() noexcept { return *ptr; }
        const Type& operator*() const noexcept { return *ptr; }
        Type* operator->() noexcept { return ptr.get(); }
        const Type* operator->() const noexcept { return ptr.get(); }

        ChannelIterator& operator++() noexcept
        {
            ptr = container.next();
            return *this;
        }

        ChannelIterator operator++(int) noexcept
        {
            auto p = std::move(ptr);
            ptr = container.next();
            return ChannelIterator{container, std::move(p)};
        }

    private:
        const ChannelContainer<Type>& container;
        std::unique_ptr<Type> ptr;
    };

    template <class Type>
    class Channel final
    {
    public:
        using Iterator = ChannelIterator<Type>;
        using ConstIterator = ChannelIterator<const Type>;

        Channel(std::ptrdiff_t capacity = 0): container{capacity} {}

        Iterator begin() noexcept { return Iterator{container, container.next()}; }
        ConstIterator begin() const noexcept { return Iterator{container, container.next()}; }
        Iterator end() noexcept { return Iterator{container}; }
        ConstIterator end() const noexcept { return Iterator{container}; }

        template <class T>
        void send(T&& entry)
        {
            container.send(std::forward<T>(entry));
        }

        void close()
        {
            container.close();
        }

    private:
        ChannelContainer<Type> container;
    };
}

#endif // OUZEL_THREAD_CHANNEL_HPP
<commit_msg>Use predicate in wait<commit_after>// Ouzel by Elviss Strazdins

#ifndef OUZEL_THREAD_CHANNEL_HPP
#define OUZEL_THREAD_CHANNEL_HPP

#include <condition_variable>
#include <memory>
#include <mutex>
#include <vector>
#include "Semaphore.hpp"

namespace ouzel::thread
{
    template <class Type>
    class ChannelContainer final
    {
    public:
        ChannelContainer(std::ptrdiff_t c):
            capacity{c},
            semaphore{c}
        {}

        ~ChannelContainer()
        {
            std::unique_lock lock(queueMutex);
            closed = true;
            lock.unlock();
            if (capacity > 0) semaphore.acquire();
            queueCondition.notify_all();
        }

        ChannelContainer(const ChannelContainer&) = delete;
        ChannelContainer& operator=(const ChannelContainer&) = delete;
        ChannelContainer(ChannelContainer&&) = delete;
        ChannelContainer& operator=(ChannelContainer&&) = delete;

        template <class T>
        void send(T&& entry)
        {
            std::unique_lock lock(queueMutex);
            if (!closed) queue.push(std::forward<T>(entry));
            lock.unlock();
            if (capacity > 0) semaphore.acquire();
            queueCondition.notify_all();
        }

        void close()
        {
            std::unique_lock lock(queueMutex);
            closed = true;
            lock.unlock();
            if (capacity > 0) semaphore.acquire();
            queueCondition.notify_all();
        }

        std::unique_ptr<Type> next() const
        {
            std::unique_lock lock(queueMutex);
            queueCondition.wait(lock, [this]() { return closed || !queue.empty(); });

            if (!queue.empty())
            {
                auto result = std::make_unique<Type>(std::move(queue.front()));
                queue.pop();
                lock.unlock();
                if (capacity > 0) semaphore.release();
                return result;
            }
            else
                return std::unique_ptr<Type>{};
        }

    private:
        bool closed = false;
        mutable std::queue<Type> queue;
        mutable std::mutex queueMutex;
        mutable std::condition_variable queueCondition;
        std::ptrdiff_t capacity = 0;
        mutable Semaphore semaphore;
    };

    template <class Type>
    class ChannelIterator final
    {
    public:
        explicit ChannelIterator(const ChannelContainer<Type>& c) noexcept:
            container{c} {}
        ChannelIterator(const ChannelContainer<Type>& c, std::unique_ptr<Type> p) noexcept:
            container{c}, ptr{std::move(p)} {}

        operator bool() const noexcept { return ptr != nullptr; }

        bool operator==(const ChannelIterator& i) const noexcept { return ptr == i.ptr; }
        bool operator!=(const ChannelIterator& i) const noexcept { return ptr != i.ptr; }

        Type& operator*() noexcept { return *ptr; }
        const Type& operator*() const noexcept { return *ptr; }
        Type* operator->() noexcept { return ptr.get(); }
        const Type* operator->() const noexcept { return ptr.get(); }

        ChannelIterator& operator++() noexcept
        {
            ptr = container.next();
            return *this;
        }

        ChannelIterator operator++(int) noexcept
        {
            auto p = std::move(ptr);
            ptr = container.next();
            return ChannelIterator{container, std::move(p)};
        }

    private:
        const ChannelContainer<Type>& container;
        std::unique_ptr<Type> ptr;
    };

    template <class Type>
    class Channel final
    {
    public:
        using Iterator = ChannelIterator<Type>;
        using ConstIterator = ChannelIterator<const Type>;

        Channel(std::ptrdiff_t capacity = 0): container{capacity} {}

        Iterator begin() noexcept { return Iterator{container, container.next()}; }
        ConstIterator begin() const noexcept { return Iterator{container, container.next()}; }
        Iterator end() noexcept { return Iterator{container}; }
        ConstIterator end() const noexcept { return Iterator{container}; }

        template <class T>
        void send(T&& entry)
        {
            container.send(std::forward<T>(entry));
        }

        void close()
        {
            container.close();
        }

    private:
        ChannelContainer<Type> container;
    };
}

#endif // OUZEL_THREAD_CHANNEL_HPP
<|endoftext|>


<commit_before>/*
 * ColumnArchive.hpp
 *
 *  Created on: Jul 5, 2016
 *      Author: pschultz
 */

#ifndef SRC_COLUMNARCHIVE_HPP_
#define COLUMNARCHIVE_HPP_

#include <include/PVLayerLoc.h>
#include <include/pv_datatypes.h>
#include <layers/HyPerLayer.hpp>
#include <connections/HyPerConn.hpp>
#include <columns/HyPerCol.hpp>

struct LayerArchive {
   std::string name;
   PVLayerLoc layerLoc;
   std::vector<pvdata_t> data;
   bool operator==(LayerArchive const& comparison) const;
   bool operator!=(LayerArchive const& comparison) const { return !(operator==(comparison)); }
   pvdata_t tolerance;
};

struct ConnArchive {
   std::string name;
   bool sharedWeights;
   int numArbors;
   int numDataPatches;
   int nxp;
   int nyp;
   int nfp;
   std::vector<std::vector<pvwdata_t>> data; // outer index is arbors, inner index is individual weights, with nxp,nyp,nfp,numDataPatches squashed.
   bool operator==(ConnArchive const& comparison) const;
   bool operator!=(ConnArchive const& comparison) const { return !(operator==(comparison)); }
   pvwdata_t tolerance;
};

class ColumnArchive {
public:
   ColumnArchive(PV::HyPerCol * hc, pvdata_t layerTolerance, pvwdata_t connTolerance) { addCol(hc, layerTolerance, connTolerance); }
   virtual ~ColumnArchive() {}

   std::vector<LayerArchive>::size_type getNumLayers() const { return m_layerdata.size(); }
   std::vector<LayerArchive> const& getLayerData() const { return m_layerdata; }
   LayerArchive const& getLayerData(int l) const { return m_layerdata.at(l); }

   std::vector<ConnArchive>::size_type getNumConns() const { return m_conndata.size(); }
   std::vector<ConnArchive> const& getConnData() const { return m_conndata; }
   ConnArchive const& getConnData(int c) const { return m_conndata.at(c); }

   bool operator== (ColumnArchive const& comparison) const;
   bool operator!= (ColumnArchive const& comparison) const { return !(operator==(comparison)); }

private:
   ColumnArchive() {}
   void addCol(PV::HyPerCol * hc, pvdata_t layerTolerance, pvwdata_t connTolerance);
   void addLayer(PV::HyPerLayer * layer, pvdata_t layerTolerance);
   void addConn(PV::HyPerConn * conn, pvwdata_t connTolerance);

private:
   std::vector<LayerArchive> m_layerdata;
   std::vector<ConnArchive> m_conndata;
};

template <typename T> bool compareFields(char const * type, char const * field, T val1, T val2) {
   if (val1 != val2) {
      pvErrorNoExit() << type << " have different " << field << ": " << val1 << " versus \"" << val2 << ".\n";
      return false;
   }
   else {
      return true;
   }
}

#endif /* COLUMNARCHIVE_HPP_ */
<commit_msg>Removes stray quotation mark from print statement<commit_after>/*
 * ColumnArchive.hpp
 *
 *  Created on: Jul 5, 2016
 *      Author: pschultz
 */

#ifndef SRC_COLUMNARCHIVE_HPP_
#define COLUMNARCHIVE_HPP_

#include <include/PVLayerLoc.h>
#include <include/pv_datatypes.h>
#include <layers/HyPerLayer.hpp>
#include <connections/HyPerConn.hpp>
#include <columns/HyPerCol.hpp>

struct LayerArchive {
   std::string name;
   PVLayerLoc layerLoc;
   std::vector<pvdata_t> data;
   bool operator==(LayerArchive const& comparison) const;
   bool operator!=(LayerArchive const& comparison) const { return !(operator==(comparison)); }
   pvdata_t tolerance;
};

struct ConnArchive {
   std::string name;
   bool sharedWeights;
   int numArbors;
   int numDataPatches;
   int nxp;
   int nyp;
   int nfp;
   std::vector<std::vector<pvwdata_t>> data; // outer index is arbors, inner index is individual weights, with nxp,nyp,nfp,numDataPatches squashed.
   bool operator==(ConnArchive const& comparison) const;
   bool operator!=(ConnArchive const& comparison) const { return !(operator==(comparison)); }
   pvwdata_t tolerance;
};

class ColumnArchive {
public:
   ColumnArchive(PV::HyPerCol * hc, pvdata_t layerTolerance, pvwdata_t connTolerance) { addCol(hc, layerTolerance, connTolerance); }
   virtual ~ColumnArchive() {}

   std::vector<LayerArchive>::size_type getNumLayers() const { return m_layerdata.size(); }
   std::vector<LayerArchive> const& getLayerData() const { return m_layerdata; }
   LayerArchive const& getLayerData(int l) const { return m_layerdata.at(l); }

   std::vector<ConnArchive>::size_type getNumConns() const { return m_conndata.size(); }
   std::vector<ConnArchive> const& getConnData() const { return m_conndata; }
   ConnArchive const& getConnData(int c) const { return m_conndata.at(c); }

   bool operator== (ColumnArchive const& comparison) const;
   bool operator!= (ColumnArchive const& comparison) const { return !(operator==(comparison)); }

private:
   ColumnArchive() {}
   void addCol(PV::HyPerCol * hc, pvdata_t layerTolerance, pvwdata_t connTolerance);
   void addLayer(PV::HyPerLayer * layer, pvdata_t layerTolerance);
   void addConn(PV::HyPerConn * conn, pvwdata_t connTolerance);

private:
   std::vector<LayerArchive> m_layerdata;
   std::vector<ConnArchive> m_conndata;
};

template <typename T> bool compareFields(char const * type, char const * field, T val1, T val2) {
   if (val1 != val2) {
      pvErrorNoExit() << type << " have different " << field << ": " << val1 << " versus " << val2 << ".\n";
      return false;
   }
   else {
      return true;
   }
}

#endif /* COLUMNARCHIVE_HPP_ */
<|endoftext|>


<commit_before>#ifndef TEAMINFO_HPP
#define TEAMINFO_HPP

#include <string>
#include <vector>
#include <protobuf/referee.pb.h>

// Information about a single team.
class TeamInfo {
public:
	// The team's name (empty string if operator has not typed anything).
	std::string name;
	// The number of goals scored by the team during normal play and overtime.
	uint score;
	// The number of red cards issued to the team since the beginning of the game.
	uint red_cards;
	// The amount of time (in microseconds) left on each yellow card issued to the team.
	// If no yellow cards are issued, this array has no elements.
	// Otherwise, times are ordered from smallest to largest.
	std::vector<uint> yellow_card_times;
	// The total number of yellow cards ever issued to the team.
	uint yellow_cards;
	// The number of timeouts this team can still call.
	// If in a timeout right now, that timeout is excluded.
	uint timeouts_left;
	// The number of microseconds of timeout this team can use.
	uint timeout_time;
	// The pattern number of this team's goalie.
	uint goalie;

	TeamInfo()
		: name(""),
		  score(0),
		  red_cards(0),
		  yellow_cards(0),
		  timeouts_left(0),
		  timeout_time(0),
		  goalie(0)
	{
	}

	void ParseRefboxPacket(SSL_Referee_TeamInfo packet)
	{
		name = packet.name();
		score = packet.score();
		red_cards = packet.red_cards();
		yellow_cards = packet.yellow_cards();
		yellow_card_times.resize(yellow_cards);
		for(int i = 0; i < yellow_cards; i++)
			yellow_card_times[i] = packet.yellow_card_times(i);
		timeouts_left = packet.timeouts();
		timeout_time = packet.timeout_time();
		goalie = packet.goalie();
	}
};

#endif // TEAMINFO_HPP
<commit_msg>Fixes bug in parsing TeamInfo from referee protobuf packet.<commit_after>#ifndef TEAMINFO_HPP
#define TEAMINFO_HPP

#include <iostream>
#include <string>
#include <vector>
#include <protobuf/referee.pb.h>

// Information about a single team.
class TeamInfo {
public:
	// The team's name (empty string if operator has not typed anything).
	std::string name;
	// The number of goals scored by the team during normal play and overtime.
	uint score;
	// The number of red cards issued to the team since the beginning of the game.
	uint red_cards;
	// The amount of time (in microseconds) left on each yellow card issued to the team.
	// If no yellow cards are issued, this array has no elements.
	// Otherwise, times are ordered from smallest to largest.
	std::vector<uint> yellow_card_times;
	// The total number of yellow cards ever issued to the team.
	uint yellow_cards;
	// The number of timeouts this team can still call.
	// If in a timeout right now, that timeout is excluded.
	uint timeouts_left;
	// The number of microseconds of timeout this team can use.
	uint timeout_time;
	// The pattern number of this team's goalie.
	uint goalie;

	TeamInfo()
		: name(""),
		  score(0),
		  red_cards(0),
		  yellow_cards(0),
		  timeouts_left(0),
		  timeout_time(0),
		  goalie(0)
	{
	}

	void ParseRefboxPacket(SSL_Referee_TeamInfo packet)
	{
		name = packet.name();
		score = packet.score();
		red_cards = packet.red_cards();
		yellow_cards = packet.yellow_cards();
		yellow_card_times.resize(yellow_cards);
		for(int i = 0; i < packet.yellow_card_times_size(); i++)
			yellow_card_times[i] = packet.yellow_card_times(i);
		timeouts_left = packet.timeouts();
		timeout_time = packet.timeout_time();
		goalie = packet.goalie();
	}
};

#endif // TEAMINFO_HPP
<|endoftext|>