//------------------------------------------------------------------------------------- void Entity::writeToDB(void* data) { CALLBACK_ID* pCallbackID = static_cast<CALLBACK_ID*>(data); CALLBACK_ID callbackID = 0; if(pCallbackID) callbackID = *pCallbackID; onWriteToDB(); backupCellData(); Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject(); (*pBundle).newMessage(BaseappInterface::onCellWriteToDBCompleted); (*pBundle) << this->getID(); (*pBundle) << callbackID; if(this->getBaseMailbox()) { this->getBaseMailbox()->postMail((*pBundle)); } Mercury::Bundle::ObjPool().reclaimObject(pBundle); }
//------------------------------------------------------------------------------------- void Base::onCellWriteToDBCompleted() { PyObject* pyResult = PyObject_CallMethod(this, const_cast<char*>("onPreArchive"), const_cast<char*>("")); if(pyResult != NULL) Py_DECREF(pyResult); else PyErr_PrintEx(0); hasDB(true); onWriteToDB(); isArchiveing_ = false; MemoryStream* s = MemoryStream::ObjPool().createObject(); addPersistentsDataToStream(ED_FLAG_ALL, s); Components::COMPONENTS cts = Components::getSingleton().getComponents(DBMGR_TYPE); Components::ComponentInfos* dbmgrinfos = NULL; if(cts.size() > 0) dbmgrinfos = &(*cts.begin()); if(dbmgrinfos == NULL || dbmgrinfos->pChannel == NULL || dbmgrinfos->cid == 0) { ERROR_MSG("Base::onCellWriteToDBCompleted: not found dbmgr!\n"); return; } Mercury::Bundle bundle; bundle.newMessage(DbmgrInterface::writeEntity); bundle << this->getID(); bundle << this->getScriptModule()->getUType(); bundle.append(*s); bundle.send(Baseapp::getSingleton().getNetworkInterface(), dbmgrinfos->pChannel); MemoryStream::ObjPool().reclaimObject(s); }