EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PyCallableDispatcher< Svc > Class Template Reference

#include "PyServiceCD.h"

Inheritance diagram for PyCallableDispatcher< Svc >:
Collaboration diagram for PyCallableDispatcher< Svc >:

Public Member Functions

 PyCallableDispatcher (Svc *parent)
 
virtual ~PyCallableDispatcher ()
 
void RegisterCall (const char *call_name, CallProc p)
 
virtual PyResult Dispatch (const std::string &method_name, PyCallArgs &call)
 
- Public Member Functions inherited from PyCallable::CallDispatcher
virtual ~CallDispatcher ()
 

Protected Attributes

std::map< std::string, CallProcm_serviceCalls
 
Svc *const m_parent
 

Private Types

typedef PyResult(Svc::* CallProc )(PyCallArgs &call)
 
typedef std::map< std::string,
CallProc >::iterator 
mapitr
 

Detailed Description

template<class Svc>
class PyCallableDispatcher< Svc >

Definition at line 37 of file PyServiceCD.h.

Member Typedef Documentation

template<class Svc >
typedef PyResult(Svc::* PyCallableDispatcher< Svc >::CallProc)(PyCallArgs &call)
private

Definition at line 40 of file PyServiceCD.h.

template<class Svc >
typedef std::map<std::string, CallProc>::iterator PyCallableDispatcher< Svc >::mapitr
private

Definition at line 41 of file PyServiceCD.h.

Constructor & Destructor Documentation

template<class Svc >
PyCallableDispatcher< Svc >::PyCallableDispatcher ( Svc *  parent)
inline

Definition at line 43 of file PyServiceCD.h.

44  : m_parent(parent) {
45  }
Svc *const m_parent
Definition: PyServiceCD.h:74
template<class Svc >
virtual PyCallableDispatcher< Svc >::~PyCallableDispatcher ( )
inlinevirtual

Definition at line 47 of file PyServiceCD.h.

47  {
48  }

Member Function Documentation

template<class Svc >
virtual PyResult PyCallableDispatcher< Svc >::Dispatch ( const std::string &  method_name,
PyCallArgs call 
)
inlinevirtual

Implements PyCallable::CallDispatcher.

Definition at line 55 of file PyServiceCD.h.

References PyCallArgs::client, Client::GetName(), PyCallableDispatcher< Svc >::m_parent, PyCallableDispatcher< Svc >::m_serviceCalls, and sLog.

55  {
56  //this could be done a lot more efficiently with a custom data structure IF NEEDED
57  mapitr res = m_serviceCalls.find(method_name);
58  if (res == m_serviceCalls.end()) {
59  sLog.Error("Server","Unknown call to '%s' by '%s'", method_name.c_str(), call.client->GetName());
60  // list registered calls for named service
61  //if (is_log_enabled(SERVICE__WARNING))
62  // for (auto cur : m_serviceCalls)
63  // _log(SERVICE__WARNING, " %s", cur.first.c_str());
64  return nullptr;
65  }
66 
67  CallProc p = res->second;
68  return (m_parent->*p)(call);
69  }
PyResult(Svc::* CallProc)(PyCallArgs &call)
Definition: PyServiceCD.h:40
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
Svc *const m_parent
Definition: PyServiceCD.h:74
const char * GetName() const
Definition: Client.h:94
Client *const client
Definition: PyCallable.h:49
std::map< std::string, CallProc >::iterator mapitr
Definition: PyServiceCD.h:41
std::map< std::string, CallProc > m_serviceCalls
Definition: PyServiceCD.h:72

Here is the call graph for this function:

template<class Svc >
void PyCallableDispatcher< Svc >::RegisterCall ( const char *  call_name,
CallProc  p 
)
inline

Definition at line 50 of file PyServiceCD.h.

References PyCallableDispatcher< Svc >::m_serviceCalls.

50  {
51  m_serviceCalls[call_name] = p;
52  }
std::map< std::string, CallProc > m_serviceCalls
Definition: PyServiceCD.h:72

Member Data Documentation

template<class Svc >
Svc* const PyCallableDispatcher< Svc >::m_parent
protected

Definition at line 74 of file PyServiceCD.h.

Referenced by PyCallableDispatcher< Svc >::Dispatch().

template<class Svc >
std::map<std::string, CallProc> PyCallableDispatcher< Svc >::m_serviceCalls
protected

The documentation for this class was generated from the following file: