src/core/serverapi/binaries.h
00001 //------------------------------------------------------------------------------
00002 // binaries.h
00003 //------------------------------------------------------------------------------
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301, USA.
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
00022 //------------------------------------------------------------------------------
00023 #ifndef __BINARIES_H_
00024 #define __BINARIES_H_
00025 
00026 #include "ini/ini.h"
00027 #include "global.h"
00028 #include <QHash>
00029 #include <QObject>
00030 #include <QString>
00031 
00032 class EnginePlugin;
00033 class Message;
00034 
00035 class MAIN_EXPORT Binaries : public QObject
00036 {
00037         public:
00038                 Binaries(const EnginePlugin *plugin);
00039 
00046                 virtual QString                                 clientBinary(Message& message) const { return obtainBinary(configKeyClientBinary(), Client, message); }
00047 
00054                 virtual QString                                 clientWorkingDirectory(Message& message) const;
00055 
00056                 virtual QString                                 configKeyClientBinary() const { return "BinaryPath"; }
00057                 virtual QString                                 configKeyOfflineBinary() const { return configKeyClientBinary(); }
00058                 virtual QString                                 configKeyServerBinary() const { return "ServerBinaryPath"; }
00059 
00066                 virtual QString                                 offlineGameBinary(Message& message) const { return obtainBinary(configKeyOfflineBinary(), Offline, message); }
00067 
00082                 virtual QString                                 offlineGameWorkingDirectory(Message& message) const;
00083 
00090                 const EnginePlugin*             plugin() const { return enginePlugin; }
00091 
00098                 virtual QString                                 serverBinary(Message& message) const { return obtainBinary(configKeyServerBinary(), TServer, message); }
00099 
00114                 virtual QString                                 serverWorkingDirectory(Message& message) const;
00115 
00116         protected:
00117                 enum BinaryType
00118                 {
00119                         Client,
00120                         Offline,
00121                         TServer
00122                 };
00123 
00131                 typedef QHash<BinaryType, QString>      BinaryNamesDictionary;
00132 
00133                 static BinaryNamesDictionary            binaryNames;
00134 
00135                 QString                                                         obtainBinary(const QString& configKey, BinaryType binaryType, Message& message) const;
00136 
00137                 const EnginePlugin                                      *enginePlugin;
00138 };
00139 
00140 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator