<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: Dff.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: hbrinkm $ $Date: 2006-11-15 16:25:48 $
 *
 *  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
 *
 ************************************************************************/

/*******************************************************************
 *
 *  $RCSfile: Dff.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: hbrinkm $ $Date: 2006-11-15 16:25:48 $
 *
 ******************************************************************/

#ifndef INCLUDED_DFF_HXX
#define INCLUDED_DFF_HXX

#include <vector>
#include <WW8StructBase.hxx>
#include <WW8ResourceModelImpl.hxx>

namespace doctok
{
using std::vector;

class DffBlock;

class DffRecord : public WW8StructBase, public doctok::Reference<Properties>,
                  public Sprm
{
    bool bInitialized;
public:
    typedef boost::shared_ptr<DffRecord> Pointer_t;

protected:
    typedef vector<Pointer_t> Records_t;
    Records_t mRecords;

    void initChildren();

public:

    DffRecord(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount);
    DffRecord(WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 nCount);
    virtual ~DffRecord() {}

    bool isContainer() const;
    sal_uInt32 calcSize() const;

    sal_uInt32 getVersion() const;
    sal_uInt32 getInstance() const;
    sal_uInt32 getRecordType() const;

    virtual DffRecord * clone() const { return new DffRecord(*this); }

    virtual void resolveLocal(Properties & rHandler);
    virtual void resolveChildren(Properties & rHandler);

    Records_t findRecords(sal_uInt32 nType, bool bRecursive = true,
                          bool bAny = false);

    void findRecords
    (sal_uInt32 nType, Records_t & rRecords,
     bool bRecursive = true, bool bAny = false);

    Records_t::iterator begin();
    Records_t::iterator end();

    sal_uInt32 getShapeType();
    sal_uInt32 getShapeId();
    sal_uInt32 getShapeBid();

    /* Properties methods */
    virtual void resolve(Properties & rHandler);
    virtual string getType() const;

    /* Sprm methods */
    virtual sal_uInt32 getId() const { return getRecordType(); }
    virtual Value::Pointer_t getValue();
    virtual doctok::Reference<BinaryObj>::Pointer_t getBinary();
    virtual doctok::Reference<Stream>::Pointer_t getStream();
    virtual doctok::Reference<Properties>::Pointer_t getProps();

    virtual string toString() const;
    virtual string getName() const;

    friend class DffBlock;
};

typedef vector<DffRecord::Pointer_t> Records_t;

class DffBlock : public WW8StructBase, public doctok::Reference<Properties>
{
    bool bInitialized;
    sal_uInt32 mnPadding;

    Records_t mRecords;

protected:
    void initChildren();

public:
    typedef boost::shared_ptr<DffBlock> Pointer_t;

    DffBlock(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount, sal_uInt32 nPadding);
    DffBlock(WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 nCount, sal_uInt32 nPadding);
    DffBlock(const DffBlock & rSrc);
    virtual ~DffBlock() {}

    Records_t findRecords(sal_uInt32 nType, bool bRecursive = true,
                          bool bAny = false);

    void findRecords(sal_uInt32 nType, Records_t & rRecords,
                     bool bRecursive = true, bool bAny = false);

    DffRecord::Pointer_t getShape(sal_uInt32 nSpid);
    DffRecord::Pointer_t getBlip(sal_uInt32 nBlip);

    Records_t::iterator begin();
    Records_t::iterator end();

    /* Properties methods */
    virtual void resolve(Properties & rHandler);
    virtual string getType() const;
};

DffRecord *
createDffRecord(WW8StructBase * pParent, sal_uInt32 nOffset,
                sal_uInt32 * nSize = NULL);

}

#endif
<commit_msg>createDffRecord from stream<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: Dff.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: hbrinkm $ $Date: 2006-11-23 09:17:09 $
 *
 *  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
 *
 ************************************************************************/

/*******************************************************************
 *
 *  $RCSfile: Dff.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: hbrinkm $ $Date: 2006-11-23 09:17:09 $
 *
 ******************************************************************/

#ifndef INCLUDED_DFF_HXX
#define INCLUDED_DFF_HXX

#include <vector>
#include <WW8StructBase.hxx>
#include <WW8ResourceModelImpl.hxx>

namespace doctok
{
using std::vector;

class DffBlock;

class DffRecord : public WW8StructBase, public doctok::Reference<Properties>,
                  public Sprm
{
    bool bInitialized;
public:
    typedef boost::shared_ptr<DffRecord> Pointer_t;

protected:
    typedef vector<Pointer_t> Records_t;
    Records_t mRecords;

    void initChildren();

public:

    DffRecord(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount);
    DffRecord(WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 nCount);
    virtual ~DffRecord() {}

    bool isContainer() const;
    sal_uInt32 calcSize() const;

    sal_uInt32 getVersion() const;
    sal_uInt32 getInstance() const;
    sal_uInt32 getRecordType() const;

    virtual DffRecord * clone() const { return new DffRecord(*this); }

    virtual void resolveLocal(Properties & rHandler);
    virtual void resolveChildren(Properties & rHandler);

    Records_t findRecords(sal_uInt32 nType, bool bRecursive = true,
                          bool bAny = false);

    void findRecords
    (sal_uInt32 nType, Records_t & rRecords,
     bool bRecursive = true, bool bAny = false);

    Records_t::iterator begin();
    Records_t::iterator end();

    sal_uInt32 getShapeType();
    sal_uInt32 getShapeId();
    sal_uInt32 getShapeBid();

    /* Properties methods */
    virtual void resolve(Properties & rHandler);
    virtual string getType() const;

    /* Sprm methods */
    virtual sal_uInt32 getId() const { return getRecordType(); }
    virtual Value::Pointer_t getValue();
    virtual doctok::Reference<BinaryObj>::Pointer_t getBinary();
    virtual doctok::Reference<Stream>::Pointer_t getStream();
    virtual doctok::Reference<Properties>::Pointer_t getProps();

    virtual string toString() const;
    virtual string getName() const;

    friend class DffBlock;
};

typedef vector<DffRecord::Pointer_t> Records_t;

class DffBlock : public WW8StructBase, public doctok::Reference<Properties>
{
    bool bInitialized;
    sal_uInt32 mnPadding;

    Records_t mRecords;

protected:
    void initChildren();

public:
    typedef boost::shared_ptr<DffBlock> Pointer_t;

    DffBlock(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount, sal_uInt32 nPadding);
    DffBlock(WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 nCount, sal_uInt32 nPadding);
    DffBlock(const DffBlock & rSrc);
    virtual ~DffBlock() {}

    Records_t findRecords(sal_uInt32 nType, bool bRecursive = true,
                          bool bAny = false);

    void findRecords(sal_uInt32 nType, Records_t & rRecords,
                     bool bRecursive = true, bool bAny = false);

    DffRecord::Pointer_t getShape(sal_uInt32 nSpid);
    DffRecord::Pointer_t getBlip(sal_uInt32 nBlip);

    Records_t::iterator begin();
    Records_t::iterator end();

    /* Properties methods */
    virtual void resolve(Properties & rHandler);
    virtual string getType() const;
};

DffRecord *
createDffRecord(WW8StructBase * pParent, sal_uInt32 nOffset,
                sal_uInt32 * nSize = NULL);
DffRecord *
createDffRecord(WW8Stream & rStream, sal_uInt32 nOffset,
                sal_uInt32 * nSize = NULL);

}

#endif
<|endoftext|>


<commit_before>// Time:  O(n)
// Space: O(n)

class Solution {
public:
    /**
     * @param ratings Children's ratings
     * @return the minimum candies you must give
     */
    int candy(vector<int>& ratings) {
        vector<int> candies(ratings.size(), 1);
        for (int i = 1; i < ratings.size(); ++i) {
            if (ratings[i] > ratings[i - 1]) {
                candies[i] = candies[i - 1] + 1;
            }
        }

        for (int i = ratings.size() - 2; i >= 0; --i) {
            if (ratings[i] > ratings[i + 1] && candies[i] <= candies[i + 1]) {
                candies[i] = candies[i + 1] + 1;
            }
        }
        return accumulate(candies.cbegin(), candies.cend(), 0);
    }
};
<commit_msg>Update candy.cpp<commit_after>// Time:  O(n)
// Space: O(n)

class Solution {
public:
    /**
     * @param ratings Children's ratings
     * @return the minimum candies you must give
     */
    int candy(vector<int>& ratings) {
        vector<int> candies(ratings.size(), 1);
        for (int i = 1; i < ratings.size(); ++i) {
            if (ratings[i] > ratings[i - 1]) {
                candies[i] = candies[i - 1] + 1;
            }
        }
        for (int i = ratings.size() - 2; i >= 0; --i) {
            if (ratings[i] > ratings[i + 1] && candies[i] <= candies[i + 1]) {
                candies[i] = candies[i + 1] + 1;
            }
        }
        return accumulate(candies.cbegin(), candies.cend(), 0);
    }
};
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: AccessibleDrawDocumentView.hxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: rt $ $Date: 2007-04-25 14:40:31 $
 *
 *  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 _SD_ACCESSIBILITY_ACCESSIBLE_DRAW_DOCUMENT_VIEW_HXX
#define _SD_ACCESSIBILITY_ACCESSIBLE_DRAW_DOCUMENT_VIEW_HXX

#ifndef _SD_ACCESSIBILITY_ACCESSIBLE_DOCUMENT_VIEW_BASE_HXX
#include "AccessibleDocumentViewBase.hxx"
#endif

namespace accessibility {

/** This class makes draw documents in the general view modes
    accessible.  It passes all shapes on the current draw page to a
    children manager and additionally creates a new shape that
    represents the actual draw page.

    Please see the documentation of the base class for further
    explanations of the individual methods.
*/
class AccessibleDrawDocumentView :
    public AccessibleDocumentViewBase
{
public:
    //=====  internal  ========================================================

    AccessibleDrawDocumentView (::sd::Window* pSdWindow,
        ::sd::ViewShell* pViewShell,
        const ::com::sun::star::uno::Reference<
        ::com::sun::star::frame::XController>& rxController,
        const ::com::sun::star::uno::Reference<
        ::com::sun::star::accessibility::XAccessible>& rxParent);

    virtual ~AccessibleDrawDocumentView (void);

    /** Complete the initialization begun in the constructor.
    */
    virtual void Init (void);

    //=====  IAccessibleViewForwarderListener  ================================

    virtual void ViewForwarderChanged (ChangeType aChangeType,
        const IAccessibleViewForwarder* pViewForwarder);

    //=====  XAccessibleContext  ==============================================

    virtual sal_Int32 SAL_CALL
        getAccessibleChildCount (void)
        throw (::com::sun::star::uno::RuntimeException);

    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
        getAccessibleChild (sal_Int32 nIndex)
        throw (::com::sun::star::uno::RuntimeException);

    //=====  lang::XEventListener  ============================================

    virtual void SAL_CALL
        disposing (const ::com::sun::star::lang::EventObject& rEventObject)
        throw (::com::sun::star::uno::RuntimeException);

    //=====  XPropertyChangeListener  =========================================

    virtual void SAL_CALL
        propertyChange (const ::com::sun::star::beans::PropertyChangeEvent& rEventObject)
        throw (::com::sun::star::uno::RuntimeException);

protected:

    //=====  XServiceInfo  ====================================================

    virtual ::rtl::OUString SAL_CALL
        getImplementationName (void)
        throw (::com::sun::star::uno::RuntimeException);

    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
        getSupportedServiceNames (void)
        throw (::com::sun::star::uno::RuntimeException);

    virtual sal_Bool
        implIsSelected( sal_Int32 nAccessibleChildIndex )
        throw (::com::sun::star::uno::RuntimeException);

    /** Select or deselect the specified child or all children if the given
        index has the special value ACCESSIBLE_SELECTION_CHILD_ALL.
        Selecting or deselecting a child sets or resets the
        <const>SELECTED</const> state and selects or deslects the UNO shape
        beeing made accessible by the child.
        @param nAccessibleChildIndex
            Index of the child to select or deselect.  If the parameter has
            the value ACCESSIBLE_SELECTION_CHILD_ALL then all children are
            selected or deslected.
        @param bSelect
            Indicates whether to select or deselect the specified child
            reps. children.
    */
    virtual void
        implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
        throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);

protected:
    /** This object manages the shapes of the represented draw page.  It is
        responsible to determine the visible shapes and create on demand the
        accessible objects representing them.
    */
    ChildrenManager* mpChildrenManager;

    // This method is called from the component helper base class while
    // disposing.
    virtual void SAL_CALL disposing (void);

    /** Create a shape the represents the page as seen on the screen.
    */
    AccessiblePageShape* CreateDrawPageShape (void);

    /// Create an accessible name that contains the current view mode.
    virtual ::rtl::OUString
        CreateAccessibleName ()
        throw (::com::sun::star::uno::RuntimeException);

    /** Create an accessible description that contains the current
        view mode.
    */
    virtual ::rtl::OUString
        CreateAccessibleDescription ()
        throw (::com::sun::star::uno::RuntimeException);

    /** Make sure that the currently focused shape sends a FOCUSED state
        change event indicating that it has (regained) the focus.
    */
    virtual void Activated (void);

    /** Make sure that the currently focused shape sends a FOCUSED state
        change event indicating that it has lost the focus.
    */
    virtual void Deactivated (void);
};

} // end of namespace accessibility

#endif
<commit_msg>INTEGRATION: CWS changefileheader (1.11.222); FILE MERGED 2008/04/01 15:35:00 thb 1.11.222.2: #i85898# Stripping all external header guards 2008/03/31 13:58:08 rt 1.11.222.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: AccessibleDrawDocumentView.hxx,v $
 * $Revision: 1.12 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _SD_ACCESSIBILITY_ACCESSIBLE_DRAW_DOCUMENT_VIEW_HXX
#define _SD_ACCESSIBILITY_ACCESSIBLE_DRAW_DOCUMENT_VIEW_HXX

#include "AccessibleDocumentViewBase.hxx"

namespace accessibility {

/** This class makes draw documents in the general view modes
    accessible.  It passes all shapes on the current draw page to a
    children manager and additionally creates a new shape that
    represents the actual draw page.

    Please see the documentation of the base class for further
    explanations of the individual methods.
*/
class AccessibleDrawDocumentView :
    public AccessibleDocumentViewBase
{
public:
    //=====  internal  ========================================================

    AccessibleDrawDocumentView (::sd::Window* pSdWindow,
        ::sd::ViewShell* pViewShell,
        const ::com::sun::star::uno::Reference<
        ::com::sun::star::frame::XController>& rxController,
        const ::com::sun::star::uno::Reference<
        ::com::sun::star::accessibility::XAccessible>& rxParent);

    virtual ~AccessibleDrawDocumentView (void);

    /** Complete the initialization begun in the constructor.
    */
    virtual void Init (void);

    //=====  IAccessibleViewForwarderListener  ================================

    virtual void ViewForwarderChanged (ChangeType aChangeType,
        const IAccessibleViewForwarder* pViewForwarder);

    //=====  XAccessibleContext  ==============================================

    virtual sal_Int32 SAL_CALL
        getAccessibleChildCount (void)
        throw (::com::sun::star::uno::RuntimeException);

    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
        getAccessibleChild (sal_Int32 nIndex)
        throw (::com::sun::star::uno::RuntimeException);

    //=====  lang::XEventListener  ============================================

    virtual void SAL_CALL
        disposing (const ::com::sun::star::lang::EventObject& rEventObject)
        throw (::com::sun::star::uno::RuntimeException);

    //=====  XPropertyChangeListener  =========================================

    virtual void SAL_CALL
        propertyChange (const ::com::sun::star::beans::PropertyChangeEvent& rEventObject)
        throw (::com::sun::star::uno::RuntimeException);

protected:

    //=====  XServiceInfo  ====================================================

    virtual ::rtl::OUString SAL_CALL
        getImplementationName (void)
        throw (::com::sun::star::uno::RuntimeException);

    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
        getSupportedServiceNames (void)
        throw (::com::sun::star::uno::RuntimeException);

    virtual sal_Bool
        implIsSelected( sal_Int32 nAccessibleChildIndex )
        throw (::com::sun::star::uno::RuntimeException);

    /** Select or deselect the specified child or all children if the given
        index has the special value ACCESSIBLE_SELECTION_CHILD_ALL.
        Selecting or deselecting a child sets or resets the
        <const>SELECTED</const> state and selects or deslects the UNO shape
        beeing made accessible by the child.
        @param nAccessibleChildIndex
            Index of the child to select or deselect.  If the parameter has
            the value ACCESSIBLE_SELECTION_CHILD_ALL then all children are
            selected or deslected.
        @param bSelect
            Indicates whether to select or deselect the specified child
            reps. children.
    */
    virtual void
        implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
        throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);

protected:
    /** This object manages the shapes of the represented draw page.  It is
        responsible to determine the visible shapes and create on demand the
        accessible objects representing them.
    */
    ChildrenManager* mpChildrenManager;

    // This method is called from the component helper base class while
    // disposing.
    virtual void SAL_CALL disposing (void);

    /** Create a shape the represents the page as seen on the screen.
    */
    AccessiblePageShape* CreateDrawPageShape (void);

    /// Create an accessible name that contains the current view mode.
    virtual ::rtl::OUString
        CreateAccessibleName ()
        throw (::com::sun::star::uno::RuntimeException);

    /** Create an accessible description that contains the current
        view mode.
    */
    virtual ::rtl::OUString
        CreateAccessibleDescription ()
        throw (::com::sun::star::uno::RuntimeException);

    /** Make sure that the currently focused shape sends a FOCUSED state
        change event indicating that it has (regained) the focus.
    */
    virtual void Activated (void);

    /** Make sure that the currently focused shape sends a FOCUSED state
        change event indicating that it has lost the focus.
    */
    virtual void Deactivated (void);
};

} // end of namespace accessibility

#endif
<|endoftext|>


<commit_before>
/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: ModuleController.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: rt $ $Date: 2007-04-03 16:11:35 $
 *
 *  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 SD_FRAMEWORK_MODULE_CONTROLLER_HXX
#define SD_FRAMEWORK_MODULE_CONTROLLER_HXX

#include "MutexOwner.hxx"

#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif
#ifndef _COM_SUN_STAR_DRAWING_FRAMEWORK_XMODULECONTROLLER_HPP_
#include <com/sun/star/drawing/framework/XModuleController.hpp>
#endif
#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
#include <com/sun/star/uno/XComponentContext.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
#include <com/sun/star/lang/XInitialization.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
#include <com/sun/star/frame/XController.hpp>
#endif
#ifndef _CPPUHELPER_COMPBASE2_HXX_
#include <cppuhelper/compbase2.hxx>
#endif

#include <boost/scoped_ptr.hpp>
#include <set>

namespace {

typedef ::cppu::WeakComponentImplHelper2 <
    ::com::sun::star::drawing::framework::XModuleController,
    ::com::sun::star::lang::XInitialization
    > ModuleControllerInterfaceBase;

} // end of anonymous namespace.

namespace sd { namespace framework {

/** At the moment the ModuleController reads the
    org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories
    configuration data that maps from resource URLs to service names of
    factories that can create resources for the URLs.  When a resource
    controller, for example the PaneController, wants to create a pane for
    which it does not have a factory, it asks the ModuleController to
    provide one.  The ModuleController looks up the service name registere
    for the resource URL, in this case a pane URL and instantiates the
    service.  The service is expected to register on its creation a factory
    for the resource in question.

    This simple concept may be extended in the future.
*/
class ModuleController
    : private sd::MutexOwner,
      public ModuleControllerInterfaceBase
{
public:
    static ::com::sun::star::uno::Reference<
        ::com::sun::star::drawing::framework::XModuleController>
        CreateInstance (
            const ::com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>&
            rxContext);

    virtual void SAL_CALL disposing (void);

    // XModuleController

    virtual void SAL_CALL requestResource(const ::rtl::OUString& rsResourceURL)
        throw (::com::sun::star::uno::RuntimeException);

    // XInitialization

    virtual void SAL_CALL initialize(
        const ::com::sun::star::uno::Sequence<com::sun::star::uno::Any>& aArguments)
        throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);

private:
    ::com::sun::star::uno::Reference<
        com::sun::star::frame::XController> mxController;

    class ResourceToFactoryMap;
    ::boost::scoped_ptr<ResourceToFactoryMap> mpResourceToFactoryMap;
    class LoadedFactoryContainer;
    ::boost::scoped_ptr<LoadedFactoryContainer> mpLoadedFactories;

    ModuleController (
        const ::com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& rxContext)
        throw();
    ModuleController (void); // Not implemented.
    ModuleController (const ModuleController&); // Not implemented.
    virtual ~ModuleController (void) throw();
    void LoadFactories (void);
    void ProcessFactory (const ::std::vector<com::sun::star::uno::Any>& rValues);
};

} } // end of namespace sd::framework

#endif
<commit_msg>INTEGRATION: CWS presenterview (1.2.22); FILE MERGED 2007/07/10 14:29:14 af 1.2.22.2: #i18486# Typos. 2007/06/19 08:14:07 af 1.2.22.1: #i18486# Added code for instantiating services at framework startup.<commit_after>
/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: ModuleController.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: kz $ $Date: 2008-04-03 14:03: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 SD_FRAMEWORK_MODULE_CONTROLLER_HXX
#define SD_FRAMEWORK_MODULE_CONTROLLER_HXX

#include "MutexOwner.hxx"

#include <osl/mutex.hxx>
#include <com/sun/star/drawing/framework/XModuleController.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <cppuhelper/compbase2.hxx>

#include <boost/scoped_ptr.hpp>
#include <set>

namespace css = ::com::sun::star;

namespace {

typedef ::cppu::WeakComponentImplHelper2 <
    css::drawing::framework::XModuleController,
    css::lang::XInitialization
    > ModuleControllerInterfaceBase;

} // end of anonymous namespace.

namespace sd { namespace framework {

/** The ModuleController has to tasks:

    1. It reads the
    org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories
    configuration data that maps from resource URLs to service names of
    factories that can create resources for the URLs.  When the
    configuration controller wants to create a resource for which it does
    not have a factory, it asks the ModuleController to provide one.  The
    ModuleController looks up the service name registered for the URL of the
    resource and instantiates this service.  The service is expected to
    register on its creation a factory for the resource in question.

    2. The ModuleController reads on its creation
    org.openoffice.Office.Impress/MultiPaneGUI/Framework/StartupServices
    configuration data and instantiates all listed services.  These servces
    can then register as listeners at the ConfigurationController or do
    whatever they like.
*/
class ModuleController
    : private sd::MutexOwner,
      public ModuleControllerInterfaceBase
{
public:
    static css::uno::Reference<
        css::drawing::framework::XModuleController>
        CreateInstance (
            const css::uno::Reference<css::uno::XComponentContext>&
            rxContext);

    virtual void SAL_CALL disposing (void);

    // XModuleController

    virtual void SAL_CALL requestResource(const ::rtl::OUString& rsResourceURL)
        throw (css::uno::RuntimeException);

    // XInitialization

    virtual void SAL_CALL initialize(
        const css::uno::Sequence<css::uno::Any>& aArguments)
        throw (css::uno::Exception, css::uno::RuntimeException);

private:
    css::uno::Reference<
        css::frame::XController> mxController;

    class ResourceToFactoryMap;
    ::boost::scoped_ptr<ResourceToFactoryMap> mpResourceToFactoryMap;
    class LoadedFactoryContainer;
    ::boost::scoped_ptr<LoadedFactoryContainer> mpLoadedFactories;

    ModuleController (
        const css::uno::Reference<css::uno::XComponentContext>& rxContext)
        throw();
    ModuleController (void); // Not implemented.
    ModuleController (const ModuleController&); // Not implemented.
    virtual ~ModuleController (void) throw();

    /** Load a list of URL to service mappings from the
        /org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories
        configuration entry.  The mappings are stored in the
        mpResourceToFactoryMap member.
    */
    void LoadFactories (const css::uno::Reference<css::uno::XComponentContext>& rxContext);

    /** Called for every entry in the ResourceFactories configuration entry.
    */
    void ProcessFactory (const ::std::vector<css::uno::Any>& rValues);

    /** Instantiate all startup services that are found in the
        /org.openoffice.Office.Impress/MultiPaneGUI/Framework/StartupServices
        configuration entry.  This method is called once when a new
        ModuleController object is created.
    */
    void InstantiateStartupServices (void);

    /** Called for one entry in the StartupServices configuration list this
        method instantiates the service described by the entry.  It does not
        hold references to the new object so that the object will be
        destroyed on function exit when it does not register itself
        somewhere.  It typically will register as
        XConfigurationChangeListener at the configuration controller.
    */
    void ProcessStartupService (const ::std::vector<css::uno::Any>& rValues);
};

} } // end of namespace sd::framework

#endif
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: MetaExportComponent.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-20 08:11:12 $
 *
 *  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 _XMLOFF_METAEXPORTCOMPONENT_HXX
#define _XMLOFF_METAEXPORTCOMPONENT_HXX

#ifndef _XMLOFF_XMLEXP_HXX
#include "xmlexp.hxx"
#endif

class XMLMetaExportComponent : public SvXMLExport
{
public:
    // #110680#
    // XMLMetaExportComponent();
    XMLMetaExportComponent(
        const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
        sal_uInt16 nFlags
        );

    ~XMLMetaExportComponent();

protected:
    // export the events off all autotexts
    virtual sal_uInt32 exportDoc(
        enum ::xmloff::token::XMLTokenEnum eClass = xmloff::token::XML_TOKEN_INVALID );

    // methods without content:
    virtual void _ExportAutoStyles();
    virtual void _ExportMasterStyles();
    virtual void _ExportContent();
};

// global functions to support the component

::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
    XMLMetaExportComponent_getSupportedServiceNames()
    throw();

::rtl::OUString SAL_CALL XMLMetaExportComponent_getImplementationName()
    throw();

::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
    XMLMetaExportComponent_createInstance(
        const ::com::sun::star::uno::Reference<
            ::com::sun::star::lang::XMultiServiceFactory > & )
    throw( ::com::sun::star::uno::Exception );

#endif

<commit_msg>INTEGRATION: CWS ooo19126 (1.5.270); FILE MERGED 2005/09/05 14:37:48 rt 1.5.270.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: MetaExportComponent.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 12:37:37 $
 *
 *  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 _XMLOFF_METAEXPORTCOMPONENT_HXX
#define _XMLOFF_METAEXPORTCOMPONENT_HXX

#ifndef _XMLOFF_XMLEXP_HXX
#include "xmlexp.hxx"
#endif

class XMLMetaExportComponent : public SvXMLExport
{
public:
    // #110680#
    // XMLMetaExportComponent();
    XMLMetaExportComponent(
        const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
        sal_uInt16 nFlags
        );

    ~XMLMetaExportComponent();

protected:
    // export the events off all autotexts
    virtual sal_uInt32 exportDoc(
        enum ::xmloff::token::XMLTokenEnum eClass = xmloff::token::XML_TOKEN_INVALID );

    // methods without content:
    virtual void _ExportAutoStyles();
    virtual void _ExportMasterStyles();
    virtual void _ExportContent();
};

// global functions to support the component

::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
    XMLMetaExportComponent_getSupportedServiceNames()
    throw();

::rtl::OUString SAL_CALL XMLMetaExportComponent_getImplementationName()
    throw();

::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
    XMLMetaExportComponent_createInstance(
        const ::com::sun::star::uno::Reference<
            ::com::sun::star::lang::XMultiServiceFactory > & )
    throw( ::com::sun::star::uno::Exception );

#endif

<|endoftext|>


<commit_before>#include "stdafx.h"
//scene
#include "StageScene.h"
#include "MainScene.h"
#include "GameScene.h"
#include "IntroScene.h"
#include "EndingScene.h"
//layer
#include "UILayer.h"
//info
#include "LightManager.h"
#include "StageInformation.h"
//manager
#include "GameManager.h"
//config
#include "ConstVars.h"
#include "FileStuff.h"
//etc
#include "Sling.h"
#include <SimpleAudioEngine.h>

Scene* StageScene::createScene()
{
	Scene* scene = Scene::create();
	scene->setAnchorPoint(Vec2::ZERO);
	scene->setPosition(Vec2::ZERO);

	Layer* layer = StageScene::create();
	layer->setName("stageScene");
	layer->setAnchorPoint(Vec2::ZERO);
	layer->setPosition(Vec2::ZERO);

	scene->addChild(layer);

	return scene;
}

bool StageScene::m_justCleared = true;

bool StageScene::init()
{
	if (!LayerColor::initWithColor(Color4B::BLACK))
	{
		return false;
	}

	setName("StageScene");

	m_stageToPlay = UserDefault::getInstance()->getIntegerForKey(ConstVars::LASTSTAGE);
	m_maxStageNum = StageInformation::GetMaxStageNum();

	m_background = LoadBackground();
	addChild(m_background);

	m_lightManager = new LightManager();

	SetBGM();

	if (m_stageToPlay == 13)
	{
		scheduleOnce(schedule_selector(StageScene::EndingEvent), 0.0f);
		return true;
	}

	MenuItemImage* backButton = MakeBackButton();
	Menu* menu = Menu::create(backButton, nullptr);
	menu->setPosition(Vec2::ZERO);
	addChild(menu);

	SetupLight();
	SetupCharacter();

	return true;
}

void StageScene::ChangeCharacterToButton(Point finalPos, float scale)
{

	MenuItemImage* character = MenuItemImage::create();
	character->setNormalImage(
		Sprite::createWithSpriteFrame(
		SpriteFrameCache::getInstance()->getSpriteFrameByName(FileStuff::CHARACTER_CACHE)
		)
	);

	character->setSelectedImage(
		Sprite::createWithSpriteFrame(
		SpriteFrameCache::getInstance()->getSpriteFrameByName(FileStuff::CHARACTER_SELECTED)
		)
	);

	character->setScale(scale);
	character->setCallback(CC_CALLBACK_0(StageScene::GotoStage, this, m_stageToPlay));

	Menu* menu = Menu::create(character, nullptr);
	menu->setPosition(finalPos);
	addChild(menu);

}

void StageScene::PlaySound(const char* file)
{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(file);
}

void StageScene::MoveCharacter(Sprite* character, int stageNum)
{
	//ִϸ̼   ϴ κ
	Point finishPos = GetCharacterPosition(stageNum);
	Point startPos = GetCharacterPosition(m_stageToPlay - 1);
	Size screenSize = Director::getInstance()->getVisibleSize();
	float startScale = character->getScale()* (1 - startPos.y / (screenSize.height * 1.5));
	float finishScale = character->getScale() * (1 - finishPos.y / (screenSize.height * 1.5));
	float timeLength = 2.0f;
	float standingTime = 2.0f;
	if (stageNum == 1)
	{
		standingTime = 0.1f;
	}

	int last_played_stage = UserDefault::getInstance()->getIntegerForKey(ConstVars::LASTWALKSTAGE);
	if (last_played_stage != m_stageToPlay)
	{

		//̵
		character->setPosition(startPos);
		character->runAction(Sequence::create(
			DelayTime::create(standingTime),
			CallFunc::create(CC_CALLBACK_0(StageScene::PlaySound, this, FileStuff::SOUND_FOOTSTEP)),
			MoveTo::create(timeLength, finishPos),
			CallFunc::create(CC_CALLBACK_0(StageScene::ChangeCharacterToButton, this, finishPos, finishScale)),
			RemoveSelf::create(),
			nullptr
			)
		);

		//ũ⺯ȭ
		character->setScale(startScale);
		ScaleTo* scaleAction = ScaleTo::create(timeLength, finishScale);
		character->runAction(Sequence::create(
			DelayTime::create(standingTime),
			ScaleTo::create(timeLength, finishScale),
			nullptr)
		);

		UserDefault::getInstance()->setIntegerForKey(ConstVars::LASTWALKSTAGE, m_stageToPlay);
	}
	else
	{
		ChangeCharacterToButton(finishPos, finishScale);
	}

}

void StageScene::SetupCharacter()
{

	Sprite* character = Sprite::createWithSpriteFrame(
		SpriteFrameCache::getInstance()->getSpriteFrameByName(FileStuff::CHARACTER_CACHE)
		);

	addChild(character);

	MoveCharacter(character, m_stageToPlay);

}

Point StageScene::GetCharacterPosition(int stage)
{
	Size screenSize = Director::getInstance()->getVisibleSize();
	if (stage == 0)
	{
		return Point(screenSize.width / 2 , 0);
	}
	LightManager mng;
	int odd = stage % 2;
	Vec2 lightPos = mng.GetPosition(stage);

	/* ġ 󸶳   ǥ.*/
	float posRatio = .7f ;
	Vec2 currentDelta = Vec2(-50, -70);
	currentDelta.x *= -(odd);
	currentDelta.x -= 20;

	return lightPos + posRatio * currentDelta;
}

Sprite* StageScene::LoadBackground()
{
	Sprite* background;
	switch (m_stageToPlay)
	{
	case 1:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_01);
		break;
	case 2:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_02);
		break;
	case 3:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_03);
		break;
	case 4:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_04);
		break;
	case 5:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_05);
		break;
	case 6:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_06);
		break;
	case 7:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_07);
		break;
	case 8:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_08);
		break;
	case 9:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_09);
		break;
	case 10:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_10);
		break;
	case 11:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_11);
		break;
	case 12:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_12);
		break;
	case 13:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_13OFF);
		break;
	}

	float scale = (Director::getInstance()->getVisibleSize().width) / (background->getContentSize().width);
	background->setAnchorPoint(Point::ZERO);
	background->setScale(scale);

	return background;
}

void StageScene::SetBGM()
{
	if (m_stageToPlay >= 12)
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(FileStuff::SOUND_BEFORE_ENDING_BACKGROUND, true);
	}
	else if (m_stageToPlay >= 5)
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(FileStuff::SOUND_MIDDLE_PHASE_BACKGROUND, true);
	}
	else if (m_stageToPlay >= 1)
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(FileStuff::SOUND_INITIAL_BACKGROUND, true);
	}
}

void StageScene::SetupLight()
{
	int last_played_stage = UserDefault::getInstance()->getIntegerForKey(ConstVars::LASTWALKSTAGE);
	if (last_played_stage == 0)
	{
		return;
	}

	if (last_played_stage != m_stageToPlay)
	{
		for (int i = 1; i <= m_maxStageNum && i < last_played_stage; i++)
		{
			addChild(m_lightManager->GetLight(i));
		}
		//   ȿ
		Sprite* lastLight = m_lightManager->GetLight(last_played_stage);
		lastLight->setOpacity(0);
		FadeIn* fadeIn = FadeIn::create(2.0f);
		lastLight->runAction(fadeIn);
		addChild(lastLight);

		//9ź  ҳ
		if (m_stageToPlay == 10){
			Sprite* girlLikeGhost = Sprite::create(FileStuff::GHOSTGIRL);
			girlLikeGhost->setOpacity(10);
			girlLikeGhost->setScale(0.3f);
			girlLikeGhost->setPosition(37, 45);
			Sequence* seq = Sequence::create(DelayTime::create(0.5f),
				DelayTime::create(0.5),
				FadeTo::create(0.5f,100),
				DelayTime::create(0.5f),
				FadeOut::create(0.3f),
				DelayTime::create(3.0f),
				FadeTo::create(0.8f, 70),
				FadeOut::create(0.9f),
				nullptr
				);
			girlLikeGhost->runAction(seq);
			lastLight->addChild(girlLikeGhost);

		}

	}else
	{
		for (int i = 1; i <= m_maxStageNum && i < m_stageToPlay; i++)
		{
			addChild(m_lightManager->GetLight(i));
		}
	}
}

void StageScene::EndingEvent(float dt)
{
	CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
	CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(FileStuff::SOUND_BEFORE_ENDING_BACKGROUND);

	Sequence* seq = Sequence::create(
		DelayTime::create(2.3f),
		CallFuncN::create(CC_CALLBACK_0(StageScene::ShowBlinkingLight, this)),
		DelayTime::create(4.0f),
		CallFuncN::create(CC_CALLBACK_0(StageScene::ShowBlinkingLight, this)),
		DelayTime::create(3.0f),
 		CallFuncN::create(CC_CALLBACK_0(StageScene::ShowDeadbody, this)),
 		DelayTime::create(2.0f),
		CallFuncN::create(CC_CALLBACK_0(StageScene::ChangeToEndingScene, this)),
		nullptr);

	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(FileStuff::SOUND_SHOCKED);
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(FileStuff::SOUND_CRASH);

	runAction(seq);
}

void StageScene::ChangeToEndingScene()
{
	Director::getInstance()->replaceScene(EndingScene::createScene());
}

void StageScene::ShowDeadbody()
{
	m_background->removeFromParent();
	m_background = Sprite::create(FileStuff::STAGE_BACKGROUND_13APP);
	float scale = (Director::getInstance()->getVisibleSize().width) / (m_background->getContentSize().width);
	m_background->setAnchorPoint(Point::ZERO);
	m_background->setScale(scale);
	addChild(m_background);

	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(FileStuff::SOUND_SHOCKED, false, 3.0f);
	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(FileStuff::SOUND_CRASH, false, 3.0f);
}

void StageScene::SetStreetLight(int isOn)
{
	m_background->removeFromParent();
	if (isOn)
		m_background = Sprite::create(FileStuff::STAGE_BACKGROUND_13ON);
	else
		m_background = Sprite::create(FileStuff::STAGE_BACKGROUND_13OFF);

	float scale = (Director::getInstance()->getVisibleSize().width) / (m_background->getContentSize().width);
	m_background->setAnchorPoint(Point::ZERO);
	m_background->setScale(scale);
	addChild(m_background);
}

void StageScene::ShowBlinkingLight()
{
	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(FileStuff::SOUND_STREETLIGHTS);

	CallFunc* lightOff = CallFunc::create(CC_CALLBACK_0(StageScene::SetStreetLight, this, false));
	CallFunc* lightOn = CallFunc::create(CC_CALLBACK_0(StageScene::SetStreetLight, this, true));

	Sequence* seq = Sequence::create(
		lightOn,
		DelayTime::create(0.25f),
		lightOff,
		DelayTime::create(1.0f),
		lightOn,
		DelayTime::create(0.2f),
		lightOff,
		DelayTime::create(0.2f),
		lightOn,
		nullptr);

	runAction(seq);
}

MenuItemImage* StageScene::MakeBackButton()
{
	MenuItemImage* button = MenuItemImage::create(
		FileStuff::PAUSEBUTTON,
		FileStuff::PAUSEBUTTON,
		CC_CALLBACK_1(StageScene::ChangeToMainScene, this));

	Size buttonSize = button->getContentSize();
	float scale = MIN(
		UILayer::PAUSE_BUTTON_WIDTH / buttonSize.width,
		UILayer::PAUSE_BUTTON_HEIGHT / buttonSize.height);
	button->setScale(scale);
	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();
	button->setPosition(
		origin.x + visibleSize.width - buttonSize.width*scale / 2,
		origin.y + buttonSize.height*scale / 2
		);

	return button;
}

void StageScene::GotoStage(Ref* pSender, int stageNum)
{
	Scene* scene = GameScene::createScene();
	GameScene* gameScene = static_cast<GameScene*>(scene->getChildByName("GameScene"));

	GameManager* gameManager = GameManager::GetInstance();
	gameManager->SetUILayer(gameScene->GetUILayer());
	gameManager->SetGameLayer(gameScene->GetGameLayer());
	gameManager->SetStage(stageNum);

	TransitionFade* sceneWithEffect = TransitionFade::create(1.5f, scene);

	Director::getInstance()->replaceScene(sceneWithEffect);
}

void StageScene::ChangeToMainScene(Ref* pSender)
{
	Director::getInstance()->replaceScene(MainScene::createScene());
}

void StageScene::ChangeToStageScene(Ref* pSender)
{
	Director::getInstance()->replaceScene(StageScene::createScene());
}<commit_msg>Fix bug<commit_after>#include "stdafx.h"
//scene
#include "StageScene.h"
#include "MainScene.h"
#include "GameScene.h"
#include "IntroScene.h"
#include "EndingScene.h"
//layer
#include "UILayer.h"
//info
#include "LightManager.h"
#include "StageInformation.h"
//manager
#include "GameManager.h"
//config
#include "ConstVars.h"
#include "FileStuff.h"
//etc
#include "Sling.h"
#include <SimpleAudioEngine.h>

Scene* StageScene::createScene()
{
	Scene* scene = Scene::create();
	scene->setAnchorPoint(Vec2::ZERO);
	scene->setPosition(Vec2::ZERO);

	Layer* layer = StageScene::create();
	layer->setName("stageScene");
	layer->setAnchorPoint(Vec2::ZERO);
	layer->setPosition(Vec2::ZERO);

	scene->addChild(layer);

	return scene;
}

bool StageScene::m_justCleared = true;

bool StageScene::init()
{
	if (!LayerColor::initWithColor(Color4B::BLACK))
	{
		return false;
	}

	setName("StageScene");

	m_stageToPlay = UserDefault::getInstance()->getIntegerForKey(ConstVars::LASTSTAGE);
	m_maxStageNum = StageInformation::GetMaxStageNum();

	m_background = LoadBackground();
	addChild(m_background);

	m_lightManager = new LightManager();

	SetBGM();

	if (m_stageToPlay == 13)
	{
		scheduleOnce(schedule_selector(StageScene::EndingEvent), 0.0f);
		return true;
	}

	MenuItemImage* backButton = MakeBackButton();
	Menu* menu = Menu::create(backButton, nullptr);
	menu->setPosition(Vec2::ZERO);
	addChild(menu);

	SetupLight();
	SetupCharacter();

	return true;
}

void StageScene::ChangeCharacterToButton(Point finalPos, float scale)
{

	MenuItemImage* character = MenuItemImage::create();
	character->setNormalImage(
		Sprite::createWithSpriteFrame(
		SpriteFrameCache::getInstance()->getSpriteFrameByName(FileStuff::CHARACTER_CACHE)
		)
	);

	character->setSelectedImage(
		Sprite::createWithSpriteFrame(
		SpriteFrameCache::getInstance()->getSpriteFrameByName(FileStuff::CHARACTER_SELECTED)
		)
	);

	character->setScale(scale);
	character->setCallback(CC_CALLBACK_0(StageScene::GotoStage, this, m_stageToPlay));

	Menu* menu = Menu::create(character, nullptr);
	menu->setPosition(finalPos);
	addChild(menu);

}

void StageScene::PlaySound(const char* file)
{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(file);
}

void StageScene::MoveCharacter(Sprite* character, int stageNum)
{
	//ִϸ̼   ϴ κ
	Point finishPos = GetCharacterPosition(stageNum);
	Point startPos = GetCharacterPosition(m_stageToPlay - 1);
	Size screenSize = Director::getInstance()->getVisibleSize();
	float startScale = character->getScale()* (1 - startPos.y / (screenSize.height * 1.5));
	float finishScale = character->getScale() * (1 - finishPos.y / (screenSize.height * 1.5));
	float timeLength = 2.0f;
	float standingTime = 2.0f;
	if (stageNum == 1)
	{
		standingTime = 0.1f;
	}

	int last_played_stage = UserDefault::getInstance()->getIntegerForKey(ConstVars::LASTWALKSTAGE);
	if (last_played_stage != m_stageToPlay)
	{

		//̵
		character->setPosition(startPos);
		character->runAction(Sequence::create(
			DelayTime::create(standingTime),
			CallFunc::create(CC_CALLBACK_0(StageScene::PlaySound, this, FileStuff::SOUND_FOOTSTEP)),
			MoveTo::create(timeLength, finishPos),
			CallFunc::create(CC_CALLBACK_0(StageScene::ChangeCharacterToButton, this, finishPos, finishScale)),
			RemoveSelf::create(),
			nullptr
			)
		);

		//ũ⺯ȭ
		character->setScale(startScale);
		ScaleTo* scaleAction = ScaleTo::create(timeLength, finishScale);
		character->runAction(Sequence::create(
			DelayTime::create(standingTime),
			ScaleTo::create(timeLength, finishScale),
			nullptr)
		);

		UserDefault::getInstance()->setIntegerForKey(ConstVars::LASTWALKSTAGE, m_stageToPlay);
	}
	else
	{
		ChangeCharacterToButton(finishPos, finishScale);
	}

}

void StageScene::SetupCharacter()
{

	Sprite* character = Sprite::createWithSpriteFrame(
		SpriteFrameCache::getInstance()->getSpriteFrameByName(FileStuff::CHARACTER_CACHE)
		);

	addChild(character);

	MoveCharacter(character, m_stageToPlay);

}

Point StageScene::GetCharacterPosition(int stage)
{
	Size screenSize = Director::getInstance()->getVisibleSize();
	if (stage == 0)
	{
		return Point(screenSize.width / 2 , 0);
	}
	LightManager mng;
	int odd = stage % 2;
	Vec2 lightPos = mng.GetPosition(stage);

	/* ġ 󸶳   ǥ.*/
	float posRatio = .7f ;
	Vec2 currentDelta = Vec2(-50, -70);
	currentDelta.x *= -(odd);
	currentDelta.x -= 20;

	return lightPos + posRatio * currentDelta;
}

Sprite* StageScene::LoadBackground()
{
	Sprite* background;
	switch (m_stageToPlay)
	{
	case 1:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_01);
		break;
	case 2:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_02);
		break;
	case 3:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_03);
		break;
	case 4:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_04);
		break;
	case 5:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_05);
		break;
	case 6:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_06);
		break;
	case 7:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_07);
		break;
	case 8:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_08);
		break;
	case 9:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_09);
		break;
	case 10:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_10);
		break;
	case 11:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_11);
		break;
	case 12:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_12);
		break;
	case 13:
		background = Sprite::create(FileStuff::STAGE_BACKGROUND_13OFF);
		break;
	}

	float scale = (Director::getInstance()->getVisibleSize().width) / (background->getContentSize().width);
	background->setAnchorPoint(Point::ZERO);
	background->setScale(scale);

	return background;
}

void StageScene::SetBGM()
{
	if (m_stageToPlay >= 12)
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(FileStuff::SOUND_BEFORE_ENDING_BACKGROUND, true);
	}
	else if (m_stageToPlay >= 5)
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(FileStuff::SOUND_MIDDLE_PHASE_BACKGROUND, true);
	}
	else if (m_stageToPlay >= 1)
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(FileStuff::SOUND_INITIAL_BACKGROUND, true);
	}
}

void StageScene::SetupLight()
{
	int last_played_stage = UserDefault::getInstance()->getIntegerForKey(ConstVars::LASTWALKSTAGE);
	if (last_played_stage == 0)
	{
		return;
	}

	if (last_played_stage != m_stageToPlay)
	{
		for (int i = 1; i <= m_maxStageNum && i < last_played_stage; i++)
		{
			addChild(m_lightManager->GetLight(i));
		}
		//   ȿ
		Sprite* lastLight = m_lightManager->GetLight(last_played_stage);
		lastLight->setOpacity(0);
		FadeIn* fadeIn = FadeIn::create(2.0f);
		lastLight->runAction(fadeIn);
		addChild(lastLight);

		//9ź  ҳ
		if (m_stageToPlay == 10){
			Sprite* girlLikeGhost = Sprite::create(FileStuff::GHOSTGIRL);
			girlLikeGhost->setOpacity(10);
			girlLikeGhost->setScale(0.3f);
			girlLikeGhost->setPosition(37, 45);
			Sequence* seq = Sequence::create(DelayTime::create(0.5f),
				DelayTime::create(0.5),
				FadeTo::create(0.5f,100),
				DelayTime::create(0.5f),
				FadeOut::create(0.3f),
				DelayTime::create(3.0f),
				FadeTo::create(0.8f, 70),
				FadeOut::create(0.9f),
				nullptr
				);
			girlLikeGhost->runAction(seq);
			lastLight->addChild(girlLikeGhost);

		}

	}else
	{
		for (int i = 1; i <= m_maxStageNum && i < m_stageToPlay; i++)
		{
			addChild(m_lightManager->GetLight(i));
		}
	}
}

void StageScene::EndingEvent(float dt)
{
	CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
	CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(FileStuff::SOUND_BEFORE_ENDING_BACKGROUND);

	Sequence* seq = Sequence::create(
		DelayTime::create(2.3f),
		CallFuncN::create(CC_CALLBACK_0(StageScene::ShowBlinkingLight, this)),
		DelayTime::create(4.0f),
		CallFuncN::create(CC_CALLBACK_0(StageScene::ShowBlinkingLight, this)),
		DelayTime::create(3.0f),
 		CallFuncN::create(CC_CALLBACK_0(StageScene::ShowDeadbody, this)),
 		DelayTime::create(2.0f),
		CallFuncN::create(CC_CALLBACK_0(StageScene::ChangeToEndingScene, this)),
		nullptr);

	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(FileStuff::SOUND_SHOCKED);
	CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(FileStuff::SOUND_CRASH);

	runAction(seq);
}

void StageScene::ChangeToEndingScene()
{
	Director::getInstance()->replaceScene(EndingScene::createScene());
}

void StageScene::ShowDeadbody()
{
	m_background->removeFromParent();
	m_background = Sprite::create(FileStuff::STAGE_BACKGROUND_13APP);
	float scale = (Director::getInstance()->getVisibleSize().width) / (m_background->getContentSize().width);
	m_background->setAnchorPoint(Point::ZERO);
	m_background->setScale(scale);
	addChild(m_background);

	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(FileStuff::SOUND_SHOCKED, false, 3.0f);
	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(FileStuff::SOUND_CRASH, false, 3.0f);
}

void StageScene::SetStreetLight(int isOn)
{
	m_background->removeFromParent();
	if (isOn)
		m_background = Sprite::create(FileStuff::STAGE_BACKGROUND_13ON);
	else
		m_background = Sprite::create(FileStuff::STAGE_BACKGROUND_13OFF);

	float scale = (Director::getInstance()->getVisibleSize().width) / (m_background->getContentSize().width);
	m_background->setAnchorPoint(Point::ZERO);
	m_background->setScale(scale);
	addChild(m_background);
}

void StageScene::ShowBlinkingLight()
{
	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(FileStuff::SOUND_STREETLIGHTS);

	CallFunc* lightOff = CallFunc::create(CC_CALLBACK_0(StageScene::SetStreetLight, this, false));
	CallFunc* lightOn = CallFunc::create(CC_CALLBACK_0(StageScene::SetStreetLight, this, true));

	Sequence* seq = Sequence::create(
		lightOn,
		DelayTime::create(0.25f),
		lightOff,
		DelayTime::create(1.0f),
		lightOn,
		DelayTime::create(0.2f),
		lightOff,
		DelayTime::create(0.2f),
		lightOn,
		nullptr);

	runAction(seq);
}

MenuItemImage* StageScene::MakeBackButton()
{
	MenuItemImage* button = MenuItemImage::create(
		FileStuff::PAUSEBUTTON,
		FileStuff::PAUSEBUTTON_CLICKED,
		CC_CALLBACK_1(StageScene::ChangeToMainScene, this));

	Size buttonSize = button->getContentSize();
	float scale = MIN(
		UILayer::PAUSE_BUTTON_WIDTH / buttonSize.width,
		UILayer::PAUSE_BUTTON_HEIGHT / buttonSize.height);
	button->setScale(scale);
	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();
	button->setPosition(
		origin.x + visibleSize.width - buttonSize.width *scale / 2,
		origin.y + buttonSize.height * scale / 2
		);

	return button;
}

void StageScene::GotoStage(Ref* pSender, int stageNum)
{
	Scene* scene = GameScene::createScene();
	GameScene* gameScene = static_cast<GameScene*>(scene->getChildByName("GameScene"));

	GameManager* gameManager = GameManager::GetInstance();
	gameManager->SetUILayer(gameScene->GetUILayer());
	gameManager->SetGameLayer(gameScene->GetGameLayer());
	gameManager->SetStage(stageNum);

	TransitionFade* sceneWithEffect = TransitionFade::create(1.5f, scene);

	Director::getInstance()->replaceScene(sceneWithEffect);
}

void StageScene::ChangeToMainScene(Ref* pSender)
{
	Director::getInstance()->replaceScene(MainScene::createScene());
}

void StageScene::ChangeToStageScene(Ref* pSender)
{
	Director::getInstance()->replaceScene(StageScene::createScene());
}<|endoftext|>


<commit_before>
#include <memory>
// using std::unique_ptr

#include <map>
// using std::map

#include <cassert>
// using assert

#include <cstdlib>
// using std::abort

#include "llvm/Config/llvm-config.h"

#include "llvm/IR/LLVMContext.h"
// using llvm::LLVMContext

#include "llvm/IR/Module.h"
// using llvm::Module

#include "llvm/IR/LegacyPassManager.h"
// using llvm::legacy::PassMananger

#include "llvm/Pass.h"
// using llvm::Pass
// using llvm::PassInfo

#include "llvm/Analysis/LoopInfo.h"
// using llvm::LoopInfoWrapperPass
// using llvm::LoopInfo

#include "llvm/Support/SourceMgr.h"
// using llvm::SMDiagnostic

#include "llvm/AsmParser/Parser.h"
// using llvm::parseAssemblyString

#include "llvm/IR/Verifier.h"
// using llvm::verifyModule

#include "llvm/Support/ErrorHandling.h"
// using llvm::report_fatal_error

#include "llvm/Support/raw_ostream.h"
// using llvm::raw_string_ostream

#include "gtest/gtest.h"
// using testing::Test

#include "boost/variant.hpp"
// using boost::variant

#include "SkeletonOptPass.hpp"

namespace icsa {
namespace {

using test_result_t = boost::variant<bool, unsigned int>;
using test_result_map = std::map<std::string, test_result_t>;

struct test_result_visitor : public boost::static_visitor<unsigned int> {
  unsigned int operator()(bool b) const { return b ? 1 : 0; }
  unsigned int operator()(unsigned int i) const { return i; }
};

class TestDummy : public testing::Test {
public:
  enum struct AssemblyHolderType : int { FILE_TYPE, STRING_TYPE };

  TestDummy() : m_Module{nullptr}, m_TestDataDir{"./unittests/data/"} {}

  void ParseAssembly(
      const char *AssemblyHolder,
      const AssemblyHolderType asmHolder = AssemblyHolderType::FILE_TYPE) {
    llvm::SMDiagnostic err;

    auto &ctx = llvm::getGlobalContext();

    if (AssemblyHolderType::FILE_TYPE == asmHolder) {
      std::string fullFilename{m_TestDataDir};
      fullFilename += AssemblyHolder;

      m_Module = llvm::parseAssemblyFile(fullFilename, err, ctx);

    } else {
      m_Module = llvm::parseAssemblyString(AssemblyHolder, err, ctx);
    }

    std::string errMsg;
    llvm::raw_string_ostream os(errMsg);
    err.print("", os);

    if (llvm::verifyModule(*m_Module, &(llvm::errs())))
      llvm::report_fatal_error("module verification failed\n");

    if (!m_Module)
      llvm::report_fatal_error(os.str().c_str());

    return;
  }

  void ExpectTestPass(const test_result_map &trm) {
    static char ID;

    struct UtilityPass : public llvm::FunctionPass {
      UtilityPass(const test_result_map &trm)
          : llvm::FunctionPass(ID), m_trm(trm) {}

      static int initialize() {
        auto *registry = llvm::PassRegistry::getPassRegistry();

        auto *PI = new llvm::PassInfo("Utility pass for unit tests", "", &ID,
                                      nullptr, true, true);

        registry->registerPass(*PI, false);
        llvm::initializeLoopInfoWrapperPassPass(*registry);

        return 0;
      }

      void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {
        AU.setPreservesAll();
        AU.addRequiredTransitive<llvm::LoopInfoWrapperPass>();

        return;
      }

      bool runOnFunction(llvm::Function &F) override {
        if (!F.hasName() || !F.getName().startswith("test"))
          return false;

        auto &LI = getAnalysis<llvm::LoopInfoWrapperPass>().getLoopInfo();
        // LI.print(llvm::outs());

        auto *CurLoop = *LI.begin();
        assert(CurLoop && "Loop ptr is invalid");

        test_result_map::const_iterator found;

        // subcase
        found = lookup("number of foos");
        if (std::end(m_trm) != found) {
          const auto &rv = 0;
          const auto &ev =
              boost::apply_visitor(test_result_visitor(), found->second);
          EXPECT_EQ(ev, rv) << found->first;
        }

        return false;
      }

      test_result_map::const_iterator lookup(const std::string &subcase,
                                             bool fatalIfMissing = false) {
        auto found = m_trm.find(subcase);
        if (fatalIfMissing && m_trm.end() == found) {
          llvm::errs() << "subcase: " << subcase << " test data not found\n";
          std::abort();
        }

        return found;
      }

      const test_result_map &m_trm;
    };

    static int init = UtilityPass::initialize();
    (void)init; // do not optimize away

    auto *P = new UtilityPass(trm);
    llvm::legacy::PassManager PM;

    PM.add(P);
    PM.run(*m_Module);

    return;
  }

protected:
  std::unique_ptr<llvm::Module> m_Module;
  const char *m_TestDataDir;
};

TEST_F(TestDummy, NumberOfFoos) {
  ParseAssembly("test01.ll");

  test_result_map trm;

  trm.insert({"number of foos", 0u});
  ExpectTestPass(trm);
}

} // namespace anonymous end
} // namespace icsa end
<commit_msg>add conditional compilation for backwards compatibility<commit_after>
#include <memory>
// using std::unique_ptr

#include <map>
// using std::map

#include <cassert>
// using assert

#include <cstdlib>
// using std::abort

#include "llvm/Config/llvm-config.h"

#include "llvm/IR/LLVMContext.h"
// using llvm::LLVMContext

#include "llvm/IR/Module.h"
// using llvm::Module

#include "llvm/IR/LegacyPassManager.h"
// using llvm::legacy::PassMananger

#include "llvm/Pass.h"
// using llvm::Pass
// using llvm::PassInfo

#include "llvm/Analysis/LoopInfo.h"
// using llvm::LoopInfoWrapperPass
// using llvm::LoopInfo

#include "llvm/Support/SourceMgr.h"
// using llvm::SMDiagnostic

#include "llvm/AsmParser/Parser.h"
// using llvm::parseAssemblyString

#include "llvm/IR/Verifier.h"
// using llvm::verifyModule

#include "llvm/Support/ErrorHandling.h"
// using llvm::report_fatal_error

#include "llvm/Support/raw_ostream.h"
// using llvm::raw_string_ostream

#include "gtest/gtest.h"
// using testing::Test

#include "boost/variant.hpp"
// using boost::variant

#include "SkeletonOptPass.hpp"

namespace icsa {
namespace {

using test_result_t = boost::variant<bool, unsigned int>;
using test_result_map = std::map<std::string, test_result_t>;

struct test_result_visitor : public boost::static_visitor<unsigned int> {
  unsigned int operator()(bool b) const { return b ? 1 : 0; }
  unsigned int operator()(unsigned int i) const { return i; }
};

class TestDummy : public testing::Test {
public:
  enum struct AssemblyHolderType : int { FILE_TYPE, STRING_TYPE };

  TestDummy() : m_Module{nullptr}, m_TestDataDir{"./unittests/data/"} {}

  void ParseAssembly(
      const char *AssemblyHolder,
      const AssemblyHolderType asmHolder = AssemblyHolderType::FILE_TYPE) {
    llvm::SMDiagnostic err;

#if (LLVM_VERSION_MAJOR >= 4) ||                                               \
    (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
    static llvm::LLVMContext theContext;
    auto &ctx = theContext;
#else
    auto &ctx = llvm::getGlobalContext();
#endif

    if (AssemblyHolderType::FILE_TYPE == asmHolder) {
      std::string fullFilename{m_TestDataDir};
      fullFilename += AssemblyHolder;

      m_Module = llvm::parseAssemblyFile(fullFilename, err, ctx);

    } else {
      m_Module = llvm::parseAssemblyString(AssemblyHolder, err, ctx);
    }

    std::string errMsg;
    llvm::raw_string_ostream os(errMsg);
    err.print("", os);

    if (llvm::verifyModule(*m_Module, &(llvm::errs())))
      llvm::report_fatal_error("module verification failed\n");

    if (!m_Module)
      llvm::report_fatal_error(os.str().c_str());

    return;
  }

  void ExpectTestPass(const test_result_map &trm) {
    static char ID;

    struct UtilityPass : public llvm::FunctionPass {
      UtilityPass(const test_result_map &trm)
          : llvm::FunctionPass(ID), m_trm(trm) {}

      static int initialize() {
        auto *registry = llvm::PassRegistry::getPassRegistry();

        auto *PI = new llvm::PassInfo("Utility pass for unit tests", "", &ID,
                                      nullptr, true, true);

        registry->registerPass(*PI, false);
        llvm::initializeLoopInfoWrapperPassPass(*registry);

        return 0;
      }

      void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {
        AU.setPreservesAll();
        AU.addRequiredTransitive<llvm::LoopInfoWrapperPass>();

        return;
      }

      bool runOnFunction(llvm::Function &F) override {
        if (!F.hasName() || !F.getName().startswith("test"))
          return false;

        auto &LI = getAnalysis<llvm::LoopInfoWrapperPass>().getLoopInfo();
        // LI.print(llvm::outs());

        auto *CurLoop = *LI.begin();
        assert(CurLoop && "Loop ptr is invalid");

        test_result_map::const_iterator found;

        // subcase
        found = lookup("number of foos");
        if (std::end(m_trm) != found) {
          const auto &rv = 0;
          const auto &ev =
              boost::apply_visitor(test_result_visitor(), found->second);
          EXPECT_EQ(ev, rv) << found->first;
        }

        return false;
      }

      test_result_map::const_iterator lookup(const std::string &subcase,
                                             bool fatalIfMissing = false) {
        auto found = m_trm.find(subcase);
        if (fatalIfMissing && m_trm.end() == found) {
          llvm::errs() << "subcase: " << subcase << " test data not found\n";
          std::abort();
        }

        return found;
      }

      const test_result_map &m_trm;
    };

    static int init = UtilityPass::initialize();
    (void)init; // do not optimize away

    auto *P = new UtilityPass(trm);
    llvm::legacy::PassManager PM;

    PM.add(P);
    PM.run(*m_Module);

    return;
  }

protected:
  std::unique_ptr<llvm::Module> m_Module;
  const char *m_TestDataDir;
};

TEST_F(TestDummy, NumberOfFoos) {
  ParseAssembly("test01.ll");

  test_result_map trm;

  trm.insert({"number of foos", 0u});
  ExpectTestPass(trm);
}

} // namespace anonymous end
} // namespace icsa end
<|endoftext|>


<commit_before>#include "drake/systems/LCMSystem.h"
#include "drake/systems/plants/RigidBodySystem.h"
#include "drake/systems/plants/BotVisualizer.h"
#include "drake/systems/cascade_system.h"
#include "drake/util/drakeAppUtil.h"

using namespace std;
using namespace Eigen;
using namespace Drake;

/** @page rigidBodyLCMNode rigidBodyLCMNode Application
 * @ingroup simulation
 * @brief Loads a urdf/sdf and simulates it, subscribing to LCM inputs and
publishing LCM outputs
 *
 * This application loads a robot from urdf or sdf and runs a simulation, with
every input
 * with an LCM type defined subscribed to the associated LCM channels, and every
 * output with an LCM type defined publishing on the associate channels.  See
@ref lcm_vector_concept.
 *
 *
@verbatim
Usage:  rigidBodyLCMNode [options] full_path_to_urdf_or_sdf_file
  with (case sensitive) options:
    --base [floating_type]  // can be "FIXED, ROLLPITCHYAW, or QUATERNION"
(default: QUATERNION)
@endverbatim
 */

int main(int argc, char* argv[]) {
  if (argc < 2) {
    std::cerr << "Usage: " << argv[0]
              << " [options] full_path_to_urdf_or_sdf_file" << std::endl;
    return 1;
  }

  // todo: consider moving this logic into the RigidBodySystem class so it can
  // be reused
  DrakeJoint::FloatingBaseType floating_base_type = DrakeJoint::QUATERNION;
  char* floating_base_option =
      getCommandLineOption(argv, argc + argv, "--base");
  if (floating_base_option) {
    if (strcmp(floating_base_option, "FIXED") == 0) {
      floating_base_type = DrakeJoint::FIXED;
    } else if (strcmp(floating_base_option, "RPY") == 0) {
      floating_base_type = DrakeJoint::ROLLPITCHYAW;
    } else if (strcmp(floating_base_option, "QUAT") == 0) {
      floating_base_type = DrakeJoint::QUATERNION;
    } else {
      throw std::runtime_error(string("Unknown base type") +
                               floating_base_option +
                               "; must be FIXED, RPY, or QUAT");
    }
  }

  auto rigid_body_sys = make_shared<RigidBodySystem>();
  rigid_body_sys->addRobotFromFile(argv[argc-1], floating_base_type);
  auto const & tree = rigid_body_sys->getRigidBodyTree();

  if (commandLineOptionExists(argv, argc + argv, "--add_flat_terrain")) {
    double box_width = 1000;
    double box_depth = 10;
    DrakeShapes::Box geom(Vector3d(box_width, box_width, box_depth));
    Isometry3d T_element_to_link = Isometry3d::Identity();
    T_element_to_link.translation() << 0, 0,
        -box_depth / 2;  // top of the box is at z=0
    auto& world = tree->bodies[0];
    Vector4d color;
    color << 0.9297, 0.7930, 0.6758,
        1;  // was hex2dec({'ee','cb','ad'})'/256 in matlab
    world->addVisualElement(
        DrakeShapes::VisualElement(geom, T_element_to_link, color));
    tree->addCollisionElement(
        RigidBody::CollisionElement(geom, T_element_to_link, world), *world,
        "terrain");
    tree->updateStaticCollisionElements();
  }

  shared_ptr<lcm::LCM> lcm = make_shared<lcm::LCM>();
  auto visualizer =
      make_shared<BotVisualizer<RigidBodySystem::StateVector>>(lcm, tree);
  auto sys = cascade(rigid_body_sys, visualizer);

  SimulationOptions options = default_simulation_options;
  options.realtime_factor = 1.0;
  options.timeout_seconds = std::numeric_limits<double>::infinity();
  options.initial_step_size = 5e-3;

  runLCM(sys, lcm, 0, std::numeric_limits<double>::infinity(),
         getInitialState(*sys), options);
  //  simulate(*sys, 0, std::numeric_limits<double>::max(), getInitialState(*sys), options);

  return 0;
}
<commit_msg>Updated systems/plants/rigidBodyLCMNode.cpp to use new API<commit_after>#include "drake/systems/LCMSystem.h"
#include "drake/systems/plants/RigidBodySystem.h"
#include "drake/systems/plants/BotVisualizer.h"
#include "drake/systems/cascade_system.h"
#include "drake/util/drakeAppUtil.h"

using namespace std;
using namespace Eigen;
using namespace Drake;

/** @page rigidBodyLCMNode rigidBodyLCMNode Application
 * @ingroup simulation
 * @brief Loads a urdf/sdf and simulates it, subscribing to LCM inputs and
publishing LCM outputs
 *
 * This application loads a robot from urdf or sdf and runs a simulation, with
every input
 * with an LCM type defined subscribed to the associated LCM channels, and every
 * output with an LCM type defined publishing on the associate channels.  See
@ref lcm_vector_concept.
 *
 *
@verbatim
Usage:  rigidBodyLCMNode [options] full_path_to_urdf_or_sdf_file
  with (case sensitive) options:
    --base [floating_type]  // can be "FIXED, ROLLPITCHYAW, or QUATERNION"
(default: QUATERNION)
@endverbatim
 */

int main(int argc, char* argv[]) {
  if (argc < 2) {
    std::cerr << "Usage: " << argv[0]
              << " [options] full_path_to_urdf_or_sdf_file" << std::endl;
    return 1;
  }

  // todo: consider moving this logic into the RigidBodySystem class so it can
  // be reused
  DrakeJoint::FloatingBaseType floating_base_type = DrakeJoint::QUATERNION;
  char* floating_base_option =
      getCommandLineOption(argv, argc + argv, "--base");
  if (floating_base_option) {
    if (strcmp(floating_base_option, "FIXED") == 0) {
      floating_base_type = DrakeJoint::FIXED;
    } else if (strcmp(floating_base_option, "RPY") == 0) {
      floating_base_type = DrakeJoint::ROLLPITCHYAW;
    } else if (strcmp(floating_base_option, "QUAT") == 0) {
      floating_base_type = DrakeJoint::QUATERNION;
    } else {
      throw std::runtime_error(string("Unknown base type") +
                               floating_base_option +
                               "; must be FIXED, RPY, or QUAT");
    }
  }

  auto rigid_body_sys = make_shared<RigidBodySystem>();
  rigid_body_sys->addRobotFromFile(argv[argc-1], floating_base_type);
  auto const & tree = rigid_body_sys->getRigidBodyTree();

  if (commandLineOptionExists(argv, argc + argv, "--add_flat_terrain")) {
    double box_width = 1000;
    double box_depth = 10;
    DrakeShapes::Box geom(Vector3d(box_width, box_width, box_depth));
    Isometry3d T_element_to_link = Isometry3d::Identity();
    T_element_to_link.translation() << 0, 0,
        -box_depth / 2;  // top of the box is at z=0
    RigidBody& world = tree->body(0);
    Vector4d color;
    color << 0.9297, 0.7930, 0.6758,
        1;  // was hex2dec({'ee','cb','ad'})'/256 in matlab
    world.addVisualElement(
        DrakeShapes::VisualElement(geom, T_element_to_link, color));
    tree->addCollisionElement(
        RigidBody::CollisionElement(geom, T_element_to_link, world), world,
        "terrain");
    tree->updateStaticCollisionElements();
  }

  shared_ptr<lcm::LCM> lcm = make_shared<lcm::LCM>();
  auto visualizer =
      make_shared<BotVisualizer<RigidBodySystem::StateVector>>(lcm, tree);
  auto sys = cascade(rigid_body_sys, visualizer);

  SimulationOptions options = default_simulation_options;
  options.realtime_factor = 1.0;
  options.timeout_seconds = std::numeric_limits<double>::infinity();
  options.initial_step_size = 5e-3;

  runLCM(sys, lcm, 0, std::numeric_limits<double>::infinity(),
         getInitialState(*sys), options);
  //  simulate(*sys, 0, std::numeric_limits<double>::max(), getInitialState(*sys), options);

  return 0;
}
<|endoftext|>


<commit_before>// This file is part of the dune-gdt project:
//   https://github.com/dune-community/dune-gdt
// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved.
// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
//      or  GPL-2.0+ (http://opensource.org/licenses/gpl-license)
//          with "runtime exception" (http://www.dune-project.org/license.html)
// Authors:
//   Felix Schindler (2018)

#ifndef DUNE_GDT_LOCAL_FINITE_ELEMENTS_DEFAULT_HH
#define DUNE_GDT_LOCAL_FINITE_ELEMENTS_DEFAULT_HH

#include <dune/xt/common/memory.hh>

#include "interfaces.hh"

namespace Dune {
namespace GDT {

/**
 * \brief Implements LocalFiniteElementInterface, given a basis, coefficients and an interpolation.
 */
template <class D, size_t d, class R, size_t r, size_t rC = 1>
class LocalFiniteElementDefault : public LocalFiniteElementInterface<D, d, R, r, rC>
{
  using ThisType = LocalFiniteElementDefault<D, d, R, r, rC>;
  using BaseType = LocalFiniteElementInterface<D, d, R, r, rC>;

public:
  using typename BaseType::DomainType;
  using typename BaseType::BasisType;
  using typename BaseType::CoefficientsType;
  using typename BaseType::InterpolationType;

  LocalFiniteElementDefault(const int ord,
                            const BasisType& bas,
                            const CoefficientsType& coeffs,
                            const InterpolationType& inter,
                            std::vector<DomainType> lps = {})
    : geometry_type_(bas.geometry_type())
    , order_(ord)
    , basis_(bas)
    , coefficients_(coeffs)
    , interpolation_(inter)
    , lagrange_points_(lps)
  {
    DUNE_THROW_IF(coeffs.geometry_type() != geometry_type_, Exceptions::finite_element_error, "");
    DUNE_THROW_IF(coeffs.size() != bas.size(), Exceptions::finite_element_error, "");
    DUNE_THROW_IF(inter.geometry_type() != geometry_type_, Exceptions::finite_element_error, "");
    DUNE_THROW_IF(inter.size() != bas.size(), Exceptions::finite_element_error, "");
    DUNE_THROW_IF(!(lps.size() == bas.size() || lps.size() == 0), Exceptions::finite_element_error, "");
  }

  /**
    * \attention Do not delete any of the moved in raw pointers manually afterwads!
    **/
  LocalFiniteElementDefault(const int ord,
                            BasisType*&& bas_ptr,
                            CoefficientsType*&& coeffs_ptr,
                            InterpolationType*&& inter_ptr,
                            std::vector<DomainType> lps = {})
    : geometry_type_(bas_ptr->geometry_type())
    , order_(ord)
    , basis_(std::move(bas_ptr))
    , coefficients_(std::move(coeffs_ptr))
    , interpolation_(std::move(inter_ptr))
    , lagrange_points_(lps)
  {
    DUNE_THROW_IF(coeffs_ptr->geometry_type() != geometry_type_, Exceptions::finite_element_error, "");
    DUNE_THROW_IF(coeffs_ptr->size() != bas_ptr->size(), Exceptions::finite_element_error, "");
    DUNE_THROW_IF(inter_ptr->geometry_type() != geometry_type_, Exceptions::finite_element_error, "");
    DUNE_THROW_IF(inter_ptr->size() != bas_ptr->size(), Exceptions::finite_element_error, "");
    DUNE_THROW_IF(!(lps.size() == bas_ptr->size() || lps.size() == 0), Exceptions::finite_element_error, "");
  }

  const GeometryType& geometry_type() const override
  {
    return geometry_type_;
  }

  int order() const override
  {
    return order_;
  }

  size_t size() const override
  {
    return basis_.access().size();
  }

  const BasisType& basis() const override
  {
    return basis_.access();
  }

  const CoefficientsType& coefficients() const override
  {
    return coefficients_.access();
  }

  const InterpolationType& interpolation() const override
  {
    return interpolation_.access();
  }

  bool is_lagrangian() const override
  {
    return lagrange_points_.size() > 0;
  }

  const std::vector<DomainType>& lagrange_points() const override
  {
    if (!is_lagrangian())
      DUNE_THROW(Exceptions::finite_element_error, "do not call lagrange_points() if is_lagrangian() is false!");
    return lagrange_points_;
  }

private:
  const GeometryType geometry_type_;
  const int order_;
  const XT::Common::ConstStorageProvider<BasisType> basis_;
  const XT::Common::ConstStorageProvider<CoefficientsType> coefficients_;
  const XT::Common::ConstStorageProvider<InterpolationType> interpolation_;
  const std::vector<DomainType> lagrange_points_;
}; // class LocalFiniteElementDefault

} // namespace GDT
} // namespace Dune

#endif // DUNE_GDT_LOCAL_FINITE_ELEMENTS_DEFAULT_HH
<commit_msg>[local.finite-elements.default] improve error message<commit_after>// This file is part of the dune-gdt project:
//   https://github.com/dune-community/dune-gdt
// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved.
// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
//      or  GPL-2.0+ (http://opensource.org/licenses/gpl-license)
//          with "runtime exception" (http://www.dune-project.org/license.html)
// Authors:
//   Felix Schindler (2018)

#ifndef DUNE_GDT_LOCAL_FINITE_ELEMENTS_DEFAULT_HH
#define DUNE_GDT_LOCAL_FINITE_ELEMENTS_DEFAULT_HH

#include <dune/xt/common/memory.hh>

#include "interfaces.hh"

namespace Dune {
namespace GDT {

/**
 * \brief Implements LocalFiniteElementInterface, given a basis, coefficients and an interpolation.
 */
template <class D, size_t d, class R, size_t r, size_t rC = 1>
class LocalFiniteElementDefault : public LocalFiniteElementInterface<D, d, R, r, rC>
{
  using ThisType = LocalFiniteElementDefault<D, d, R, r, rC>;
  using BaseType = LocalFiniteElementInterface<D, d, R, r, rC>;

public:
  using typename BaseType::DomainType;
  using typename BaseType::BasisType;
  using typename BaseType::CoefficientsType;
  using typename BaseType::InterpolationType;

  LocalFiniteElementDefault(const int ord,
                            const BasisType& bas,
                            const CoefficientsType& coeffs,
                            const InterpolationType& inter,
                            std::vector<DomainType> lps = {})
    : geometry_type_(bas.geometry_type())
    , order_(ord)
    , basis_(bas)
    , coefficients_(coeffs)
    , interpolation_(inter)
    , lagrange_points_(lps)
  {
    check_input();
  }

  /**
    * \attention Do not delete any of the moved in raw pointers manually afterwads!
    **/
  LocalFiniteElementDefault(const int ord,
                            BasisType*&& bas_ptr,
                            CoefficientsType*&& coeffs_ptr,
                            InterpolationType*&& inter_ptr,
                            std::vector<DomainType> lps = {})
    : geometry_type_(bas_ptr->geometry_type())
    , order_(ord)
    , basis_(std::move(bas_ptr))
    , coefficients_(std::move(coeffs_ptr))
    , interpolation_(std::move(inter_ptr))
    , lagrange_points_(lps)
  {
    check_input();
  }

  const GeometryType& geometry_type() const override
  {
    return geometry_type_;
  }

  int order() const override
  {
    return order_;
  }

  size_t size() const override
  {
    return basis_.access().size();
  }

  const BasisType& basis() const override
  {
    return basis_.access();
  }

  const CoefficientsType& coefficients() const override
  {
    return coefficients_.access();
  }

  const InterpolationType& interpolation() const override
  {
    return interpolation_.access();
  }

  bool is_lagrangian() const override
  {
    return lagrange_points_.size() > 0;
  }

  const std::vector<DomainType>& lagrange_points() const override
  {
    if (!is_lagrangian())
      DUNE_THROW(Exceptions::finite_element_error, "do not call lagrange_points() if is_lagrangian() is false!");
    return lagrange_points_;
  }

private:
  void check_input()
  {
    DUNE_THROW_IF(coefficients_.access().geometry_type() != geometry_type_,
                  Exceptions::finite_element_error,
                  "\n   coefficients_.access().geometry_type() = " << coefficients_.access().geometry_type()
                                                                   << "\n   geometry_type_ = "
                                                                   << geometry_type_);
    DUNE_THROW_IF(coefficients_.access().size() != basis_.access().size(),
                  Exceptions::finite_element_error,
                  "\n   coefficients_.access().size() = " << coefficients_.access().size()
                                                          << "\n   basis_.access().size() = "
                                                          << basis_.access().size());
    DUNE_THROW_IF(interpolation_.access().geometry_type() != geometry_type_,
                  Exceptions::finite_element_error,
                  "\n   interpolation_.access().geometry_type() = " << interpolation_.access().geometry_type()
                                                                    << "\n   "
                                                                    << geometry_type_);
    DUNE_THROW_IF(interpolation_.access().size() != basis_.access().size(),
                  Exceptions::finite_element_error,
                  "\n   interpolation_.access().size() = " << interpolation_.access().size()
                                                           << "\n   basis_.access().size() = "
                                                           << basis_.access().size());
    DUNE_THROW_IF(!(lagrange_points_.size() == basis_.access().size() || lagrange_points_.size() == 0),
                  Exceptions::finite_element_error,
                  "\n   lagrange_points_.size() = " << lagrange_points_.size() << "\n   basis_.access().size() = "
                                                    << basis_.access().size());
  } // ... check_input(...)

  const GeometryType geometry_type_;
  const int order_;
  const XT::Common::ConstStorageProvider<BasisType> basis_;
  const XT::Common::ConstStorageProvider<CoefficientsType> coefficients_;
  const XT::Common::ConstStorageProvider<InterpolationType> interpolation_;
  const std::vector<DomainType> lagrange_points_;
}; // class LocalFiniteElementDefault

} // namespace GDT
} // namespace Dune

#endif // DUNE_GDT_LOCAL_FINITE_ELEMENTS_DEFAULT_HH
<|endoftext|>