Changeset 44:f5222044879c in xplra for src


Ignore:
Timestamp:
02/15/13 18:51:58 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Created the Globals class

Location:
src/plugin/src/xplra
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/plugin/src/xplra/ListenThread.h

    r38 r44  
    4444//------------------------------------------------------------------------------
    4545
    46 class MessageWindow;
     46class Globals;
    4747
    4848//------------------------------------------------------------------------------
     
    5858private:
    5959    /**
    60      * The version of X-Plane.
     60     * The global objects.
    6161     */
    62     int xplaneVersion;
    63 
    64     /**
    65      * The version of the XPLM library.
    66      */
    67     int xplmVersion;
    68 
    69     /**
    70      * The message window for showing messages.
    71      */
    72     MessageWindow& messageWindow;
     62    Globals& globals;
    7363
    7464    /**
     
    9282     * Construct the thread.
    9383     */
    94     ListenThread(int xplaneVersion, int xplmVersion,
    95                  MessageWindow& messageWindow);
     84    ListenThread(Globals& globals);
    9685
    9786    /**
    98      * Get the versions
     87     * Get the globals
    9988     */
    100     void getVersions(int& xplane, int& xplm) const;
    101 
    102     /**
    103      * Get the message window.
    104      */
    105     MessageWindow& getMessageWindow();
     89    Globals& getGlobals();
    10690
    10791    /**
     
    120104//------------------------------------------------------------------------------
    121105
    122 inline ListenThread::ListenThread(int xplaneVersion, int xplmVersion,
    123                                   MessageWindow& messageWindow) :
     106inline ListenThread::ListenThread(Globals& globals) :
    124107    Thread(true),
    125     xplaneVersion(xplaneVersion),
    126     xplmVersion(xplmVersion),
    127     messageWindow(messageWindow),
     108    globals(globals),
    128109    quitEvent(&waiter)
    129110{
     
    132113//------------------------------------------------------------------------------
    133114
    134 inline void ListenThread::getVersions(int& xplane, int& xplm) const
     115inline Globals& ListenThread::getGlobals()
    135116{
    136     xplane = xplaneVersion;
    137     xplm = xplmVersion;
    138 }
    139 
    140 //------------------------------------------------------------------------------
    141 
    142 inline MessageWindow& ListenThread::getMessageWindow()
    143 {
    144     return messageWindow;
     117    return globals;
    145118}
    146119
  • src/plugin/src/xplra/Makefile.am

    r43 r44  
    1818        SetMultiDataRefRequest.cc       \
    1919        ReloadPluginsRequest.cc         \
     20        Globals.cc                      \
    2021        MessageWindow.cc                \
    2122        MessageRequest.cc               \
     
    3738        SetMultiDataRefRequest.h        \
    3839        ReloadPluginsRequest.h          \
     40        Globals.h                       \
    3941        MessageWindow.h                 \
    4042        MessageRequest.h                \
  • src/plugin/src/xplra/ServerThread.cc

    r39 r44  
    4141#include "ReloadPluginsRequest.h"
    4242#include "MessageRequest.h"
     43#include "Globals.h"
    4344
    4445#include <hu/varadiistvan/xplcommon/Util.h>
     
    400401    int xplmVersion = 0;
    401402
    402     listenThread.getVersions(xplaneVersion, xplmVersion);
     403    listenThread.getGlobals().getVersions(xplaneVersion, xplmVersion);
    403404
    404405    stream.writeU8(Protocol::RESULT_OK);
     
    433434        stream.writeU8(Protocol::RESULT_INVALID_DURATION);
    434435    } else {
    435         MessageRequest request(listenThread.getMessageWindow(), message, duration);
     436        MessageRequest request(listenThread.getGlobals().getMessageWindow(),
     437                               message, duration);
    436438        if (!requestQueue.execute(&request)) return false;
    437439
  • src/plugin/src/xplra/plugin.cc

    r43 r44  
    3131#include "ListenThread.h"
    3232
    33 #include "MessageWindow.h"
    34 #include "Menu.h"
     33#include "Globals.h"
    3534
    3635#include <hu/varadiistvan/xplcommon/Util.h>
     
    3837
    3938#include <XPLMDefs.h>
    40 #include <XPLMUtilities.h>
    4139#include <XPLMProcessing.h>
    4240#include <XPLMMenus.h>
     
    5351
    5452using xplra::ListenThread;
    55 using xplra::MessageWindow;
    56 using xplra::Menu;
     53using xplra::Globals;
    5754
    5855using hu::varadiistvan::xplcommon::Util;
     
    6158
    6259/**
    63  * The window to display messages from the clients.
     60 * The global objects.
    6461 */
    65 static MessageWindow* messageWindow = 0;
    66 
    67 /**
    68  * The menu.
    69  */
    70 static Menu* menu = 0;
     62static Globals* globals = 0;
    7163
    7264/**
     
    10092    // XPLMRegisterFlightLoopCallback(&callback, 5.0, 0);
    10193
    102     int xplaneVersion = 0;
    103     int xplmVersion = 0;
    104     XPLMHostApplicationID hostID = 0;
    105     XPLMGetVersions(&xplaneVersion, &xplmVersion, &hostID);
     94    globals = new Globals();
    10695
    107     messageWindow = new MessageWindow();
    108     menu = new Menu(*messageWindow);
    109 
    110     listenThread = new ListenThread(xplaneVersion, xplmVersion,
    111                                     *messageWindow);
     96    listenThread = new ListenThread(*globals);
    11297    listenThread->start();
    11398}
     
    134119    }
    135120
    136     delete menu; menu = 0;
    137     delete messageWindow; messageWindow = 0;
     121    delete globals; globals = 0;
    138122}
    139123
Note: See TracChangeset for help on using the changeset viewer.