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

#include "CachedObjectMgr.h"

Collaboration diagram for PyCachedObject:

Public Member Functions

 PyCachedObject ()
 
 ~PyCachedObject ()
 
void Dump (FILE *into, const char *pfx, bool contents_too=false)
 
PyObjectEncode ()
 
PyCachedObjectClone () const
 

Public Attributes

int64 timestamp
 
uint32 version
 
uint32 nodeID
 
bool shared
 
PyRepcache
 
bool compressed
 
PyRepobjectID
 

Detailed Description

Definition at line 125 of file CachedObjectMgr.h.

Constructor & Destructor Documentation

PyCachedObject::PyCachedObject ( )

Definition at line 591 of file CachedObjectMgr.cpp.

Referenced by Clone().

592 : timestamp(0),
593  version(0),
594  nodeID(0),
595  shared(false),
596  cache(nullptr),
597  compressed(false),
598  objectID(nullptr)
599 {
600 }

Here is the caller graph for this function:

PyCachedObject::~PyCachedObject ( )

Definition at line 602 of file CachedObjectMgr.cpp.

References cache, objectID, and PySafeDecRef.

603 {
604  PySafeDecRef( cache );
606 }
#define PySafeDecRef(op)
Definition: PyRep.h:61

Member Function Documentation

PyCachedObject * PyCachedObject::Clone ( ) const

Definition at line 608 of file CachedObjectMgr.cpp.

References cache, PyRep::Clone(), compressed, nodeID, objectID, PyCachedObject(), shared, timestamp, and version.

609 {
610  PyCachedObject *res = new PyCachedObject();
611  res->timestamp = timestamp;
612  res->version = version;
613  res->nodeID = nodeID;
614  res->shared = shared;
615  res->cache = (PyBuffer *) cache->Clone();
616  res->compressed = compressed;
617  res->objectID = objectID->Clone();
618  return res;
619 }
virtual PyRep * Clone() const =0
Clones object.
Python buffer.
Definition: PyRep.h:382

Here is the call graph for this function:

void PyCachedObject::Dump ( FILE *  into,
const char *  pfx,
bool  contents_too = false 
)

Definition at line 639 of file CachedObjectMgr.cpp.

References cache, compressed, PyRep::Dump(), nodeID, objectID, PRIu64, shared, timestamp, and version.

640 {
641  std::string s(pfx);
642  s += " ";
643  fprintf(into, "%sCached Object:\n", pfx);
644  fprintf(into, "%s ObjectID:\n", pfx);
645  objectID->Dump(into, s.c_str());
646  fprintf(into, "%s Version Time: %" PRIu64 "\n", pfx, timestamp);
647  fprintf(into, "%s Version: %u\n", pfx, version);
648  fprintf(into, "%s NodeID: %u\n", pfx, nodeID);
649  fprintf(into, "%s Shared: %s\n", pfx, shared?"yes":"no");
650  fprintf(into, "%s Compressed: %s\n", pfx, compressed?"yes":"no");
651  if (contents_too) {
652  fprintf(into, "%s Contents:\n", pfx);
653  cache->Dump(into, s.c_str());
654  }
655 }
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
#define PRIu64
Definition: eve-compat.h:85

Here is the call graph for this function:

PyObject * PyCachedObject::Encode ( )

Definition at line 778 of file CachedObjectMgr.cpp.

References cache, PyRep::Clone(), compressed, PyTuple::items, new_tuple(), nodeID, objectID, shared, timestamp, and version.

Referenced by CachedObjectMgr::GetCachedObject().

779 {
780  PyTuple *arg_tuple = new PyTuple(7);
781  arg_tuple->items[0] = new_tuple(new PyLong(timestamp), new PyInt(version));
782  arg_tuple->items[1] = new PyNone();
783  arg_tuple->items[2] = new PyInt(nodeID);
784  arg_tuple->items[3] = new PyInt(shared?1:0);
785 
786  //compression or not, we want to encode this into bytes so it doesn't
787  //get cloned in object form just to be encoded later
788 /* cache->EncodeData();
789  if (compressed) {
790  uint8 *buf = new uint8[cache->length];
791  uint32 deflen = DeflatePacket(cache->data, cache->length, buf, cache->length);
792  if (deflen == 0 || deflen >= cache->length) {
793  //failed to deflate or it did no good (client checks this)
794  memcpy(buf, cache->data, cache->length);
795  deflen = cache->length;
796  compressed = false;
797  }
798  //buf is consumed:
799  arg_tuple->items[4] = new PyBuffer(&buf, deflen);
800  } else {
801  //TODO: we dont really need to clone this if we can figure out a way to say "this is read only"
802  //or if we can change this encode method to consume the PyCachedObject (which will almost always be the case)
803  arg_tuple->items[4] = cache->Clone();
804  }*/
805  //TODO: we don't really need to clone this if we can figure out a way to say "this is read only"
806  //or if we can change this encode method to consume the PyCachedObject (which will almost always be the case)
807  arg_tuple->items[4] = cache->Clone();
808  arg_tuple->items[5] = new PyInt(compressed?1:0);
809  //same cloning statement as above.
810  arg_tuple->items[6] = objectID->Clone();
811 
812  return new PyObject( "objectCaching.CachedObject", arg_tuple );
813 }
virtual PyRep * Clone() const =0
Clones object.
Python tuple.
Definition: PyRep.h:567
Python object.
Definition: PyRep.h:826
PyTuple * new_tuple(int64 arg1)
Definition: PyRep.cpp:1160
Python's "none".
Definition: PyRep.h:352
Python integer.
Definition: PyRep.h:231
storage_type items
Definition: PyRep.h:628
Python long integer.
Definition: PyRep.h:261

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

PyRep* PyCachedObject::cache
bool PyCachedObject::compressed

Definition at line 147 of file CachedObjectMgr.h.

Referenced by Clone(), Dump(), Encode(), and CachedObjectMgr::GetCachedObject().

uint32 PyCachedObject::nodeID

Definition at line 141 of file CachedObjectMgr.h.

Referenced by Clone(), Dump(), Encode(), and CachedObjectMgr::GetCachedObject().

PyRep* PyCachedObject::objectID
bool PyCachedObject::shared

Definition at line 142 of file CachedObjectMgr.h.

Referenced by Clone(), Dump(), Encode(), and CachedObjectMgr::GetCachedObject().

int64 PyCachedObject::timestamp

Definition at line 137 of file CachedObjectMgr.h.

Referenced by Clone(), Dump(), Encode(), and CachedObjectMgr::GetCachedObject().

uint32 PyCachedObject::version

Definition at line 138 of file CachedObjectMgr.h.

Referenced by Clone(), Dump(), Encode(), and CachedObjectMgr::GetCachedObject().


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