EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PyCallable.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: Zhur
24 */
25 
26 
27 #ifndef __PYCALLABLE_H__
28 #define __PYCALLABLE_H__
29 
30 #include "ServiceDB.h"
31 
32 class Client;
33 
34 class PyRep;
35 class PyTuple;
36 class PyDict;
37 
38 class PyServiceMgr;
39 class PyCallStream;
40 
42 {
43 public:
44  PyCallArgs( Client *c, PyTuple* tup, PyDict* dict );
45  ~PyCallArgs();
46 
47  void Dump( LogType type ) const;
48 
49  Client* const client; //we do not own this
50  PyTuple* tuple; //we own this, but it may be taken
51  std::map<std::string, PyRep*> byname; //we own this, but elements may be taken.
52 };
53 
54 class PyResult
55 {
56 public:
57  PyResult();
58  PyResult( PyRep* result );
59  PyResult( PyRep* result, PyDict* namedResult );
60  PyResult( const PyResult& oth );
61  ~PyResult();
62 
63  PyResult& operator=( const PyResult& oth );
64 
67 };
68 
70 {
71 public:
73  {
74  public:
75  virtual ~CallDispatcher() {}
76 
77  virtual PyResult Dispatch( const std::string& method_name, PyCallArgs& call ) = 0;
78  };
79 
80  PyCallable();
81  virtual ~PyCallable();
82 
83  //returns ownership:
84  virtual PyResult Call( const std::string& method, PyCallArgs& args );
85 
86 protected:
88 
89 private:
90  CallDispatcher* m_serviceDispatch; //must not be NULL after constructor, we do not own this.
91 };
92 
93 #endif // __PYCALLABLE_H__
Base Python wire object.
Definition: PyRep.h:66
PyDict * ssNamedResult
Definition: PyCallable.h:66
CallDispatcher * m_serviceDispatch
Definition: PyCallable.h:90
Python's dictionary.
Definition: PyRep.h:719
std::map< std::string, PyRep * > byname
Definition: PyCallable.h:51
Python tuple.
Definition: PyRep.h:567
void _SetCallDispatcher(CallDispatcher *d)
Definition: PyCallable.h:87
* args
PyRep * ssResult
Definition: PyCallable.h:65
PyResult & operator=(const PyResult &oth)
Definition: PyCallable.cpp:110
virtual PyResult Dispatch(const std::string &method_name, PyCallArgs &call)=0
virtual ~PyCallable()
Definition: PyCallable.cpp:35
Client *const client
Definition: PyCallable.h:49
Definition: Client.h:66
PyCallArgs(Client *c, PyTuple *tup, PyDict *dict)
Definition: PyCallable.cpp:59
LogType
Definition: logsys.h:59
void Dump(LogType type) const
Definition: PyCallable.cpp:81
virtual PyResult Call(const std::string &method, PyCallArgs &args)
Definition: PyCallable.cpp:39
PyTuple * tuple
Definition: PyCallable.h:50