⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 audio.h

📁 在LINUX下运行的仿真机器人服务器源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
// -*-c++-*-/***************************************************************************                                   audio.h                       Classes for building audio messages                             -------------------    begin                : 27-JAN-2002    copyright            : (C) 2002 by The RoboCup Soccer Server                            Maintenance Group.    email                : sserver-admin@lists.sourceforge.net ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU LGPL as published by the Free Software  * *   Foundation; either version 2 of the License, or (at your option) any  * *   later version.                                                        * *                                                                         * ***************************************************************************/#ifndef _AUDIO_H_#define _AUDIO_H_#include "sender.h"#include "observer.h"#include "param.h"#include "types.h"#include <string>#include <map>#include <list>#include <rcssbase/lib/factory.hpp>class Coach;class OnlineCoach;class Player;class Stadium;class RemoteClient;namespace rcss{    namespace clang    {        class Msg;    }// Each Listener has an AudioSender for converting the message// from machine format into a format the client can understand.  The// AudioSender is in charge of gathering the relevant data// required for the message (such as the timestamp, name of the// sender, etc) including the addition of any noise (e.g. direction of// sender rounded to int).  It then delegates the task of serializing// this data to a generic serializer, which knows how to convert the// supplied data into client format.//// The reason it is done this way is because it allows us to seperatly// modify the data or the format.  If you which to change the data// being sent to the client, (e.g. round to int rather than cast to// int) then you change the AudioSender.  If you wish to change// the format (such as quoting say messages), you need to change the// generic Serializer that AudioSender delegates to.    class AudioSender        : protected Sender    {    public:        typedef std::auto_ptr< rcss::AudioSender > Ptr;    protected:        const Stadium& M_stadium;            public:        AudioSender( const Stadium& stadium,                     std::ostream& transport )            : Sender( transport ), M_stadium( stadium )        {}          virtual        ~AudioSender() {}        virtual        void        sendRefAudio( const char* ) {}        virtual        void        sendCoachAudio( const Coach&, const char* ) {}        virtual        void        sendCoachStdAudio( const clang::Msg& ) {}        virtual        void        sendPlayerAudio( const Player&, const char* ) {}        virtual        void        newCycle() {}        virtual        void        focusOn( const Player& ) {}        virtual        void        focusOff() {}        virtual        const Player*        getFocusTarget() const        { return NULL; }        virtual        unsigned int        getFocusCount() const        { return 0; }        virtual        void        setEar( bool, Side, bool, bool )        {}        virtual        void        sendOKClang()        {}        virtual        void        sendErrorNoTeamName( const std::string& )        {}    };    class Listener        : protected BaseObserver< AudioSender >    {    public:        Listener()        {}        Listener( AudioSender& sender )            : BaseObserver< AudioSender >( sender )        {}        Listener( std::auto_ptr< AudioSender > sender )            : BaseObserver< AudioSender >( sender )        {}        ~Listener()        {}        void        setAudioSender( AudioSender& sender )        {            BaseObserver< AudioSender >::setSender( sender );        }        void        setAudioSender( std::auto_ptr< AudioSender > sender )        {            BaseObserver< AudioSender >::setSender( sender );        }        void        sendRefAudio( const char* msg );          void        sendCoachAudio( const Coach& coach, const char* msg );          void        sendCoachStdAudio( const clang::Msg& msg );          void        sendPlayerAudio( const Player& player, const char* msg );        void        newCycle();        void        focusOn( const Player& player );        void        focusOff();        const Player*        getFocusTarget() const        { return sender().getFocusTarget(); }        unsigned int        getFocusCount() const        { return sender().getFocusCount(); }        class NewCycle        {        public:            void            operator()( Listener* listener )            { listener->newCycle(); }        };        void        setEar( bool on, Side side, bool complete, bool partial );        void        sendOKClang();        void        sendErrorNoTeamName( const std::string& team_name );    };    class SerializerPlayer;        class AudioSenderPlayer        : public AudioSender    {    protected:        Player& M_listener;        const SerializerPlayer& M_serializer;    public:        class Params        {        public:            Params( const Stadium& stadium,                    std::ostream& transport,                    Player& listener,                    const SerializerPlayer& serializer )                : m_stadium( stadium ),                  m_transport( transport ),                  m_listener( listener ),                  m_serializer( serializer )            {}            const Stadium& m_stadium;            std::ostream& m_transport;            Player& m_listener;            const SerializerPlayer& m_serializer;        };        typedef Ptr(*Creator)( const Params& );        typedef rcss::lib::Factory< Creator, int > Factory;        static        Factory&        factory();        AudioSenderPlayer( const Params& params )            : AudioSender( params.m_stadium, params.m_transport ),              M_listener( params.m_listener ),              M_serializer( params.m_serializer )        {}        ~AudioSenderPlayer() {}        virtual        void        sendPlayerAudio( const Player& player, const char* msg );        virtual        void        sendSelfAudio( const char* ) {}        virtual        void        sendNonSelfPlayerAudio( const Player&, const char* ) {}        virtual        void        sendOKClang()        {}        virtual        void        sendErrorNoTeamName( const std::string& )        {}    protected:        // These predicate methods allow the send funtions to change the        // data contstruction without having to rewrite the predicate.  It        // also allows you to change the predicate without changing the data        // construction.        virtual        bool         generalPredicate() const;        virtual        bool         coachStdPredicate( const clang::Msg& msg ) const;        virtual        bool         nonSelfPlayerPredicate( const Player& player ) const;        // The post method(s) allow any adjustmets to the listeners state to        // be done, independant of the data contruction        virtual        bool         postNonSelfPlayer( const Player& player );    };    class AudioSenderPlayerv1        : public AudioSenderPlayer    {    public:        AudioSenderPlayerv1( const Params& params )            : AudioSenderPlayer( params )        {}        virtual        ~AudioSenderPlayerv1()        {}        virtual        void        sendRefAudio( const char* msg );        virtual        void        sendCoachAudio( const Coach& coach, const char* msg );        virtual        void        sendCoachStdAudio( const clang::Msg& msg );        virtual        void        sendSelfAudio( const char* msg );        virtual        void        sendNonSelfPlayerAudio( const Player& player, const char* msg );        virtual        void        sendOKClang();        virtual        void        sendErrorNoTeamName( const std::string& team_name );    };    class AudioSenderPlayerv7        : public AudioSenderPlayerv1    {    public:        AudioSenderPlayerv7( const Params& params )            : AudioSenderPlayerv1( params )        {}        virtual        ~AudioSenderPlayerv7()        {}        virtual        void        sendCoachAudio( const Coach& coach, const char* msg );        virtual        void        sendNonSelfPlayerAudio( const Player& player, const char* msg );    };    class AudioSenderPlayerv8        : public AudioSenderPlayerv7    {    protected:        // the containers and pairs below use char* instead of const        // char* as the strings belong to the containers and pairs and        // will be deleted after they are removed. By making the        // non-const, a string needs to be copied to be inserted. I        // know it's a bit of a dodgy safty check, but it's better        // than nothing.  I'll try to make it cleaner later.  Idealy        // we should store them once in a general store and then point        // to that store.  Then we could just delete from that store        // when we are done... More work for later.        typedef const Player*                         player_key_t;        typedef std::pair< player_key_t, char* >   player_key_value_t;        typedef const Coach*                          coach_key_t;        typedef std::pair< coach_key_t, char* >    coach_key_value_t;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -