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

📄 audio.h

📁 2009 ROBOCUP 仿真2DSERVER 源码
💻 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 RCSSSERVER_AUDIO_H#define RCSSSERVER_AUDIO_H#include "sender.h"#include "observer.h"#include "param.h"#include "types.h"#include <string>#include <map>#include <list>#include <rcssbase/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 sendRefereeAudio( 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 sendRefereeAudio( 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();      }    void setEar( bool on,                 Side side,                 bool complete,                 bool partial );    void sendOKClang();    void sendErrorNoTeamName( const std::string & team_name );    class NewCycle {    public:        void operator()( Listener * listener )          {              listener->newCycle();          }    };};class SerializerPlayer;class AudioSenderPlayer    : public AudioSender {protected:    Player& M_listener;    const SerializerPlayer & M_serializer;public:    class Params {    public:        std::ostream & m_transport;        Player & m_listener;        const SerializerPlayer & m_serializer;        const Stadium & m_stadium;        Params( std::ostream & transport,                Player & listener,                const SerializerPlayer & serializer,                const Stadium & stadium )                : m_transport( transport )                , m_listener( listener )                , m_serializer( serializer )                , m_stadium( stadium )          { }    };    typedef Ptr (*Creator)( const Params & );    typedef rcss::Factory< Creator, int > FactoryHolder;    static    FactoryHolder & factory();    AudioSenderPlayer( const Params & params );    ~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 sendRefereeAudio( 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:

⌨️ 快捷键说明

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