EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PyServiceMgr Class Reference

#include "PyServiceMgr.h"

Collaboration diagram for PyServiceMgr:

Classes

struct  BoundObj
 

Public Member Functions

 PyServiceMgr (uint32 nodeID, EntityList &elist)
 
 ~PyServiceMgr ()
 
void Initalize (double startTime)
 
void Close ()
 
void Process ()
 
void RegisterService (const std::string &name, PyService *svc)
 
PyServiceLookupService (const std::string &name)
 
uint32 GetNodeID () const
 
PySubStructBindObject (Client *pClient, PyBoundObject *pObj, PyDict *dict=nullptr, PyDict *oid=nullptr)
 
PyBoundObjectFindBoundObject (uint32 bindID)
 
void ClearBoundObject (uint32 bindID)
 
void BoundObjectVec (std::vector< BoundObj > &vec)
 

Public Attributes

LSCServicelsc_service
 
ObjCacheServicecache_service
 

Protected Types

typedef std::map< uint32,
BoundObj
ObjectsBoundMap
 
typedef ObjectsBoundMap::iterator ObjectsBoundMapItr
 

Protected Attributes

std::map< std::string,
PyService * > 
m_svcList
 
ObjectsBoundMap m_boundObjects
 
uint32 m_nodeID
 
uint32 m_nextBindID
 

Detailed Description

Definition at line 47 of file PyServiceMgr.h.

Member Typedef Documentation

typedef std::map<uint32, BoundObj> PyServiceMgr::ObjectsBoundMap
protected

Definition at line 87 of file PyServiceMgr.h.

typedef ObjectsBoundMap::iterator PyServiceMgr::ObjectsBoundMapItr
protected

Definition at line 88 of file PyServiceMgr.h.

Constructor & Destructor Documentation

PyServiceMgr::PyServiceMgr ( uint32  nodeID,
EntityList elist 
)

Definition at line 37 of file PyServiceMgr.cpp.

References EntityList::SetService().

38 : lsc_service(nullptr),
39  cache_service(nullptr),
40  m_nextBindID(100),
41  m_nodeID(nodeID)
42 {
43  elist.SetService(this);
44 }
LSCService * lsc_service
Definition: PyServiceMgr.h:77
ObjCacheService * cache_service
Definition: PyServiceMgr.h:78
void SetService(PyServiceMgr *svc)
Definition: EntityList.h:84
uint32 m_nodeID
Definition: PyServiceMgr.h:91
uint32 m_nextBindID
Definition: PyServiceMgr.h:92

Here is the call graph for this function:

PyServiceMgr::~PyServiceMgr ( )

Definition at line 46 of file PyServiceMgr.cpp.

References Close().

46  {
47  // these crash (segfault) on exit, and i dont know why (but not sure if it's needed...)
48  //SafeDelete(lsc_service);
49  //SafeDelete(cache_service);
50 
51  Close();
52 }

Here is the call graph for this function:

Member Function Documentation

PySubStruct * PyServiceMgr::BindObject ( Client pClient,
PyBoundObject pObj,
PyDict dict = nullptr,
PyDict oid = nullptr 
)

Definition at line 213 of file PyServiceMgr.cpp.

References _log, PyBoundObject::_SetNodeBindID(), Client::AddBindID(), PyBoundObject::bindID(), PyServiceMgr::BoundObj::client, PyBoundObject::GetBindStr(), GetFileTimeNow(), PyBoundObject::GetName(), Client::GetName(), PyTuple::items, PyBoundObject::m_bindID, m_boundObjects, m_nextBindID, PyBoundObject::m_nodeID, m_nodeID, PyServiceMgr::BoundObj::object, PyStatic, and PyDict::SetItemString().

Referenced by PyService::Handle_MachoBindObject().

213  {
214  if (pClient == nullptr) {
215  _log(SERVICE__ERROR, "PyServiceMgr::BindObject() - Tried to bind a NULL client.");
216  return new PySubStruct(PyStatic.NewNone());
217  }
218 
219  if (pObj == nullptr) {
220  _log(SERVICE__ERROR, "PyServiceMgr::BindObject() - Tried to bind a NULL object.");
221  return new PySubStruct(PyStatic.NewNone());
222  }
223 
225 
226  // save bindID in client for ease of release later
227  pClient->AddBindID(m_nextBindID);
228 
229  BoundObj obj = BoundObj();
230  obj.client = pClient;
231  obj.object = pObj;
232  m_boundObjects[pObj->bindID()] = obj;
233 
234  std::string bindStr = pObj->GetBindStr();
235  _log(SERVICE__MESSAGE, "Service Mgr Binding %s to node %u:%u for %s", \
236  pObj->GetName(), pObj->m_nodeID, pObj->m_bindID, pClient->GetName());
237 
238  PyLong* time = new PyLong(GetFileTimeNow());
239 
240  PyTuple* tuple(nullptr);
241  if (dict == nullptr) {
242  tuple = new PyTuple(2);
243  tuple->items[0] = new PyString(bindStr);
244  tuple->items[1] = time;
245  } else {
246  tuple = new PyTuple(3);
247  tuple->items[0] = new PyString(bindStr);
248  tuple->items[1] = dict;
249  tuple->items[2] = time;
250  }
251 
252  if (oid != nullptr) {
253  PyDict *oidDict = new PyDict();
254  oidDict->SetItemString(bindStr.c_str(), time);
255  oid->SetItemString("OID+", oidDict);
256  }
257 
258  return new PySubStruct(new PySubStream(tuple));
259 }
ObjectsBoundMap m_boundObjects
Definition: PyServiceMgr.h:89
#define _log(type, fmt,...)
Definition: logsys.h:124
Python string.
Definition: PyRep.h:430
Python's dictionary.
Definition: PyRep.h:719
storage_type items
Definition: PyRep.h:814
Python tuple.
Definition: PyRep.h:567
std::string GetBindStr() const
#define PyStatic
Definition: PyRep.h:1209
const char * GetName() const
Definition: Client.h:94
void AddBindID(uint32 bindID)
Definition: Client.h:436
double GetFileTimeNow()
Definition: utils_time.cpp:84
void _SetNodeBindID(uint32 nodeID, uint32 bindID)
Definition: PyBoundObject.h:51
uint32 m_nodeID
Definition: PyServiceMgr.h:91
uint32 m_nextBindID
Definition: PyServiceMgr.h:92
uint32 bindID() const
Definition: PyBoundObject.h:40
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812
const char * GetName() const
Definition: PyBoundObject.h:44
Python long integer.
Definition: PyRep.h:261

Here is the call graph for this function:

Here is the caller graph for this function:

void PyServiceMgr::BoundObjectVec ( std::vector< BoundObj > &  vec)

Definition at line 284 of file PyServiceMgr.cpp.

References m_boundObjects.

Referenced by Command_bindList().

285 {
286  for (auto cur : m_boundObjects)
287  vec.push_back(cur.second);
288 }
ObjectsBoundMap m_boundObjects
Definition: PyServiceMgr.h:89

Here is the caller graph for this function:

void PyServiceMgr::ClearBoundObject ( uint32  bindID)

Definition at line 268 of file PyServiceMgr.cpp.

References _log, PyBoundObject::GetBindStr(), PyBoundObject::GetName(), m_boundObjects, and PyBoundObject::Release().

Referenced by Client::Handle_Notify(), and Client::~Client().

269 {
270  std::map<uint32, BoundObj>::iterator itr = m_boundObjects.find(bindID);
271  if (itr == m_boundObjects.end()) {
272  _log(SERVICE__ERROR, "PyServiceMgr::ClearBoundObject() - Unable to find bound object %u to release.", bindID);
273  return;
274  }
275 
276  PyBoundObject *bo(itr->second.object);
277 
278  _log(SERVICE__MESSAGE, "Service Mgr Clearing bound object %s at %s", bo->GetName(), bo->GetBindStr().c_str());
279 
280  m_boundObjects.erase(itr);
281  bo->Release();
282 }
ObjectsBoundMap m_boundObjects
Definition: PyServiceMgr.h:89
#define _log(type, fmt,...)
Definition: logsys.h:124

Here is the call graph for this function:

Here is the caller graph for this function:

void PyServiceMgr::Close ( )

Definition at line 54 of file PyServiceMgr.cpp.

References _log, PyBoundObject::GetName(), is_log_enabled, PyBoundObject::m_bindID, m_boundObjects, PyBoundObject::m_nodeID, m_svcList, SafeDelete(), and sLog.

Referenced by main(), and ~PyServiceMgr().

54  {
55  for (auto cur : m_svcList)
56  SafeDelete(cur.second);
57 
58  PyBoundObject* bo(nullptr);
59  for (auto cur : m_boundObjects) {
60  bo = cur.second.object;
61  if (is_log_enabled(SERVICE__MESSAGE))
62  _log(SERVICE__MESSAGE, "Service Mgr Destructor: Deleting %s at node %u:%u", \
63  bo->GetName(), bo->m_nodeID, bo->m_bindID);
64  SafeDelete(bo);
65  }
66 
67  sLog.Warning(" PyServiceMgr", "Services Manager has been closed." );
68 }
ObjectsBoundMap m_boundObjects
Definition: PyServiceMgr.h:89
#define _log(type, fmt,...)
Definition: logsys.h:124
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
#define is_log_enabled(type)
Definition: logsys.h:78
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
std::map< std::string, PyService * > m_svcList
Definition: PyServiceMgr.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

PyBoundObject * PyServiceMgr::FindBoundObject ( uint32  bindID)

Definition at line 261 of file PyServiceMgr.cpp.

References m_boundObjects.

Referenced by Client::Handle_CallReq().

261  {
262  std::map<uint32, BoundObj>::iterator itr = m_boundObjects.find(bindID);
263  if (itr != m_boundObjects.end())
264  return itr->second.object;
265  return nullptr;
266 }
ObjectsBoundMap m_boundObjects
Definition: PyServiceMgr.h:89

Here is the caller graph for this function:

uint32 PyServiceMgr::GetNodeID ( ) const
inline
void PyServiceMgr::Initalize ( double  startTime)

Definition at line 70 of file PyServiceMgr.cpp.

References cache_service, GetTimeMSeconds(), ObjCacheService::GiveCache(), ObjCacheService::IsCacheLoaded(), m_svcList, PyDecRef, PyStatic, PyDict::SetItemString(), and sLog.

Referenced by main().

71 {
72  PyString* str(new PyString( "machoNet.serviceInfo"));
73 
74  // look into this. what's it for? are we using it right? missing anything?
75  // client calls this, then loads cached data upon return. not sure how this is used yet
76  if (!cache_service->IsCacheLoaded(str)) {
77  PyDict *dict = new PyDict();
78  /* ServiceCallGPCS.py:197
79  * where = self.machoNet.serviceInfo[service]
80  * if where:
81  * for (k, v,) in self.machoNet.serviceInfo.iteritems():
82  * if ((k != service) and (v and (v.startswith(where) or where.startswith(v)))):
83  * nodeID = self.services.get(k, None)
84  * break
85  */
86  dict->SetItemString("account", new PyString("station"));
87  dict->SetItemString("bookmark", new PyString("station"));
88  dict->SetItemString("contractMgr", new PyString("station"));
89  dict->SetItemString("gangSvc", new PyString("station"));
90  dict->SetItemString("trademgr", new PyString("station"));
91  dict->SetItemString("tutorialSvc", new PyString("station"));
92  dict->SetItemString("slash", new PyString("station"));
93  dict->SetItemString("wormholeMgr", new PyString("location"));
94  dict->SetItemString("LSC", new PyString("location"));
95  dict->SetItemString("station", new PyString("location"));
96  dict->SetItemString("config", new PyString("locationPreferred"));
97  dict->SetItemString("scanMgr", new PyString("solarsystem"));
98  dict->SetItemString("keeper", new PyString("solarsystem"));
99  dict->SetItemString("agentMgr", PyStatic.NewNone());
100  dict->SetItemString("aggressionMgr", PyStatic.NewNone());
101  dict->SetItemString("alert", PyStatic.NewNone());
102  dict->SetItemString("allianceRegistry", PyStatic.NewNone());
103  dict->SetItemString("authentication", PyStatic.NewNone());
104  dict->SetItemString("billMgr", PyStatic.NewNone());
105  dict->SetItemString("billingMgr", PyStatic.NewNone());
106  dict->SetItemString("beyonce", PyStatic.NewNone());
107  dict->SetItemString("BSD", PyStatic.NewNone());
108  dict->SetItemString("cache", PyStatic.NewNone());
109  dict->SetItemString("calendarProxy", PyStatic.NewNone());
110  dict->SetItemString("corporationSvc", PyStatic.NewNone());
111  dict->SetItemString("corpStationMgr", PyStatic.NewNone());
112  dict->SetItemString("corpmgr", PyStatic.NewNone());
113  dict->SetItemString("corpRegistry", PyStatic.NewNone());
114  dict->SetItemString("counter", PyStatic.NewNone());
115  dict->SetItemString("certificateMgr", PyStatic.NewNone());
116  dict->SetItemString("charFittingMgr", PyStatic.NewNone());
117  dict->SetItemString("charmgr", PyStatic.NewNone());
118  dict->SetItemString("charUnboundMgr", PyStatic.NewNone());
119  dict->SetItemString("clientStatLogger", PyStatic.NewNone());
120  dict->SetItemString("clientStatsMgr", PyStatic.NewNone());
121  dict->SetItemString("clones", PyStatic.NewNone());
122  dict->SetItemString("damageTracker", PyStatic.NewNone());
123  dict->SetItemString("dataconfig", PyStatic.NewNone());
124  dict->SetItemString("DB", PyStatic.NewNone());
125  dict->SetItemString("DB2", PyStatic.NewNone());
126  dict->SetItemString("debug", PyStatic.NewNone());
127  dict->SetItemString("director", PyStatic.NewNone());
128  dict->SetItemString("dogma", PyStatic.NewNone());
129  dict->SetItemString("dogmaIM", PyStatic.NewNone());
130  dict->SetItemString("droneMgr", PyStatic.NewNone());
131  dict->SetItemString("dungeon", PyStatic.NewNone());
132  dict->SetItemString("dungeonExplorationMgr", PyStatic.NewNone());
133  dict->SetItemString("effectCompiler", PyStatic.NewNone());
134  dict->SetItemString("emailreader", PyStatic.NewNone());
135  dict->SetItemString("entity", PyStatic.NewNone());
136  dict->SetItemString("factory", PyStatic.NewNone());
137  dict->SetItemString("facWarMgr", PyStatic.NewNone());
138  dict->SetItemString("fleetMgr", PyStatic.NewNone());
139  dict->SetItemString("fleetObjectHandler", PyStatic.NewNone());
140  dict->SetItemString("fleetProxy", PyStatic.NewNone());
141  dict->SetItemString("gagger", PyStatic.NewNone());
142  dict->SetItemString("gangSvcObjectHandler", PyStatic.NewNone());
143  dict->SetItemString("http", PyStatic.NewNone());
144  dict->SetItemString("i2", PyStatic.NewNone());
145  dict->SetItemString("infoGatheringMgr", PyStatic.NewNone());
146  dict->SetItemString("insuranceSvc", PyStatic.NewNone());
147  dict->SetItemString("invbroker", PyStatic.NewNone());
148  dict->SetItemString("jumpbeaconsvc", PyStatic.NewNone());
149  dict->SetItemString("jumpCloneSvc", PyStatic.NewNone());
150  dict->SetItemString("languageSvc", PyStatic.NewNone());
151  dict->SetItemString("lien", PyStatic.NewNone());
152  dict->SetItemString("lookupSvc", PyStatic.NewNone());
153  dict->SetItemString("lootSvc", PyStatic.NewNone());
154  dict->SetItemString("LPSvc", PyStatic.NewNone());
155  dict->SetItemString("LPStore", PyStatic.NewNone());
156  dict->SetItemString("machoNet", PyStatic.NewNone());
157  dict->SetItemString("map", PyStatic.NewNone());
158  dict->SetItemString("market", PyStatic.NewNone());
159  dict->SetItemString("npcSvc", PyStatic.NewNone());
160  dict->SetItemString("objectCaching", PyStatic.NewNone());
161  dict->SetItemString("onlineStatus", PyStatic.NewNone());
162  dict->SetItemString("posMgr", PyStatic.NewNone());
163  dict->SetItemString("ram", PyStatic.NewNone());
164  dict->SetItemString("repairSvc", PyStatic.NewNone());
165  dict->SetItemString("reprocessingSvc", PyStatic.NewNone());
166  dict->SetItemString("pathfinder", PyStatic.NewNone());
167  dict->SetItemString("petitioner", PyStatic.NewNone());
168  dict->SetItemString("planetMgr", PyStatic.NewNone());
169  dict->SetItemString("search", PyStatic.NewNone());
170  dict->SetItemString("sessionMgr", PyStatic.NewNone());
171  dict->SetItemString("ship", PyStatic.NewNone());
172  dict->SetItemString("skillMgr", PyStatic.NewNone());
173  dict->SetItemString("sovMgr", PyStatic.NewNone());
174  dict->SetItemString("standing2", PyStatic.NewNone());
175  dict->SetItemString("stationSvc", PyStatic.NewNone());
176  dict->SetItemString("userSvc", PyStatic.NewNone());
177  dict->SetItemString("voiceMgr", PyStatic.NewNone());
178  dict->SetItemString("voucher", PyStatic.NewNone());
179  dict->SetItemString("warRegistry", PyStatic.NewNone());
180  dict->SetItemString("watchdog", PyStatic.NewNone());
181  dict->SetItemString("zsystem", PyStatic.NewNone());
182  dict->SetItemString("encounterSpawnServer", PyStatic.NewNone());
183  dict->SetItemString("netStateServer", PyStatic.NewNone());
184  dict->SetItemString("zActionServer", PyStatic.NewNone());
185 
186  //register it
187  cache_service->GiveCache(str, (PyRep **)&dict);
188 
189  PyDecRef(str);
190  }
191 
192  sLog.Cyan(" PyServiceMgr", "%u services registered in %.3fms", m_svcList.size(),(GetTimeMSeconds() - startTime));
193 }
Base Python wire object.
Definition: PyRep.h:66
Python string.
Definition: PyRep.h:430
Python's dictionary.
Definition: PyRep.h:719
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
double GetTimeMSeconds()
Definition: utils_time.cpp:104
#define PyStatic
Definition: PyRep.h:1209
#define PyDecRef(op)
Definition: PyRep.h:57
std::map< std::string, PyService * > m_svcList
Definition: PyServiceMgr.h:84
void GiveCache(const PyRep *objectID, PyRep **contents)
ObjCacheService * cache_service
Definition: PyServiceMgr.h:78
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812
bool IsCacheLoaded(const PyRep *objectID) const

Here is the call graph for this function:

Here is the caller graph for this function:

PyService * PyServiceMgr::LookupService ( const std::string &  name)

Definition at line 204 of file PyServiceMgr.cpp.

References _log, and m_svcList.

Referenced by Client::Handle_CallReq(), Client::UndockFromStation(), and Client::~Client().

204  {
205  std::map<std::string, PyService*>::const_iterator itr = m_svcList.find(name);
206  if (itr != m_svcList.end())
207  return itr->second;
208 
209  _log(SERVICE__ERROR, "PyServiceMgr::LookupService() - Service %s not found in list.", name.c_str());
210  return nullptr;
211 }
#define _log(type, fmt,...)
Definition: logsys.h:124
std::map< std::string, PyService * > m_svcList
Definition: PyServiceMgr.h:84

Here is the caller graph for this function:

void PyServiceMgr::Process ( )

Definition at line 195 of file PyServiceMgr.cpp.

195  {
196  //well... we used to have something to do, but not right now...
197 }
void PyServiceMgr::RegisterService ( const std::string &  name,
PyService svc 
)

Definition at line 199 of file PyServiceMgr.cpp.

References m_svcList.

Referenced by main().

200 {
201  m_svcList[name] = svc;
202 }
std::map< std::string, PyService * > m_svcList
Definition: PyServiceMgr.h:84

Here is the caller graph for this function:

Member Data Documentation

ObjectsBoundMap PyServiceMgr::m_boundObjects
protected

Definition at line 89 of file PyServiceMgr.h.

Referenced by BindObject(), BoundObjectVec(), ClearBoundObject(), Close(), and FindBoundObject().

uint32 PyServiceMgr::m_nextBindID
protected

Definition at line 92 of file PyServiceMgr.h.

Referenced by BindObject().

uint32 PyServiceMgr::m_nodeID
protected

Definition at line 91 of file PyServiceMgr.h.

Referenced by BindObject(), and GetNodeID().

std::map<std::string, PyService*> PyServiceMgr::m_svcList
protected

Definition at line 84 of file PyServiceMgr.h.

Referenced by Close(), Initalize(), LookupService(), and RegisterService().


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