<commit_before>// This macro plays a recorded ROOT session showing how to perform various
// interactive graphical editing operations. The initial graphics setup
// was created using the following root commands:
/*
     t = new TRecorder();
     t->Start("graphedit_playback.root");
     gStyle->SetPalette(1);
     TCanvas *c2 = new TCanvas("c2","c2",0,0,700,500);
     TH2F* h2 = new TH2F("h2","Random 2D Gaussian",40,-4,4,40,-4,4);
     h2->SetDirectory(0);
     TRandom r;
     for (int i=0;i<50000;i++) h2->Fill(r.Gaus(),r.Gaus());
     h2->Draw();
     gPad->Update();
     TCanvas *c1 = new TCanvas("c1","c1",0,0,700,500);
     TH1F* h1 = new TH1F("h1","Random 1D Gaussian",100,-4,4);
     h1->SetDirectory(0);
     h1->FillRandom("gaus",10000);
     h1->Draw();
     gPad->Update();

     // Here the following "sketch" was done.

     t->Stop();
*/
// Note: The previous commands should be copy/pasted into a ROOT session, not
// executed as a macro.
//
// The interactive editing shows:
//     - Object editing using object editors
//     - Direct editing on the graphics canvas
//     - Saving PS and bitmap files.
//     - Saving as a .C file: C++ code corresponding to the modifications
//       is saved.
//
// The sketch of the recorded actions is:
//
//    On the canvas c1:
//       Open View/Editor
//       Select histogram
//       Change fill style
//       Change fill color
//       Move stat box
//       Change fill color
//       Move title
//       Change fill color using wheel color
//       Select Y axis
//       Change axis title
//       Select X axis
//       Change axis title
//       Select histogram
//       Go in binning
//       Change range
//       Move range
//       On the canvas menu set grid Y
//       On the canvas menu set grid X
//       On the canvas menu set log Y
//       Increase the range
//       Close View/Editor
//       Open the Tool Bar
//       Create a text "Comment"
//       Create an arrow
//       Change the arrow size
//       Close the Tool Bar
//       Save as PS file
//       Save as C file
//       Close c1
//    On the canvas c2:
//       Open View/Editor
//       Select histogram
//       Select COL
//       Select Palette
//       Move Stats
//       Select Overflows
//       Select histogram
//       Select 3D
//       Select SURF1
//       Rotate Surface
//       Go in binning
//       Change X range
//       Change Y range
//       Close View/Editor
//       Save as GIF file
//       Save as C file
//       Close c2

Int_t file_size(char *filename)
{
   FileStat_t fs;
   gSystem->GetPathInfo(filename, fs);
   return (Int_t)fs.fSize;
}

void graph_edit_playback()
{
   r = new TRecorder();
   r->Replay("http://root.cern.ch/files/graphedit_playback.root",kFALSE);

   // wait for the recorder to finish the replay
   while (r->GetState() == TRecorder::kReplaying) {
      gSystem->ProcessEvents();
      gSystem->Sleep(1);
   }

   Int_t c1_ps_Ref  = 11592 , c1_ps_Err  = 500;
   Int_t c1_C_Ref   =  4729 , c1_C_Err   = 100;
   Int_t c2_gif_Ref = 21184 , c2_gif_Err = 100;
   Int_t c2_C_Ref   = 35471 , c2_C_Err   = 100;

   Int_t c1_ps  = file_size("c1.ps");
   Int_t c1_C   = file_size("c1.C");
   Int_t c2_gif = file_size("c2.gif");
   Int_t c2_C   = file_size("c2.C");

   cout << "**********************************************************************" <<endl;
   cout << "*  Report of graph_edit_playback.C                                   *" <<endl;
   cout << "**********************************************************************" <<endl;

   if (TMath::Abs(c1_ps_Ref-c1_ps) <= c1_ps_Err) {
      cout << "Canvas c1: PS output............................................... OK" <<endl;
   } else {
      cout << "Canvas c1: PS output........................................... FAILED" <<endl;
   }
   if (TMath::Abs(c1_C_Ref-c1_C) <= c1_C_Err) {
      cout << "           C output................................................ OK" <<endl;
   } else {
      cout << "           C output............................................ FAILED" <<endl;
   }
   if (TMath::Abs(c2_gif_Ref-c2_gif) <= c2_gif_Err) {
      cout << "Canvas c2: GIF output.............................................. OK" <<endl;
   } else {
      cout << "Canvas c2: GIF output.......................................... FAILED" <<endl;
   }
   if (TMath::Abs(c2_C_Ref-c2_C) <= c2_C_Err) {
      cout << "           C output................................................ OK" <<endl;
   } else {
      cout << "           C output............................................ FAILED" <<endl;
   }
   cout << "**********************************************************************" <<endl;

}
<commit_msg>- Do the replay with the cursor "ON".<commit_after>// This macro plays a recorded ROOT session showing how to perform various
// interactive graphical editing operations. The initial graphics setup
// was created using the following root commands:
/*
     t = new TRecorder();
     t->Start("graphedit_playback.root");
     gStyle->SetPalette(1);
     TCanvas *c2 = new TCanvas("c2","c2",0,0,700,500);
     TH2F* h2 = new TH2F("h2","Random 2D Gaussian",40,-4,4,40,-4,4);
     h2->SetDirectory(0);
     TRandom r;
     for (int i=0;i<50000;i++) h2->Fill(r.Gaus(),r.Gaus());
     h2->Draw();
     gPad->Update();
     TCanvas *c1 = new TCanvas("c1","c1",0,0,700,500);
     TH1F* h1 = new TH1F("h1","Random 1D Gaussian",100,-4,4);
     h1->SetDirectory(0);
     h1->FillRandom("gaus",10000);
     h1->Draw();
     gPad->Update();

     // Here the following "sketch" was done.

     t->Stop();
*/
// Note: The previous commands should be copy/pasted into a ROOT session, not
// executed as a macro.
//
// The interactive editing shows:
//     - Object editing using object editors
//     - Direct editing on the graphics canvas
//     - Saving PS and bitmap files.
//     - Saving as a .C file: C++ code corresponding to the modifications
//       is saved.
//
// The sketch of the recorded actions is:
//
//    On the canvas c1:
//       Open View/Editor
//       Select histogram
//       Change fill style
//       Change fill color
//       Move stat box
//       Change fill color
//       Move title
//       Change fill color using wheel color
//       Select Y axis
//       Change axis title
//       Select X axis
//       Change axis title
//       Select histogram
//       Go in binning
//       Change range
//       Move range
//       On the canvas menu set grid Y
//       On the canvas menu set grid X
//       On the canvas menu set log Y
//       Increase the range
//       Close View/Editor
//       Open the Tool Bar
//       Create a text "Comment"
//       Create an arrow
//       Change the arrow size
//       Close the Tool Bar
//       Save as PS file
//       Save as C file
//       Close c1
//    On the canvas c2:
//       Open View/Editor
//       Select histogram
//       Select COL
//       Select Palette
//       Move Stats
//       Select Overflows
//       Select histogram
//       Select 3D
//       Select SURF1
//       Rotate Surface
//       Go in binning
//       Change X range
//       Change Y range
//       Close View/Editor
//       Save as GIF file
//       Save as C file
//       Close c2

Int_t file_size(char *filename)
{
   FileStat_t fs;
   gSystem->GetPathInfo(filename, fs);
   return (Int_t)fs.fSize;
}

void graph_edit_playback()
{
   r = new TRecorder();
   r->Replay("http://root.cern.ch/files/graphedit_playback.root");

   // wait for the recorder to finish the replay
   while (r->GetState() == TRecorder::kReplaying) {
      gSystem->ProcessEvents();
      gSystem->Sleep(1);
   }

   Int_t c1_ps_Ref  = 11592 , c1_ps_Err  = 500;
   Int_t c1_C_Ref   =  4729 , c1_C_Err   = 100;
   Int_t c2_gif_Ref = 21184 , c2_gif_Err = 100;
   Int_t c2_C_Ref   = 35471 , c2_C_Err   = 100;

   Int_t c1_ps  = file_size("c1.ps");
   Int_t c1_C   = file_size("c1.C");
   Int_t c2_gif = file_size("c2.gif");
   Int_t c2_C   = file_size("c2.C");

   cout << "**********************************************************************" <<endl;
   cout << "*  Report of graph_edit_playback.C                                   *" <<endl;
   cout << "**********************************************************************" <<endl;

   if (TMath::Abs(c1_ps_Ref-c1_ps) <= c1_ps_Err) {
      cout << "Canvas c1: PS output............................................... OK" <<endl;
   } else {
      cout << "Canvas c1: PS output........................................... FAILED" <<endl;
   }
   if (TMath::Abs(c1_C_Ref-c1_C) <= c1_C_Err) {
      cout << "           C output................................................ OK" <<endl;
   } else {
      cout << "           C output............................................ FAILED" <<endl;
   }
   if (TMath::Abs(c2_gif_Ref-c2_gif) <= c2_gif_Err) {
      cout << "Canvas c2: GIF output.............................................. OK" <<endl;
   } else {
      cout << "Canvas c2: GIF output.......................................... FAILED" <<endl;
   }
   if (TMath::Abs(c2_C_Ref-c2_C) <= c2_C_Err) {
      cout << "           C output................................................ OK" <<endl;
   } else {
      cout << "           C output............................................ FAILED" <<endl;
   }
   cout << "**********************************************************************" <<endl;

}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: webdavprovider.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: kso $ $Date: 2001-11-26 09:45:37 $
 *
 *  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 _WEBDAV_UCP_PROVIDER_HXX
#define _WEBDAV_UCP_PROVIDER_HXX

#include <hash_set>

#ifndef _RTL_REF_HXX_
#include <rtl/ref.hxx>
#endif

#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
#include <com/sun/star/beans/Property.hpp>
#endif

#ifndef _DAVSESSIONFACTORY_HXX_
#include "DAVSessionFactory.hxx"
#endif

#ifndef _UCBHELPER_PROVIDERHELPER_HXX
#include <ucbhelper/providerhelper.hxx>
#endif

#ifndef _WEBDAV_UCP_PROPERTYMAP_HXX
#include "PropertyMap.hxx"
#endif

namespace webdav_ucp {

//=========================================================================

// UNO service name for the provider. This name will be used by the UCB to
// create instances of the provider.
#define WEBDAV_CONTENT_PROVIDER_SERVICE_NAME \
                "com.sun.star.ucb.WebDAVContentProvider"
#define WEBDAV_CONTENT_PROVIDER_SERVICE_NAME_LENGTH 38

// URL scheme. This is the scheme the provider will be able to create
// contents for. The UCB will select the provider ( i.e. in order to create
// contents ) according to this scheme.
#define WEBDAV_URL_SCHEME \
                "vnd.sun.star.webdav"
#define WEBDAV_URL_SCHEME_LENGTH    19

#define HTTP_URL_SCHEME         "http"
#define HTTP_URL_SCHEME_LENGTH  4

#define HTTPS_URL_SCHEME        "https"
#define HTTPS_URL_SCHEME_LENGTH 5

#define FTP_URL_SCHEME "ftp"

#define HTTP_CONTENT_TYPE \
                "application/" HTTP_URL_SCHEME "-content"

#define WEBDAV_CONTENT_TYPE    HTTP_CONTENT_TYPE
#define WEBDAV_COLLECTION_TYPE \
                "application/" WEBDAV_URL_SCHEME "-collection"

//=========================================================================

class ContentProvider : public ::ucb::ContentProviderImplHelper
{
    rtl::Reference< DAVSessionFactory > m_xDAVSessionFactory;
    PropertyMap * m_pProps;

public:
    ContentProvider( const ::com::sun::star::uno::Reference<
                        ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
    virtual ~ContentProvider();

    // XInterface
    XINTERFACE_DECL()

    // XTypeProvider
    XTYPEPROVIDER_DECL()

    // XServiceInfo
    XSERVICEINFO_DECL()

    // XContentProvider
    virtual ::com::sun::star::uno::Reference<
                ::com::sun::star::ucb::XContent > SAL_CALL
    queryContent( const ::com::sun::star::uno::Reference<
                    ::com::sun::star::ucb::XContentIdentifier >& Identifier )
        throw( ::com::sun::star::ucb::IllegalIdentifierException,
               ::com::sun::star::uno::RuntimeException );

    //////////////////////////////////////////////////////////////////////
    // Additional interfaces
    //////////////////////////////////////////////////////////////////////

    //////////////////////////////////////////////////////////////////////
    // Non-interface methods.
    //////////////////////////////////////////////////////////////////////

    rtl::Reference< DAVSessionFactory > getDAVSessionFactory()
    { return m_xDAVSessionFactory; }

    bool getProperty( const ::rtl::OUString & rPropName,
                      ::com::sun::star::beans::Property & rProp,
                      bool bStrict = false );
};

}

#endif
<commit_msg>INTEGRATION: CWS ooo20040704 (1.6.180); FILE MERGED 2004/06/28 14:35:47 cmc 1.6.180.1: #i30801# allow using system libs if possible<commit_after>/*************************************************************************
 *
 *  $RCSfile: webdavprovider.hxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: rt $ $Date: 2004-09-08 17:07:13 $
 *
 *  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 _WEBDAV_UCP_PROVIDER_HXX
#define _WEBDAV_UCP_PROVIDER_HXX

#ifndef _RTL_REF_HXX_
#include <rtl/ref.hxx>
#endif

#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
#include <com/sun/star/beans/Property.hpp>
#endif

#ifndef _DAVSESSIONFACTORY_HXX_
#include "DAVSessionFactory.hxx"
#endif

#ifndef _UCBHELPER_PROVIDERHELPER_HXX
#include <ucbhelper/providerhelper.hxx>
#endif

#ifndef _WEBDAV_UCP_PROPERTYMAP_HXX
#include "PropertyMap.hxx"
#endif

namespace webdav_ucp {

//=========================================================================

// UNO service name for the provider. This name will be used by the UCB to
// create instances of the provider.
#define WEBDAV_CONTENT_PROVIDER_SERVICE_NAME \
                "com.sun.star.ucb.WebDAVContentProvider"
#define WEBDAV_CONTENT_PROVIDER_SERVICE_NAME_LENGTH 38

// URL scheme. This is the scheme the provider will be able to create
// contents for. The UCB will select the provider ( i.e. in order to create
// contents ) according to this scheme.
#define WEBDAV_URL_SCHEME \
                "vnd.sun.star.webdav"
#define WEBDAV_URL_SCHEME_LENGTH    19

#define HTTP_URL_SCHEME         "http"
#define HTTP_URL_SCHEME_LENGTH  4

#define HTTPS_URL_SCHEME        "https"
#define HTTPS_URL_SCHEME_LENGTH 5

#define FTP_URL_SCHEME "ftp"

#define HTTP_CONTENT_TYPE \
                "application/" HTTP_URL_SCHEME "-content"

#define WEBDAV_CONTENT_TYPE    HTTP_CONTENT_TYPE
#define WEBDAV_COLLECTION_TYPE \
                "application/" WEBDAV_URL_SCHEME "-collection"

//=========================================================================

class ContentProvider : public ::ucb::ContentProviderImplHelper
{
    rtl::Reference< DAVSessionFactory > m_xDAVSessionFactory;
    PropertyMap * m_pProps;

public:
    ContentProvider( const ::com::sun::star::uno::Reference<
                        ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
    virtual ~ContentProvider();

    // XInterface
    XINTERFACE_DECL()

    // XTypeProvider
    XTYPEPROVIDER_DECL()

    // XServiceInfo
    XSERVICEINFO_DECL()

    // XContentProvider
    virtual ::com::sun::star::uno::Reference<
                ::com::sun::star::ucb::XContent > SAL_CALL
    queryContent( const ::com::sun::star::uno::Reference<
                    ::com::sun::star::ucb::XContentIdentifier >& Identifier )
        throw( ::com::sun::star::ucb::IllegalIdentifierException,
               ::com::sun::star::uno::RuntimeException );

    //////////////////////////////////////////////////////////////////////
    // Additional interfaces
    //////////////////////////////////////////////////////////////////////

    //////////////////////////////////////////////////////////////////////
    // Non-interface methods.
    //////////////////////////////////////////////////////////////////////

    rtl::Reference< DAVSessionFactory > getDAVSessionFactory()
    { return m_xDAVSessionFactory; }

    bool getProperty( const ::rtl::OUString & rPropName,
                      ::com::sun::star::beans::Property & rProp,
                      bool bStrict = false );
};

}

#endif
<|endoftext|>


<commit_before><commit_msg>This syntax is C++11 only.<commit_after><|endoftext|>


<commit_before>/*
 * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by the
 * Free Software Foundation; either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program 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 Affero General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "Cell.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "TaskScheduler.h"
#include "temple_of_ahnqiraj.h"

enum Spells
{
    // Ouro
    SPELL_SWEEP                 = 26103,
    SPELL_SAND_BLAST            = 26102,
    SPELL_GROUND_RUPTURE        = 26100,
    SPELL_BERSERK               = 26615,
    SPELL_BOULDER               = 26616,
    SPELL_OURO_SUBMERGE_VISUAL  = 26063,
    SPELL_SUMMON_SANDWORM_BASE  = 26133,

    // Misc - Mounds, Ouro Spawner
    SPELL_BIRTH                 = 26586,
    SPELL_DIRTMOUND_PASSIVE     = 26092,
    SPELL_SUMMON_OURO           = 26061,
    SPELL_SUMMON_OURO_MOUNDS    = 26058,
    SPELL_QUAKE                 = 26093,
    SPELL_SUMMON_SCARABS        = 26060,
    SPELL_SUMMON_OURO_AURA      = 26642,
    SPELL_DREAM_FOG             = 24780
};

enum Misc
{
    GROUP_EMERGED               = 0,
    GROUP_PHASE_TRANSITION      = 1,

    NPC_DIRT_MOUND              = 15712,
    GO_SANDWORM_BASE            = 180795,

    DATA_OURO_HEALTH            = 0
};

struct npc_ouro_spawner : public ScriptedAI
{
    npc_ouro_spawner(Creature* creature) : ScriptedAI(creature)
    {
        Reset();
    }

    bool hasSummoned;

    void Reset() override
    {
        hasSummoned = false;
        DoCastSelf(SPELL_DIRTMOUND_PASSIVE);
    }

    void MoveInLineOfSight(Unit* who) override
    {
        // Spawn Ouro on LoS check
        if (!hasSummoned && who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 40.0f) && !who->ToPlayer()->IsGameMaster())
        {
            DoCastSelf(SPELL_SUMMON_OURO);
            hasSummoned = true;
        }

        ScriptedAI::MoveInLineOfSight(who);
    }

    void JustSummoned(Creature* creature) override
    {
        // Despawn when Ouro is spawned
        if (creature->GetEntry() == NPC_OURO)
        {
            creature->SetInCombatWithZone();
            me->DespawnOrUnsummon();
        }
    }
};

struct boss_ouro : public BossAI
{
    boss_ouro(Creature* creature) : BossAI(creature, DATA_OURO)
    {
        SetCombatMovement(false);
        me->SetControlled(true, UNIT_STATE_ROOT);
        _scheduler.SetValidator([this] { return !me->HasUnitState(UNIT_STATE_CASTING); });
    }

    void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType, SpellSchoolMask) override
    {
        if (me->HealthBelowPctDamaged(20, damage) && !_enraged)
        {
            DoCastSelf(SPELL_BERSERK, true);
            _enraged = true;
            _scheduler.CancelGroup(GROUP_PHASE_TRANSITION);
            _scheduler.Schedule(1s, [this](TaskContext context)
                {
                    if (!IsPlayerWithinMeleeRange())
                        DoSpellAttackToRandomTargetIfReady(SPELL_BOULDER);

                    context.Repeat();
                })
                .Schedule(20s, [this](TaskContext context)
                    {
                        DoCastSelf(SPELL_SUMMON_OURO_MOUNDS, true);
                        context.Repeat();
                    });
        }
    }

    void Submerge()
    {
        me->AttackStop();
        me->SetReactState(REACT_PASSIVE);
        me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
        _submergeMelee = 0;
        _submerged = true;
        DoCastSelf(SPELL_OURO_SUBMERGE_VISUAL);
        _scheduler.CancelGroup(GROUP_EMERGED);
        _scheduler.CancelGroup(GROUP_PHASE_TRANSITION);

        if (GameObject* base = me->FindNearestGameObject(GO_SANDWORM_BASE, 10.f))
        {
            base->Use(me);
            base->DespawnOrUnsummon(6s);
        }

        DoCastSelf(SPELL_SUMMON_OURO_MOUNDS, true);
        // According to sniffs, Ouro uses his mounds to respawn. The health management could be a little scuffed.
        std::list<Creature*> ouroMounds;
        me->GetCreatureListWithEntryInGrid(ouroMounds, NPC_DIRT_MOUND, 200.f);
        if (!ouroMounds.empty()) // This can't be possible, but just to be sure.
        {
            if (Creature* mound = Acore::Containers::SelectRandomContainerElement(ouroMounds))
            {
                mound->AddAura(SPELL_SUMMON_OURO_AURA, mound);
                mound->AI()->SetData(DATA_OURO_HEALTH, me->GetHealth());
            }
        }

        me->DespawnOrUnsummon(1000);
    }

    void CastGroundRupture()
    {
        std::list<WorldObject*> targets;
        Acore::AllWorldObjectsInRange checker(me, 10.0f);
        Acore::WorldObjectListSearcher<Acore::AllWorldObjectsInRange> searcher(me, targets, checker);
        Cell::VisitAllObjects(me, searcher, 10.0f);

        for (WorldObject* target : targets)
        {
            if (Unit* unitTarget = target->ToUnit())
            {
                if (unitTarget->IsHostileTo(me))
                    DoCast(unitTarget, SPELL_GROUND_RUPTURE, true);
            }
        }
    }

    void SpellHitTarget(Unit* target, SpellInfo const* spellInfo) override
    {
        if (spellInfo->Id == SPELL_SAND_BLAST && target)
            me->GetThreatMgr().modifyThreatPercent(target, 100);
    }

    void Emerge()
    {
        DoCastSelf(SPELL_BIRTH);
        DoCastSelf(SPELL_SUMMON_SANDWORM_BASE, true);
        me->SetReactState(REACT_AGGRESSIVE);
        CastGroundRupture();
        _scheduler
            .Schedule(20s, GROUP_EMERGED, [this](TaskContext context)
                {
                    DoCastVictim(SPELL_SAND_BLAST);
                    context.Repeat();
                })
            .Schedule(22s, GROUP_EMERGED, [this](TaskContext context)
                {
                    DoCastVictim(SPELL_SWEEP);
                    context.Repeat();
                })
            .Schedule(90s, GROUP_PHASE_TRANSITION, [this](TaskContext /*context*/)
                {
                    Submerge();
                })
            .Schedule(3s, GROUP_PHASE_TRANSITION, [this](TaskContext context)
                {
                    if (!IsPlayerWithinMeleeRange() && !_submerged)
                    {
                        if (_submergeMelee < 10)
                        {
                            _submergeMelee++;
                        }
                        else
                        {
                            if (!_enraged)
                                Submerge();
                            _submergeMelee = 0;
                        }
                    }
                    else
                    {
                        _submergeMelee = 0;
                    }

                    if (!_submerged)
                        context.Repeat(1s);
                });
    }

    void Reset() override
    {
        instance->SetBossState(DATA_OURO, NOT_STARTED);
        _scheduler.CancelAll();
        _submergeMelee = 0;
        _submerged = false;
        _enraged = false;
    }

    void EnterEvadeMode(EvadeReason /*why*/) override
    {
        DoCastSelf(SPELL_OURO_SUBMERGE_VISUAL);
        me->DespawnOrUnsummon(1000);
        instance->SetBossState(DATA_OURO, FAIL);
        if (GameObject* base = me->FindNearestGameObject(GO_SANDWORM_BASE, 200.f))
            base->DespawnOrUnsummon();
    }

    void EnterCombat(Unit* who) override
    {
        Emerge();

        BossAI::EnterCombat(who);
    }

    void UpdateAI(uint32 diff) override
    {
        //Return since we have no target
        if (!UpdateVictim())
            return;

        _scheduler.Update(diff, [this]
            {
                DoMeleeAttackIfReady();
            });
    }

protected:
    TaskScheduler _scheduler;
    bool _enraged;
    uint8 _submergeMelee;
    bool _submerged;

    bool IsPlayerWithinMeleeRange() const
    {
        return me->IsWithinMeleeRange(me->GetVictim());
    }
};

struct npc_dirt_mound : ScriptedAI
{
    npc_dirt_mound(Creature* creature) : ScriptedAI(creature)
    {
        _instance = creature->GetInstanceScript();
    }

    void JustSummoned(Creature* creature) override
    {
        if (creature->GetEntry() == NPC_OURO)
        {
            creature->SetInCombatWithZone();
            creature->SetHealth(_ouroHealth);
        }
    }

    void SetData(uint32 type, uint32 data) override
    {
        if (type == DATA_OURO_HEALTH)
            _ouroHealth = data;
    }

    void EnterCombat(Unit* /*who*/) override
    {
        DoZoneInCombat();
        _scheduler.Schedule(30s, [this](TaskContext /*context*/)
            {
                DoCastSelf(SPELL_SUMMON_SCARABS, true);
                me->DespawnOrUnsummon(1000);
            })
            .Schedule(100ms, [this](TaskContext context)
            {
                ChaseNewTarget();
                context.Repeat(5s, 10s);
            });
    }

    void ChaseNewTarget()
    {
        DoResetThreat();
        if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 200.f, true))
        {
            me->AddThreat(target, 1000000.f);
            AttackStart(target);
        }
    }

    void UpdateAI(uint32 diff) override
    {
        if (!UpdateVictim())
            return;

        _scheduler.Update(diff);
    }

    void Reset() override
    {
        DoCastSelf(SPELL_DIRTMOUND_PASSIVE, true);
        DoCastSelf(SPELL_DREAM_FOG, true);
        DoCastSelf(SPELL_QUAKE, true);
    }

    void EnterEvadeMode(EvadeReason /*why*/) override
    {
        if (_instance)
        {
            _instance->SetBossState(DATA_OURO, FAIL);
        }

        if (GameObject* base = me->FindNearestGameObject(GO_SANDWORM_BASE, 200.f))
            base->DespawnOrUnsummon();

        me->DespawnOrUnsummon();
    }

protected:
    TaskScheduler _scheduler;
    uint32 _ouroHealth;
    InstanceScript* _instance;
};

void AddSC_boss_ouro()
{
    RegisterTempleOfAhnQirajCreatureAI(npc_ouro_spawner);
    RegisterTempleOfAhnQirajCreatureAI(boss_ouro);
    RegisterTempleOfAhnQirajCreatureAI(npc_dirt_mound);
}
<commit_msg>fix(Scripts/TempleOfAhnQiraj): Reduce player damage req for Ouro (#13065)<commit_after>/*
 * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by the
 * Free Software Foundation; either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program 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 Affero General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "Cell.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "TaskScheduler.h"
#include "temple_of_ahnqiraj.h"

enum Spells
{
    // Ouro
    SPELL_SWEEP                 = 26103,
    SPELL_SAND_BLAST            = 26102,
    SPELL_GROUND_RUPTURE        = 26100,
    SPELL_BERSERK               = 26615,
    SPELL_BOULDER               = 26616,
    SPELL_OURO_SUBMERGE_VISUAL  = 26063,
    SPELL_SUMMON_SANDWORM_BASE  = 26133,

    // Misc - Mounds, Ouro Spawner
    SPELL_BIRTH                 = 26586,
    SPELL_DIRTMOUND_PASSIVE     = 26092,
    SPELL_SUMMON_OURO           = 26061,
    SPELL_SUMMON_OURO_MOUNDS    = 26058,
    SPELL_QUAKE                 = 26093,
    SPELL_SUMMON_SCARABS        = 26060,
    SPELL_SUMMON_OURO_AURA      = 26642,
    SPELL_DREAM_FOG             = 24780
};

enum Misc
{
    GROUP_EMERGED               = 0,
    GROUP_PHASE_TRANSITION      = 1,

    NPC_DIRT_MOUND              = 15712,
    GO_SANDWORM_BASE            = 180795,

    DATA_OURO_HEALTH            = 0
};

struct npc_ouro_spawner : public ScriptedAI
{
    npc_ouro_spawner(Creature* creature) : ScriptedAI(creature)
    {
        Reset();
    }

    bool hasSummoned;

    void Reset() override
    {
        hasSummoned = false;
        DoCastSelf(SPELL_DIRTMOUND_PASSIVE);
    }

    void MoveInLineOfSight(Unit* who) override
    {
        // Spawn Ouro on LoS check
        if (!hasSummoned && who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 40.0f) && !who->ToPlayer()->IsGameMaster())
        {
            DoCastSelf(SPELL_SUMMON_OURO);
            hasSummoned = true;
        }

        ScriptedAI::MoveInLineOfSight(who);
    }

    void JustSummoned(Creature* creature) override
    {
        // Despawn when Ouro is spawned
        if (creature->GetEntry() == NPC_OURO)
        {
            creature->SetInCombatWithZone();
            me->DespawnOrUnsummon();
        }
    }
};

struct boss_ouro : public BossAI
{
    boss_ouro(Creature* creature) : BossAI(creature, DATA_OURO)
    {
        SetCombatMovement(false);
        me->SetControlled(true, UNIT_STATE_ROOT);
        _scheduler.SetValidator([this] { return !me->HasUnitState(UNIT_STATE_CASTING); });
    }

    void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType, SpellSchoolMask) override
    {
        if (me->HealthBelowPctDamaged(20, damage) && !_enraged)
        {
            DoCastSelf(SPELL_BERSERK, true);
            _enraged = true;
            _scheduler.CancelGroup(GROUP_PHASE_TRANSITION);
            _scheduler.Schedule(1s, [this](TaskContext context)
                {
                    if (!IsPlayerWithinMeleeRange())
                        DoSpellAttackToRandomTargetIfReady(SPELL_BOULDER);

                    context.Repeat();
                })
                .Schedule(20s, [this](TaskContext context)
                    {
                        DoCastSelf(SPELL_SUMMON_OURO_MOUNDS, true);
                        context.Repeat();
                    });
        }
    }

    void Submerge()
    {
        me->AttackStop();
        me->SetReactState(REACT_PASSIVE);
        me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
        _submergeMelee = 0;
        _submerged = true;
        DoCastSelf(SPELL_OURO_SUBMERGE_VISUAL);
        _scheduler.CancelGroup(GROUP_EMERGED);
        _scheduler.CancelGroup(GROUP_PHASE_TRANSITION);

        if (GameObject* base = me->FindNearestGameObject(GO_SANDWORM_BASE, 10.f))
        {
            base->Use(me);
            base->DespawnOrUnsummon(6s);
        }

        DoCastSelf(SPELL_SUMMON_OURO_MOUNDS, true);
        // According to sniffs, Ouro uses his mounds to respawn. The health management could be a little scuffed.
        std::list<Creature*> ouroMounds;
        me->GetCreatureListWithEntryInGrid(ouroMounds, NPC_DIRT_MOUND, 200.f);
        if (!ouroMounds.empty()) // This can't be possible, but just to be sure.
        {
            if (Creature* mound = Acore::Containers::SelectRandomContainerElement(ouroMounds))
            {
                mound->AddAura(SPELL_SUMMON_OURO_AURA, mound);
                mound->AI()->SetData(DATA_OURO_HEALTH, me->GetHealth());
            }
        }

        me->DespawnOrUnsummon(1000);
    }

    void CastGroundRupture()
    {
        std::list<WorldObject*> targets;
        Acore::AllWorldObjectsInRange checker(me, 10.0f);
        Acore::WorldObjectListSearcher<Acore::AllWorldObjectsInRange> searcher(me, targets, checker);
        Cell::VisitAllObjects(me, searcher, 10.0f);

        for (WorldObject* target : targets)
        {
            if (Unit* unitTarget = target->ToUnit())
            {
                if (unitTarget->IsHostileTo(me))
                    DoCast(unitTarget, SPELL_GROUND_RUPTURE, true);
            }
        }
    }

    void SpellHitTarget(Unit* target, SpellInfo const* spellInfo) override
    {
        if (spellInfo->Id == SPELL_SAND_BLAST && target)
            me->GetThreatMgr().modifyThreatPercent(target, 100);
    }

    void Emerge()
    {
        DoCastSelf(SPELL_BIRTH);
        DoCastSelf(SPELL_SUMMON_SANDWORM_BASE, true);
        me->SetReactState(REACT_AGGRESSIVE);
        CastGroundRupture();
        _scheduler
            .Schedule(20s, GROUP_EMERGED, [this](TaskContext context)
                {
                    DoCastVictim(SPELL_SAND_BLAST);
                    context.Repeat();
                })
            .Schedule(22s, GROUP_EMERGED, [this](TaskContext context)
                {
                    DoCastVictim(SPELL_SWEEP);
                    context.Repeat();
                })
            .Schedule(90s, GROUP_PHASE_TRANSITION, [this](TaskContext /*context*/)
                {
                    Submerge();
                })
            .Schedule(3s, GROUP_PHASE_TRANSITION, [this](TaskContext context)
                {
                    if (!IsPlayerWithinMeleeRange() && !_submerged)
                    {
                        if (_submergeMelee < 10)
                        {
                            _submergeMelee++;
                        }
                        else
                        {
                            if (!_enraged)
                                Submerge();
                            _submergeMelee = 0;
                        }
                    }
                    else
                    {
                        _submergeMelee = 0;
                    }

                    if (!_submerged)
                        context.Repeat(1s);
                });
    }

    void Reset() override
    {
        instance->SetBossState(DATA_OURO, NOT_STARTED);
        _scheduler.CancelAll();
        _submergeMelee = 0;
        _submerged = false;
        _enraged = false;
    }

    void EnterEvadeMode(EvadeReason /*why*/) override
    {
        DoCastSelf(SPELL_OURO_SUBMERGE_VISUAL);
        me->DespawnOrUnsummon(1000);
        instance->SetBossState(DATA_OURO, FAIL);
        if (GameObject* base = me->FindNearestGameObject(GO_SANDWORM_BASE, 200.f))
            base->DespawnOrUnsummon();
    }

    void EnterCombat(Unit* who) override
    {
        Emerge();

        BossAI::EnterCombat(who);
    }

    void UpdateAI(uint32 diff) override
    {
        //Return since we have no target
        if (!UpdateVictim())
            return;

        _scheduler.Update(diff, [this]
            {
                DoMeleeAttackIfReady();
            });
    }

protected:
    TaskScheduler _scheduler;
    bool _enraged;
    uint8 _submergeMelee;
    bool _submerged;

    bool IsPlayerWithinMeleeRange() const
    {
        return me->IsWithinMeleeRange(me->GetVictim());
    }
};

struct npc_dirt_mound : ScriptedAI
{
    npc_dirt_mound(Creature* creature) : ScriptedAI(creature)
    {
        _instance = creature->GetInstanceScript();
    }

    void JustSummoned(Creature* creature) override
    {
        if (creature->GetEntry() == NPC_OURO)
        {
            creature->SetInCombatWithZone();
            creature->SetHealth(_ouroHealth);
            creature->LowerPlayerDamageReq(creature->GetMaxHealth() - creature->GetHealth());
        }
    }

    void SetData(uint32 type, uint32 data) override
    {
        if (type == DATA_OURO_HEALTH)
            _ouroHealth = data;
    }

    void EnterCombat(Unit* /*who*/) override
    {
        DoZoneInCombat();
        _scheduler.Schedule(30s, [this](TaskContext /*context*/)
            {
                DoCastSelf(SPELL_SUMMON_SCARABS, true);
                me->DespawnOrUnsummon(1000);
            })
            .Schedule(100ms, [this](TaskContext context)
            {
                ChaseNewTarget();
                context.Repeat(5s, 10s);
            });
    }

    void ChaseNewTarget()
    {
        DoResetThreat();
        if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 200.f, true))
        {
            me->AddThreat(target, 1000000.f);
            AttackStart(target);
        }
    }

    void UpdateAI(uint32 diff) override
    {
        if (!UpdateVictim())
            return;

        _scheduler.Update(diff);
    }

    void Reset() override
    {
        DoCastSelf(SPELL_DIRTMOUND_PASSIVE, true);
        DoCastSelf(SPELL_DREAM_FOG, true);
        DoCastSelf(SPELL_QUAKE, true);
    }

    void EnterEvadeMode(EvadeReason /*why*/) override
    {
        if (_instance)
        {
            _instance->SetBossState(DATA_OURO, FAIL);
        }

        if (GameObject* base = me->FindNearestGameObject(GO_SANDWORM_BASE, 200.f))
            base->DespawnOrUnsummon();

        me->DespawnOrUnsummon();
    }

protected:
    TaskScheduler _scheduler;
    uint32 _ouroHealth;
    InstanceScript* _instance;
};

void AddSC_boss_ouro()
{
    RegisterTempleOfAhnQirajCreatureAI(npc_ouro_spawner);
    RegisterTempleOfAhnQirajCreatureAI(boss_ouro);
    RegisterTempleOfAhnQirajCreatureAI(npc_dirt_mound);
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: null_spritecanvas.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: kz $ $Date: 2006-12-13 14:45:40 $
 *
 *  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 _NULLCANVAS_SPRITECANVAS_HXX_
#define _NULLCANVAS_SPRITECANVAS_HXX_

#include <rtl/ref.hxx>

#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/awt/XWindowListener.hpp>
#include <com/sun/star/rendering/XSpriteCanvas.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
#include <com/sun/star/rendering/XColorSpace.hpp>
#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>

#include <cppuhelper/compbase9.hxx>
#include <comphelper/uno3.hxx>

#include <canvas/base/spritecanvasbase.hxx>
#include <canvas/base/basemutexhelper.hxx>
#include <canvas/base/windowgraphicdevicebase.hxx>

#include "null_spritecanvashelper.hxx"
#include "null_devicehelper.hxx"
#include "null_usagecounter.hxx"

namespace nullcanvas
{
    typedef ::cppu::WeakComponentImplHelper9<  ::com::sun::star::rendering::XSpriteCanvas,
                                                ::com::sun::star::rendering::XIntegerBitmap,
                                                ::com::sun::star::rendering::XGraphicDevice,
                                               ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
                                               ::com::sun::star::rendering::XBufferController,
                                               ::com::sun::star::rendering::XColorSpace,
                                               ::com::sun::star::awt::XWindowListener,
                                               ::com::sun::star::beans::XPropertySet,
                                               ::com::sun::star::lang::XServiceName >   WindowGraphicDeviceBase_Base;
    typedef ::canvas::WindowGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >,
                                               DeviceHelper,
                                               ::osl::MutexGuard,
                                               ::cppu::OWeakObject >    SpriteCanvasBase_Base;
    /** Mixin SpriteSurface

        Have to mixin the SpriteSurface before deriving from
        ::canvas::SpriteCanvasBase, as this template should already
        implement some of those interface methods.

        The reason why this appears kinda convoluted is the fact that
        we cannot specify non-IDL types as WeakComponentImplHelperN
        template args, and furthermore, don't want to derive
        ::canvas::SpriteCanvasBase directly from
        ::canvas::SpriteSurface (because derivees of
        ::canvas::SpriteCanvasBase have to explicitely forward the
        XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
        anyway). Basically, ::canvas::CanvasCustomSpriteBase should
        remain a base class that provides implementation, not to
        enforce any specific interface on its derivees.
     */
    class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base,
                                               public ::canvas::SpriteSurface
    {
    };

    typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base,
                                        SpriteCanvasHelper,
                                        ::osl::MutexGuard,
                                        ::cppu::OWeakObject >           SpriteCanvasBaseT;

    /** Product of this component's factory.

        The SpriteCanvas object combines the actual Window canvas with
        the XGraphicDevice interface. This is because there's a
        one-to-one relation between them, anyway, since each window
        can have exactly one canvas and one associated
        XGraphicDevice. And to avoid messing around with circular
        references, this is implemented as one single object.
     */
    class SpriteCanvas : public SpriteCanvasBaseT,
                         private UsageCounter< SpriteCanvas >
    {
    public:
        SpriteCanvas( const ::com::sun::star::uno::Sequence<
                            ::com::sun::star::uno::Any >&               aArguments,
                      const ::com::sun::star::uno::Reference<
                            ::com::sun::star::uno::XComponentContext >& rxContext );

        void initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );

#if defined __SUNPRO_CC
        using SpriteCanvasBaseT::disposing;
#endif

        /// Dispose all internal references
        virtual void SAL_CALL disposing();

        // Forwarding the XComponent implementation to the
        // cppu::ImplHelper templated base
        //                                    Classname     Base doing refcounting        Base implementing the XComponent interface
        //                                       |                 |                            |
        //                                       V                 V                            V
        DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase );

        // XBufferController (partial)
        virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
        virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);

        // XSpriteCanvas (partial)
        virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);

        // XServiceName
        virtual ::rtl::OUString SAL_CALL getServiceName(  ) throw (::com::sun::star::uno::RuntimeException);

     private:
        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
    };

    typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
    typedef ::rtl::Reference< SpriteCanvas > DeviceRef;
}

#endif
<commit_msg>INTEGRATION: CWS changefileheader (1.3.80); FILE MERGED 2008/03/28 16:35:09 rt 1.3.80.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: null_spritecanvas.hxx,v $
 * $Revision: 1.4 $
 *
 * 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 _NULLCANVAS_SPRITECANVAS_HXX_
#define _NULLCANVAS_SPRITECANVAS_HXX_

#include <rtl/ref.hxx>

#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/awt/XWindowListener.hpp>
#include <com/sun/star/rendering/XSpriteCanvas.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
#include <com/sun/star/rendering/XColorSpace.hpp>
#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>

#include <cppuhelper/compbase9.hxx>
#include <comphelper/uno3.hxx>

#include <canvas/base/spritecanvasbase.hxx>
#include <canvas/base/basemutexhelper.hxx>
#include <canvas/base/windowgraphicdevicebase.hxx>

#include "null_spritecanvashelper.hxx"
#include "null_devicehelper.hxx"
#include "null_usagecounter.hxx"

namespace nullcanvas
{
    typedef ::cppu::WeakComponentImplHelper9<  ::com::sun::star::rendering::XSpriteCanvas,
                                                ::com::sun::star::rendering::XIntegerBitmap,
                                                ::com::sun::star::rendering::XGraphicDevice,
                                               ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
                                               ::com::sun::star::rendering::XBufferController,
                                               ::com::sun::star::rendering::XColorSpace,
                                               ::com::sun::star::awt::XWindowListener,
                                               ::com::sun::star::beans::XPropertySet,
                                               ::com::sun::star::lang::XServiceName >   WindowGraphicDeviceBase_Base;
    typedef ::canvas::WindowGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >,
                                               DeviceHelper,
                                               ::osl::MutexGuard,
                                               ::cppu::OWeakObject >    SpriteCanvasBase_Base;
    /** Mixin SpriteSurface

        Have to mixin the SpriteSurface before deriving from
        ::canvas::SpriteCanvasBase, as this template should already
        implement some of those interface methods.

        The reason why this appears kinda convoluted is the fact that
        we cannot specify non-IDL types as WeakComponentImplHelperN
        template args, and furthermore, don't want to derive
        ::canvas::SpriteCanvasBase directly from
        ::canvas::SpriteSurface (because derivees of
        ::canvas::SpriteCanvasBase have to explicitely forward the
        XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
        anyway). Basically, ::canvas::CanvasCustomSpriteBase should
        remain a base class that provides implementation, not to
        enforce any specific interface on its derivees.
     */
    class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base,
                                               public ::canvas::SpriteSurface
    {
    };

    typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base,
                                        SpriteCanvasHelper,
                                        ::osl::MutexGuard,
                                        ::cppu::OWeakObject >           SpriteCanvasBaseT;

    /** Product of this component's factory.

        The SpriteCanvas object combines the actual Window canvas with
        the XGraphicDevice interface. This is because there's a
        one-to-one relation between them, anyway, since each window
        can have exactly one canvas and one associated
        XGraphicDevice. And to avoid messing around with circular
        references, this is implemented as one single object.
     */
    class SpriteCanvas : public SpriteCanvasBaseT,
                         private UsageCounter< SpriteCanvas >
    {
    public:
        SpriteCanvas( const ::com::sun::star::uno::Sequence<
                            ::com::sun::star::uno::Any >&               aArguments,
                      const ::com::sun::star::uno::Reference<
                            ::com::sun::star::uno::XComponentContext >& rxContext );

        void initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );

#if defined __SUNPRO_CC
        using SpriteCanvasBaseT::disposing;
#endif

        /// Dispose all internal references
        virtual void SAL_CALL disposing();

        // Forwarding the XComponent implementation to the
        // cppu::ImplHelper templated base
        //                                    Classname     Base doing refcounting        Base implementing the XComponent interface
        //                                       |                 |                            |
        //                                       V                 V                            V
        DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase );

        // XBufferController (partial)
        virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
        virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);

        // XSpriteCanvas (partial)
        virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);

        // XServiceName
        virtual ::rtl::OUString SAL_CALL getServiceName(  ) throw (::com::sun::star::uno::RuntimeException);

     private:
        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
    };

    typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
    typedef ::rtl::Reference< SpriteCanvas > DeviceRef;
}

#endif
<|endoftext|>


<commit_before>/*
* BCJR Decoding, Memoryless Modulation, and Filtering come from Tarik BENADDI (Toulouse INP)
*/
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <cmath>

#include "../../../Decoder/decoder_functions.h"

#include "Modulator_GSM_BCJR.hpp"

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BCJR tools //////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename Q>
struct negative_inf
{
	static Q get() { return -std::numeric_limits<Q>::max(); }
};

template <>
struct negative_inf <short>
{
	static short get() { return -(1 << (sizeof(short) * 8 -2)); }
};

template <>
struct negative_inf <signed char>
{
	static signed char get() { return -63; }
};

template <typename Q, proto_max<Q> MAX>
struct BCJR_normalize
{
	// Adrien comment's: I think that the normalisation is useless in floating point arithmetic
	static void apply(Q *metrics, const int &i, const int &n_states)
	{
		// normalization
		auto norm_val = negative_inf<signed char>::get();
		for (auto j = 0; j < n_states; j++)
			norm_val = MAX(norm_val, metrics[j]);

		for (auto j = 0; j < n_states; j++)
			metrics[j] -= norm_val;
	}
};

template <proto_max<signed char> MAX>
struct BCJR_normalize <signed char,MAX>
{
	static void apply(signed char *metrics, const int &i, const int &n_states)
	{
		// normalization & saturation
		auto norm_val = negative_inf<signed char>::get();
		for (auto j = 0; j < n_states; j++)
			norm_val = MAX(norm_val, metrics[j]);

		for (auto j = 0; j < n_states; j++)
			metrics[j] = saturate<signed char>(metrics[j] - norm_val, -63, +63);
	}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

template <typename Q, proto_max<Q> MAX>
Modulator_GSM_BCJR<Q,MAX>
::Modulator_GSM_BCJR(const int frame_size,
	                 const int n_states,
	                 const int m_order,
	                 const int n_bits_per_symb,
	                 const int n_prev_branches,
	                 const std::vector<int> binary_symbols,
	                 const std::vector<int> trellis,
	                 const std::vector<int> anti_trellis)
: frame_size     (frame_size     ),
  n_states       (n_states       ),
  m_order        (m_order        ),
  n_bits_per_symb(n_bits_per_symb),
  n_prev_branches(n_prev_branches),

  binary_symbols(binary_symbols),
  trellis       (trellis       ),
  anti_trellis  (anti_trellis  ),

  symb_apriori_prob(frame_size            * m_order   ),
  gamma            (frame_size * n_states * m_order   ),
  alpha            (frame_size * n_states             ),
  beta             (frame_size * n_states             ),
  proba_msg_symb   (frame_size            * m_order, 0),
  proba_msg_bits   (frame_size            * 2      , 0)
{
}

template <typename Q, proto_max<Q> MAX>
Modulator_GSM_BCJR<Q,MAX>
::~Modulator_GSM_BCJR()
{
}

template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::decode(const mipp::vector<Q> &Lch_N, mipp::vector<Q> &Le_N)
{
	std::fill(this->symb_apriori_prob.begin(), this->symb_apriori_prob.end(), 0);

	compute_alpha_beta_gamma(Lch_N);
	symboles_probas         (     );
	bits_probas             (     );
	compute_ext             (Le_N );
}

template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::decode(const mipp::vector<Q> &Lch_N, const mipp::vector<Q> &Ldec_N, mipp::vector<Q> &Le_N)
{
	LLR_to_logsymb_proba    (Ldec_N      );
	compute_alpha_beta_gamma(Lch_N       );
	symboles_probas         (            );
	bits_probas             (            );
	compute_ext             (Ldec_N, Le_N);
}

// retrieve log symbols probability from LLR
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::LLR_to_logsymb_proba(const mipp::vector<Q> &Ldec_N)
{
	std::fill(this->symb_apriori_prob.begin(), this->symb_apriori_prob.end(), 0);

	for (auto i = 0; i < (int) this->symb_apriori_prob.size() / m_order; i++)
		for (auto j = 0; j < this->m_order; j++)
			for (auto k = 0; k < this->n_bits_per_symb; k++)
			{
				const auto symbol = this->binary_symbols[k * this->m_order +j];
				const auto sign   = 1 - (symbol + symbol);
				this->symb_apriori_prob[i * this->m_order +j] += (Q)sign * Ldec_N[i * this->n_bits_per_symb +k] * 0.5;
			}
}

// compute gamma, alpha and beta, heart of the processing
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::compute_alpha_beta_gamma(const mipp::vector<Q> &Lch_N)
{
	// alpha and beta initialization
	std::fill(this->alpha.begin(), this->alpha.end(), negative_inf<Q>::get());
	std::fill(this->beta .begin(), this->beta .end(), negative_inf<Q>::get());
	this->alpha[0                                     ] = 0;
	this->beta [(this->frame_size -1) * this->n_states] = 0;

	// other way to initialize beta: does not support the fixed point mode because of the log function call
	// this is usefull when we don't use the tail bits in the turbo demodulation
	// auto beta_final_equi_proba = 1.0 / this->n_states;
	for (auto i = 0; i < this->n_states; i++)
		// this->beta[(this->frame_size -1) * n_states +i] = std::log(beta_final_equi_proba);
		this->beta[(this->frame_size -1) * n_states +i] = 0;

	// compute gamma
	for (auto i = 0; i < this->frame_size; i++)
		for (auto j = 0; j < this->n_states; j++)
			for (auto k = 0; k < this->m_order; k++)
				this->gamma[(k * n_states +j) * this->frame_size +i] =
					Lch_N[this->trellis[(k + this->m_order) * this->n_states +j] * this->frame_size +i] + // info from the channel
					this->symb_apriori_prob[i * this->m_order +k];                                        // info from the decoder

	// compute alpha and beta
	for (auto i = 1; i < this->frame_size; i++)
	{
		for (auto j = 0; j < this->n_states; j++)
		{
			const auto original_state = this->anti_trellis.data() +                  j  * this->n_prev_branches;
			const auto input_symb     = this->anti_trellis.data() + (this->n_states +j) * this->n_prev_branches;

			// compute the alpha nodes
			for (auto k = 0; k < this->n_prev_branches; k++)
				this->alpha        [(i -0) * this->n_states                  +j] =
				    MAX(this->alpha[(i -0) * this->n_states                  +j],
				        this->alpha[(i -1) * this->n_states + original_state[k]] +
				        this->gamma[(input_symb[k] * this->n_states + original_state[k]) * this->frame_size +i -1]);

			// compute the beta nodes
			for (auto k = 0; k < this->m_order; k++)
				this->beta         [(this->frame_size - (i +1)) * this->n_states                                     +j] =
				    MAX(this->beta [(this->frame_size - (i +1)) * this->n_states                                     +j],
				        this->beta [(this->frame_size - (i +0)) * this->n_states + this->trellis[k * this->n_states +j]] +
				        this->gamma[(k * this->n_states +j) * this->frame_size + this->frame_size -i]);
		}

		// normalize alpha and beta vectors (not impact on the decoding performances)
		BCJR_normalize<Q,MAX>::apply(&this->alpha[                    (i +0)  * this->n_states], i, this->n_states);
		BCJR_normalize<Q,MAX>::apply(&this->beta [(this->frame_size - (i +1)) * this->n_states], i, this->n_states);
	}
}

// from alpha, beta, and gamma computes new symbol probability
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::symboles_probas()
{
	// initialize proba_msg_symb
	for (auto i = 0; i < this->frame_size; i++)
		for (auto j = 0; j < this->m_order; j++)
			proba_msg_symb[i * this->m_order +j] = negative_inf<Q>::get();

	for (auto i = 0; i < this->frame_size; i++)
		for (auto j = 0; j < this->m_order; j++)
			for (auto k = 0; k < this->n_states; k++)
				proba_msg_symb        [ i * this->m_order                                      +j] =
				    MAX(proba_msg_symb[ i * this->m_order                                      +j],
				        this->alpha   [ i * this->n_states                                     +k] +
				        this->beta    [ i * this->n_states + this->trellis[j * this->n_states +k]] +
				        this->gamma   [(j * this->n_states +k) * this->frame_size              +i]);
}

// from symbol probabilities, computes bit probabilities
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::bits_probas()
{
	// initialize proba_msg_bits
	std::fill(proba_msg_bits.begin(), proba_msg_bits.end(), negative_inf<Q>::get());

	for (auto i = 0; i < this->frame_size; i++)
	{
		const auto ii = i * this->n_bits_per_symb;
		for (auto j = 0; j < n_bits_per_symb; j++)
			for (auto k = 0; k < this->m_order; k++)
			{
				const auto symbol = binary_symbols[j * this->m_order +k];

				// bit 0
				if (symbol == 0)
					proba_msg_bits[(ii +j) * 2 +0] = MAX(proba_msg_bits[(ii +j) * 2 +0],
					                                     proba_msg_symb[i * this->m_order +k]);
				// bit 1
				else if (symbol == 1)
					proba_msg_bits[(ii +j) * 2 +1] = MAX(proba_msg_bits[(ii +j) * 2 +1],
					                                     proba_msg_symb[i * this->m_order +k]);
			}
	}
}

// extrinsic information processing from bit probabilities
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::compute_ext(mipp::vector<Q> &Le_N)
{
	const auto loop_size = (int)Le_N.size() * 2;
	for (auto i = 0; i < loop_size; i += 2)
		// processing aposteriori and substracting a priori to directly obtain extrinsic
		Le_N[i / 2] = proba_msg_bits[i] - proba_msg_bits[i +1];
}

// extrinsic information processing from bit probabilities and CPM a priori LLR
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::compute_ext(const mipp::vector<Q> &Ldec_N,
                    mipp::vector<Q> &Le_N)
{
	const auto loop_size = (int)Le_N.size() * 2;
	for (auto i = 0; i < loop_size; i += 2)
		// processing aposteriori and substracting a priori to directly obtain extrinsic
		Le_N[i / 2] = proba_msg_bits[i] - (proba_msg_bits[i +1] + Ldec_N[i / 2]);
}<commit_msg>Typo-Bug Corrected.<commit_after>/*
* BCJR Decoding, Memoryless Modulation, and Filtering come from Tarik BENADDI (Toulouse INP)
*/
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <cmath>

#include "../../../Decoder/decoder_functions.h"

#include "Modulator_GSM_BCJR.hpp"

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BCJR tools //////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename Q>
struct negative_inf
{
	static Q get() { return -std::numeric_limits<Q>::max(); }
};

template <>
struct negative_inf <short>
{
	static short get() { return -(1 << (sizeof(short) * 8 -2)); }
};

template <>
struct negative_inf <signed char>
{
	static signed char get() { return -63; }
};

template <typename Q, proto_max<Q> MAX>
struct BCJR_normalize
{
	// Adrien comment's: I think that the normalisation is useless in floating point arithmetic
	static void apply(Q *metrics, const int &i, const int &n_states)
	{
		// normalization
		auto norm_val = negative_inf<Q>::get();
		for (auto j = 0; j < n_states; j++)
			norm_val = MAX(norm_val, metrics[j]);

		for (auto j = 0; j < n_states; j++)
			metrics[j] -= norm_val;
	}
};

template <proto_max<signed char> MAX>
struct BCJR_normalize <signed char,MAX>
{
	static void apply(signed char *metrics, const int &i, const int &n_states)
	{
		// normalization & saturation
		auto norm_val = negative_inf<signed char>::get();
		for (auto j = 0; j < n_states; j++)
			norm_val = MAX(norm_val, metrics[j]);

		for (auto j = 0; j < n_states; j++)
			metrics[j] = saturate<signed char>(metrics[j] - norm_val, -63, +63);
	}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

template <typename Q, proto_max<Q> MAX>
Modulator_GSM_BCJR<Q,MAX>
::Modulator_GSM_BCJR(const int frame_size,
	                 const int n_states,
	                 const int m_order,
	                 const int n_bits_per_symb,
	                 const int n_prev_branches,
	                 const std::vector<int> binary_symbols,
	                 const std::vector<int> trellis,
	                 const std::vector<int> anti_trellis)
: frame_size     (frame_size     ),
  n_states       (n_states       ),
  m_order        (m_order        ),
  n_bits_per_symb(n_bits_per_symb),
  n_prev_branches(n_prev_branches),

  binary_symbols(binary_symbols),
  trellis       (trellis       ),
  anti_trellis  (anti_trellis  ),

  symb_apriori_prob(frame_size            * m_order   ),
  gamma            (frame_size * n_states * m_order   ),
  alpha            (frame_size * n_states             ),
  beta             (frame_size * n_states             ),
  proba_msg_symb   (frame_size            * m_order, 0),
  proba_msg_bits   (frame_size            * 2      , 0)
{
}

template <typename Q, proto_max<Q> MAX>
Modulator_GSM_BCJR<Q,MAX>
::~Modulator_GSM_BCJR()
{
}

template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::decode(const mipp::vector<Q> &Lch_N, mipp::vector<Q> &Le_N)
{
	std::fill(this->symb_apriori_prob.begin(), this->symb_apriori_prob.end(), 0);

	compute_alpha_beta_gamma(Lch_N);
	symboles_probas         (     );
	bits_probas             (     );
	compute_ext             (Le_N );
}

template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::decode(const mipp::vector<Q> &Lch_N, const mipp::vector<Q> &Ldec_N, mipp::vector<Q> &Le_N)
{
	LLR_to_logsymb_proba    (Ldec_N      );
	compute_alpha_beta_gamma(Lch_N       );
	symboles_probas         (            );
	bits_probas             (            );
	compute_ext             (Ldec_N, Le_N);
}

// retrieve log symbols probability from LLR
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::LLR_to_logsymb_proba(const mipp::vector<Q> &Ldec_N)
{
	std::fill(this->symb_apriori_prob.begin(), this->symb_apriori_prob.end(), 0);

	for (auto i = 0; i < (int) this->symb_apriori_prob.size() / m_order; i++)
		for (auto j = 0; j < this->m_order; j++)
			for (auto k = 0; k < this->n_bits_per_symb; k++)
			{
				const auto symbol = this->binary_symbols[k * this->m_order +j];
				const auto sign   = 1 - (symbol + symbol);
				this->symb_apriori_prob[i * this->m_order +j] += (Q)sign * Ldec_N[i * this->n_bits_per_symb +k] * 0.5;
			}
}

// compute gamma, alpha and beta, heart of the processing
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::compute_alpha_beta_gamma(const mipp::vector<Q> &Lch_N)
{
	// alpha and beta initialization
	std::fill(this->alpha.begin(), this->alpha.end(), negative_inf<Q>::get());
	std::fill(this->beta .begin(), this->beta .end(), negative_inf<Q>::get());
	this->alpha[0                                     ] = 0;
	this->beta [(this->frame_size -1) * this->n_states] = 0;

	// other way to initialize beta: does not support the fixed point mode because of the log function call
	// this is usefull when we don't use the tail bits in the turbo demodulation
	// auto beta_final_equi_proba = 1.0 / this->n_states;
	for (auto i = 0; i < this->n_states; i++)
		// this->beta[(this->frame_size -1) * n_states +i] = std::log(beta_final_equi_proba);
		this->beta[(this->frame_size -1) * n_states +i] = 0;

	// compute gamma
	for (auto i = 0; i < this->frame_size; i++)
		for (auto j = 0; j < this->n_states; j++)
			for (auto k = 0; k < this->m_order; k++)
				this->gamma[(k * n_states +j) * this->frame_size +i] =
					Lch_N[this->trellis[(k + this->m_order) * this->n_states +j] * this->frame_size +i] + // info from the channel
					this->symb_apriori_prob[i * this->m_order +k];                                        // info from the decoder

	// compute alpha and beta
	for (auto i = 1; i < this->frame_size; i++)
	{
		for (auto j = 0; j < this->n_states; j++)
		{
			const auto original_state = this->anti_trellis.data() +                  j  * this->n_prev_branches;
			const auto input_symb     = this->anti_trellis.data() + (this->n_states +j) * this->n_prev_branches;

			// compute the alpha nodes
			for (auto k = 0; k < this->n_prev_branches; k++)
				this->alpha        [(i -0) * this->n_states                  +j] =
				    MAX(this->alpha[(i -0) * this->n_states                  +j],
				        this->alpha[(i -1) * this->n_states + original_state[k]] +
				        this->gamma[(input_symb[k] * this->n_states + original_state[k]) * this->frame_size +i -1]);

			// compute the beta nodes
			for (auto k = 0; k < this->m_order; k++)
				this->beta         [(this->frame_size - (i +1)) * this->n_states                                     +j] =
				    MAX(this->beta [(this->frame_size - (i +1)) * this->n_states                                     +j],
				        this->beta [(this->frame_size - (i +0)) * this->n_states + this->trellis[k * this->n_states +j]] +
				        this->gamma[(k * this->n_states +j) * this->frame_size + this->frame_size -i]);
		}

		// normalize alpha and beta vectors (not impact on the decoding performances)
		BCJR_normalize<Q,MAX>::apply(&this->alpha[                    (i +0)  * this->n_states], i, this->n_states);
		BCJR_normalize<Q,MAX>::apply(&this->beta [(this->frame_size - (i +1)) * this->n_states], i, this->n_states);
	}
}

// from alpha, beta, and gamma computes new symbol probability
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::symboles_probas()
{
	// initialize proba_msg_symb
	for (auto i = 0; i < this->frame_size; i++)
		for (auto j = 0; j < this->m_order; j++)
			proba_msg_symb[i * this->m_order +j] = negative_inf<Q>::get();

	for (auto i = 0; i < this->frame_size; i++)
		for (auto j = 0; j < this->m_order; j++)
			for (auto k = 0; k < this->n_states; k++)
				proba_msg_symb        [ i * this->m_order                                      +j] =
				    MAX(proba_msg_symb[ i * this->m_order                                      +j],
				        this->alpha   [ i * this->n_states                                     +k] +
				        this->beta    [ i * this->n_states + this->trellis[j * this->n_states +k]] +
				        this->gamma   [(j * this->n_states +k) * this->frame_size              +i]);
}

// from symbol probabilities, computes bit probabilities
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::bits_probas()
{
	// initialize proba_msg_bits
	std::fill(proba_msg_bits.begin(), proba_msg_bits.end(), negative_inf<Q>::get());

	for (auto i = 0; i < this->frame_size; i++)
	{
		const auto ii = i * this->n_bits_per_symb;
		for (auto j = 0; j < n_bits_per_symb; j++)
			for (auto k = 0; k < this->m_order; k++)
			{
				const auto symbol = binary_symbols[j * this->m_order +k];

				// bit 0
				if (symbol == 0)
					proba_msg_bits[(ii +j) * 2 +0] = MAX(proba_msg_bits[(ii +j) * 2 +0],
					                                     proba_msg_symb[i * this->m_order +k]);
				// bit 1
				else if (symbol == 1)
					proba_msg_bits[(ii +j) * 2 +1] = MAX(proba_msg_bits[(ii +j) * 2 +1],
					                                     proba_msg_symb[i * this->m_order +k]);
			}
	}
}

// extrinsic information processing from bit probabilities
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::compute_ext(mipp::vector<Q> &Le_N)
{
	const auto loop_size = (int)Le_N.size() * 2;
	for (auto i = 0; i < loop_size; i += 2)
		// processing aposteriori and substracting a priori to directly obtain extrinsic
		Le_N[i / 2] = proba_msg_bits[i] - proba_msg_bits[i +1];
}

// extrinsic information processing from bit probabilities and CPM a priori LLR
template <typename Q, proto_max<Q> MAX>
void Modulator_GSM_BCJR<Q,MAX>
::compute_ext(const mipp::vector<Q> &Ldec_N,
                    mipp::vector<Q> &Le_N)
{
	const auto loop_size = (int)Le_N.size() * 2;
	for (auto i = 0; i < loop_size; i += 2)
		// processing aposteriori and substracting a priori to directly obtain extrinsic
		Le_N[i / 2] = proba_msg_bits[i] - (proba_msg_bits[i +1] + Ldec_N[i / 2]);
}<|endoftext|>


<commit_before>// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <list>
#include <vector>

#include <glog/logging.h>

#include <stout/hashmap.hpp>
#include <stout/json.hpp>
#include <stout/os.hpp>

#include <process/collect.hpp>
#include <process/defer.hpp>
#include <process/dispatch.hpp>
#include <process/subprocess.hpp>

#include <mesos/docker/spec.hpp>

#include "common/status_utils.hpp"

#include "slave/containerizer/mesos/provisioner/docker/metadata_manager.hpp"
#include "slave/containerizer/mesos/provisioner/docker/store.hpp"
#include "slave/containerizer/mesos/provisioner/docker/paths.hpp"
#include "slave/containerizer/mesos/provisioner/docker/puller.hpp"

using namespace process;

namespace spec = docker::spec;

using std::list;
using std::pair;
using std::string;
using std::vector;

namespace mesos {
namespace internal {
namespace slave {
namespace docker {

class StoreProcess : public Process<StoreProcess>
{
public:
  StoreProcess(
      const Flags& _flags,
      const Owned<MetadataManager>& _metadataManager,
      const Owned<Puller>& _puller)
    : flags(_flags),
      metadataManager(_metadataManager),
      puller(_puller) {}

  ~StoreProcess() {}

  Future<Nothing> recover();

  Future<ImageInfo> get(const mesos::Image& image);

private:
  Future<Image> _get(
      const spec::ImageReference& reference,
      const Option<Image>& image);

  Future<ImageInfo> __get(const Image& image);

  Future<vector<string>> moveLayers(
      const list<pair<string, string>>& layerPaths);

  Future<Image> storeImage(
      const spec::ImageReference& reference,
      const vector<string>& layerIds);

  Future<Nothing> moveLayer(
      const pair<string, string>& layerPath);

  const Flags flags;
  Owned<MetadataManager> metadataManager;
  Owned<Puller> puller;
  hashmap<string, Owned<Promise<Image>>> pulling;
};

Try<Owned<slave::Store>> Store::create(const Flags& flags)
{
  Try<Owned<Puller>> puller = Puller::create(flags);
  if (puller.isError()) {
    return Error("Failed to create Docker puller: " + puller.error());
  }

  Try<Owned<slave::Store>> store = Store::create(flags, puller.get());
  if (store.isError()) {
    return Error("Failed to create Docker store: " + store.error());
  }

  return store.get();
}

Try<Owned<slave::Store>> Store::create(
    const Flags& flags,
    const Owned<Puller>& puller)
{
  Try<Nothing> mkdir = os::mkdir(flags.docker_store_dir);
  if (mkdir.isError()) {
    return Error("Failed to create Docker store directory: " +
                 mkdir.error());
  }

  mkdir = os::mkdir(paths::getStagingDir(flags.docker_store_dir));
  if (mkdir.isError()) {
    return Error("Failed to create Docker store staging directory: " +
                 mkdir.error());
  }

  Try<Owned<MetadataManager>> metadataManager = MetadataManager::create(flags);
  if (metadataManager.isError()) {
    return Error(metadataManager.error());
  }

  Owned<StoreProcess> process(
      new StoreProcess(flags, metadataManager.get(), puller));

  return Owned<slave::Store>(new Store(process));
}

Store::Store(const Owned<StoreProcess>& _process) : process(_process)
{
  spawn(CHECK_NOTNULL(process.get()));
}

Store::~Store()
{
  terminate(process.get());
  wait(process.get());
}

Future<Nothing> Store::recover()
{
  return dispatch(process.get(), &StoreProcess::recover);
}

Future<ImageInfo> Store::get(const mesos::Image& image)
{
  return dispatch(process.get(), &StoreProcess::get, image);
}

Future<ImageInfo> StoreProcess::get(const mesos::Image& image)
{
  if (image.type() != mesos::Image::DOCKER) {
    return Failure("Docker provisioner store only supports Docker images");
  }

  Try<spec::ImageReference> reference =
    spec::parseImageReference(image.docker().name());

  if (reference.isError()) {
    return Failure("Failed to parse docker image '" + image.docker().name() +
                   "': " + reference.error());
  }

  return metadataManager->get(reference.get())
    .then(defer(self(), &Self::_get, reference.get(), lambda::_1))
    .then(defer(self(), &Self::__get, lambda::_1));
}

Future<Image> StoreProcess::_get(
    const spec::ImageReference& reference,
    const Option<Image>& image)
{
  if (image.isSome()) {
    return image.get();
  }

  Try<string> staging =
    os::mkdtemp(paths::getStagingTempDir(flags.docker_store_dir));

  if (staging.isError()) {
    return Failure("Failed to create a staging directory");
  }

  const string imageReference = stringify(reference);

  if (!pulling.contains(imageReference)) {
    Owned<Promise<Image>> promise(new Promise<Image>());

    Future<Image> future = puller->pull(reference, Path(staging.get()))
      .then(defer(self(), &Self::moveLayers, lambda::_1))
      .then(defer(self(), &Self::storeImage, reference, lambda::_1))
      .onAny(defer(self(), [this, imageReference](const Future<Image>&) {
        pulling.erase(imageReference);
      }))
      .onAny([staging, imageReference]() {
        Try<Nothing> rmdir = os::rmdir(staging.get());
        if (rmdir.isError()) {
          LOG(WARNING) << "Failed to remove staging directory: "
                       << rmdir.error();
        }
      });

    promise->associate(future);
    pulling[imageReference] = promise;

    return promise->future();
  }

  return pulling[imageReference]->future();
}

Future<ImageInfo> StoreProcess::__get(const Image& image)
{
  CHECK_LT(0, image.layer_ids_size());

  vector<string> layerDirectories;
  foreach (const string& layer, image.layer_ids()) {
    layerDirectories.push_back(
        paths::getImageLayerRootfsPath(
            flags.docker_store_dir, layer));
  }

  // Read the manifest from the last layer because all runtime config
  // are merged at the leaf already.
  Try<string> manifest = os::read(
      paths::getImageLayerManifestPath(
          flags.docker_store_dir,
          image.layer_ids(image.layer_ids_size() - 1)));

  if (manifest.isError()) {
    return Failure("Failed to read manifest: " + manifest.error());
  }

  Try<::docker::spec::v1::ImageManifest> v1 =
    ::docker::spec::v1::parse(manifest.get());

  if (v1.isError()) {
    return Failure("Failed to parse docker v1 manifest: " + v1.error());
  }

  return ImageInfo{layerDirectories, v1.get()};
}

Future<Nothing> StoreProcess::recover()
{
  return metadataManager->recover();
}

Future<vector<string>> StoreProcess::moveLayers(
    const list<pair<string, string>>& layerPaths)
{
  list<Future<Nothing>> futures;
  foreach (const auto& layerPath, layerPaths) {
    futures.push_back(moveLayer(layerPath));
  }

  return collect(futures)
    .then([layerPaths]() {
      vector<string> layerIds;
      foreach (const auto& layerPath, layerPaths) {
        layerIds.push_back(layerPath.first);
      }

      return layerIds;
    });
}

Future<Image> StoreProcess::storeImage(
    const spec::ImageReference& reference,
    const vector<string>& layerIds)
{
  return metadataManager->put(reference, layerIds);
}

Future<Nothing> StoreProcess::moveLayer(
    const pair<string, string>& layerPath)
{
  if (!os::exists(layerPath.second)) {
    return Failure("Unable to find layer '" + layerPath.first + "' in '" +
                   layerPath.second + "'");
  }

  const string imageLayerPath =
    paths::getImageLayerPath(flags.docker_store_dir, layerPath.first);

  // If image layer path exists, we should remove it and make an empty
  // directory, because os::rename can only have empty or non-existed
  // directory as destination.
  if (os::exists(imageLayerPath)) {
    Try<Nothing> rmdir = os::rmdir(imageLayerPath);
    if (rmdir.isError()) {
      return Failure("Failed to remove existing layer: " + rmdir.error());
    }
  }

  Try<Nothing> mkdir = os::mkdir(imageLayerPath);
  if (mkdir.isError()) {
    return Failure("Failed to create layer path in store for id '" +
                   layerPath.first + "': " + mkdir.error());
  }

  Try<Nothing> status = os::rename(
      layerPath.second,
      imageLayerPath);

  if (status.isError()) {
    return Failure("Failed to move layer '" + layerPath.first +
                   "' to store directory: " + status.error());
  }

  return Nothing();
}

} // namespace docker {
} // namespace slave {
} // namespace internal {
} // namespace mesos {
<commit_msg>Added a NOTE in docker store about caching.<commit_after>// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <list>
#include <vector>

#include <glog/logging.h>

#include <stout/hashmap.hpp>
#include <stout/json.hpp>
#include <stout/os.hpp>

#include <process/collect.hpp>
#include <process/defer.hpp>
#include <process/dispatch.hpp>
#include <process/subprocess.hpp>

#include <mesos/docker/spec.hpp>

#include "common/status_utils.hpp"

#include "slave/containerizer/mesos/provisioner/docker/metadata_manager.hpp"
#include "slave/containerizer/mesos/provisioner/docker/store.hpp"
#include "slave/containerizer/mesos/provisioner/docker/paths.hpp"
#include "slave/containerizer/mesos/provisioner/docker/puller.hpp"

using namespace process;

namespace spec = docker::spec;

using std::list;
using std::pair;
using std::string;
using std::vector;

namespace mesos {
namespace internal {
namespace slave {
namespace docker {

class StoreProcess : public Process<StoreProcess>
{
public:
  StoreProcess(
      const Flags& _flags,
      const Owned<MetadataManager>& _metadataManager,
      const Owned<Puller>& _puller)
    : flags(_flags),
      metadataManager(_metadataManager),
      puller(_puller) {}

  ~StoreProcess() {}

  Future<Nothing> recover();

  Future<ImageInfo> get(const mesos::Image& image);

private:
  Future<Image> _get(
      const spec::ImageReference& reference,
      const Option<Image>& image);

  Future<ImageInfo> __get(const Image& image);

  Future<vector<string>> moveLayers(
      const list<pair<string, string>>& layerPaths);

  Future<Image> storeImage(
      const spec::ImageReference& reference,
      const vector<string>& layerIds);

  Future<Nothing> moveLayer(
      const pair<string, string>& layerPath);

  const Flags flags;
  Owned<MetadataManager> metadataManager;
  Owned<Puller> puller;
  hashmap<string, Owned<Promise<Image>>> pulling;
};

Try<Owned<slave::Store>> Store::create(const Flags& flags)
{
  Try<Owned<Puller>> puller = Puller::create(flags);
  if (puller.isError()) {
    return Error("Failed to create Docker puller: " + puller.error());
  }

  Try<Owned<slave::Store>> store = Store::create(flags, puller.get());
  if (store.isError()) {
    return Error("Failed to create Docker store: " + store.error());
  }

  return store.get();
}

Try<Owned<slave::Store>> Store::create(
    const Flags& flags,
    const Owned<Puller>& puller)
{
  Try<Nothing> mkdir = os::mkdir(flags.docker_store_dir);
  if (mkdir.isError()) {
    return Error("Failed to create Docker store directory: " +
                 mkdir.error());
  }

  mkdir = os::mkdir(paths::getStagingDir(flags.docker_store_dir));
  if (mkdir.isError()) {
    return Error("Failed to create Docker store staging directory: " +
                 mkdir.error());
  }

  Try<Owned<MetadataManager>> metadataManager = MetadataManager::create(flags);
  if (metadataManager.isError()) {
    return Error(metadataManager.error());
  }

  Owned<StoreProcess> process(
      new StoreProcess(flags, metadataManager.get(), puller));

  return Owned<slave::Store>(new Store(process));
}

Store::Store(const Owned<StoreProcess>& _process) : process(_process)
{
  spawn(CHECK_NOTNULL(process.get()));
}

Store::~Store()
{
  terminate(process.get());
  wait(process.get());
}

Future<Nothing> Store::recover()
{
  return dispatch(process.get(), &StoreProcess::recover);
}

Future<ImageInfo> Store::get(const mesos::Image& image)
{
  return dispatch(process.get(), &StoreProcess::get, image);
}

Future<ImageInfo> StoreProcess::get(const mesos::Image& image)
{
  if (image.type() != mesos::Image::DOCKER) {
    return Failure("Docker provisioner store only supports Docker images");
  }

  Try<spec::ImageReference> reference =
    spec::parseImageReference(image.docker().name());

  if (reference.isError()) {
    return Failure("Failed to parse docker image '" + image.docker().name() +
                   "': " + reference.error());
  }

  return metadataManager->get(reference.get())
    .then(defer(self(), &Self::_get, reference.get(), lambda::_1))
    .then(defer(self(), &Self::__get, lambda::_1));
}

Future<Image> StoreProcess::_get(
    const spec::ImageReference& reference,
    const Option<Image>& image)
{
  // NOTE: Here, we assume that image layers are not removed without
  // first removing the metadata in the metadata manager first.
  // Otherwise, the image we return here might miss some layers. At
  // the time we introduce cache eviction, we also want to avoid the
  // situation where a layer was returned to the provisioner but is
  // later evicted.
  if (image.isSome()) {
    return image.get();
  }

  Try<string> staging =
    os::mkdtemp(paths::getStagingTempDir(flags.docker_store_dir));

  if (staging.isError()) {
    return Failure("Failed to create a staging directory");
  }

  const string imageReference = stringify(reference);

  if (!pulling.contains(imageReference)) {
    Owned<Promise<Image>> promise(new Promise<Image>());

    Future<Image> future = puller->pull(reference, Path(staging.get()))
      .then(defer(self(), &Self::moveLayers, lambda::_1))
      .then(defer(self(), &Self::storeImage, reference, lambda::_1))
      .onAny(defer(self(), [this, imageReference](const Future<Image>&) {
        pulling.erase(imageReference);
      }))
      .onAny([staging, imageReference]() {
        Try<Nothing> rmdir = os::rmdir(staging.get());
        if (rmdir.isError()) {
          LOG(WARNING) << "Failed to remove staging directory: "
                       << rmdir.error();
        }
      });

    promise->associate(future);
    pulling[imageReference] = promise;

    return promise->future();
  }

  return pulling[imageReference]->future();
}

Future<ImageInfo> StoreProcess::__get(const Image& image)
{
  CHECK_LT(0, image.layer_ids_size());

  vector<string> layerDirectories;
  foreach (const string& layer, image.layer_ids()) {
    layerDirectories.push_back(
        paths::getImageLayerRootfsPath(
            flags.docker_store_dir, layer));
  }

  // Read the manifest from the last layer because all runtime config
  // are merged at the leaf already.
  Try<string> manifest = os::read(
      paths::getImageLayerManifestPath(
          flags.docker_store_dir,
          image.layer_ids(image.layer_ids_size() - 1)));

  if (manifest.isError()) {
    return Failure("Failed to read manifest: " + manifest.error());
  }

  Try<::docker::spec::v1::ImageManifest> v1 =
    ::docker::spec::v1::parse(manifest.get());

  if (v1.isError()) {
    return Failure("Failed to parse docker v1 manifest: " + v1.error());
  }

  return ImageInfo{layerDirectories, v1.get()};
}

Future<Nothing> StoreProcess::recover()
{
  return metadataManager->recover();
}

Future<vector<string>> StoreProcess::moveLayers(
    const list<pair<string, string>>& layerPaths)
{
  list<Future<Nothing>> futures;
  foreach (const auto& layerPath, layerPaths) {
    futures.push_back(moveLayer(layerPath));
  }

  return collect(futures)
    .then([layerPaths]() {
      vector<string> layerIds;
      foreach (const auto& layerPath, layerPaths) {
        layerIds.push_back(layerPath.first);
      }

      return layerIds;
    });
}

Future<Image> StoreProcess::storeImage(
    const spec::ImageReference& reference,
    const vector<string>& layerIds)
{
  return metadataManager->put(reference, layerIds);
}

Future<Nothing> StoreProcess::moveLayer(
    const pair<string, string>& layerPath)
{
  if (!os::exists(layerPath.second)) {
    return Failure("Unable to find layer '" + layerPath.first + "' in '" +
                   layerPath.second + "'");
  }

  const string imageLayerPath =
    paths::getImageLayerPath(flags.docker_store_dir, layerPath.first);

  // If image layer path exists, we should remove it and make an empty
  // directory, because os::rename can only have empty or non-existed
  // directory as destination.
  if (os::exists(imageLayerPath)) {
    Try<Nothing> rmdir = os::rmdir(imageLayerPath);
    if (rmdir.isError()) {
      return Failure("Failed to remove existing layer: " + rmdir.error());
    }
  }

  Try<Nothing> mkdir = os::mkdir(imageLayerPath);
  if (mkdir.isError()) {
    return Failure("Failed to create layer path in store for id '" +
                   layerPath.first + "': " + mkdir.error());
  }

  Try<Nothing> status = os::rename(
      layerPath.second,
      imageLayerPath);

  if (status.isError()) {
    return Failure("Failed to move layer '" + layerPath.first +
                   "' to store directory: " + status.error());
  }

  return Nothing();
}

} // namespace docker {
} // namespace slave {
} // namespace internal {
} // namespace mesos {
<|endoftext|>