EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
APIServer.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Aknor Jaden, adapted from ImageServer.h authored by caytchen
24 */
25 
26 #ifndef __APISERVER__H__INCL__
27 #define __APISERVER__H__INCL__
28 
29 #include "APIServerListener.h"
30 
31 class APIServiceManager;
32 
44 class APIServer : public Singleton<APIServer>
45 {
46 public:
47  APIServer();
48  void Run();
49  void Stop();
50  void CreateServices(const PyServiceMgr &services);
51 
52  std::string& url();
53 
54  std::tr1::shared_ptr<std::vector<char> > GetXML(const APICommandCall * pAPICommandCall);
55 
56  // used when the ImageServer can't find the image requested
57  // this way we don't have to transfer over all the static NPC images
58  static const char *const FallbackURL;
59 
60 private:
61  void RunInternal();
62 
63  std::unique_ptr<boost::asio::detail::thread> _ioThread;
64  std::unique_ptr<boost::asio::io_context> _io;
65  std::unique_ptr<APIServerListener> _listener;
66  std::string _url;
67  std::string _basePath;
68  boost::asio::detail::mutex _limboLock;
69  bool runonce;
70 
71  std::tr1::shared_ptr<std::string> m_xmlString;
72 
73  std::map<std::string, APIServiceManager *> m_APIServiceManagers; // We own these
74 
75  class Lock
76  {
77  public:
78  Lock(boost::asio::detail::mutex& mutex);
79  ~Lock();
80  private:
81  boost::asio::detail::mutex& _mutex;
82  };
83 };
84 
85 #define sAPIServer \
86  ( APIServer::get() )
87 
88 #endif // __APISERVER__H__INCL__
static const char *const FallbackURL
Definition: APIServer.h:58
std::string & url()
Definition: APIServer.cpp:100
std::map< std::string, APIServiceManager * > m_APIServiceManagers
Definition: APIServer.h:73
std::tr1::shared_ptr< std::vector< char > > GetXML(const APICommandCall *pAPICommandCall)
Definition: APIServer.cpp:67
void Run()
Definition: APIServer.cpp:105
std::unique_ptr< boost::asio::detail::thread > _ioThread
Definition: APIServer.h:63
std::map< std::string, std::string > APICommandCall
Handles queries from external clients for many kinds of returned xml structures according to CCP's AP...
Definition: APIServer.h:44
Generic Base Class used to derive classes for specific service handlers (character, corporation, etc)
std::string _basePath
Definition: APIServer.h:67
bool runonce
Definition: APIServer.h:69
std::unique_ptr< boost::asio::io_context > _io
Definition: APIServer.h:64
boost::asio::detail::mutex _limboLock
Definition: APIServer.h:68
Template used for singleton classes.
Definition: Singleton.h:43
void CreateServices(const PyServiceMgr &services)
Definition: APIServer.cpp:49
void RunInternal()
Definition: APIServer.cpp:116
std::string _url
Definition: APIServer.h:66
void Stop()
Definition: APIServer.cpp:110
std::tr1::shared_ptr< std::string > m_xmlString
Definition: APIServer.h:71
Lock(boost::asio::detail::mutex &mutex)
Definition: APIServer.cpp:123
boost::asio::detail::mutex & _mutex
Definition: APIServer.h:81
std::unique_ptr< APIServerListener > _listener
Definition: APIServer.h:65