本文整理汇总了C++中PropertyDescription::addPersistentToStream方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyDescription::addPersistentToStream方法的具体用法?C++ PropertyDescription::addPersistentToStream怎么用?C++ PropertyDescription::addPersistentToStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyDescription
的用法示例。
在下文中一共展示了PropertyDescription::addPersistentToStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//-------------------------------------------------------------------------------------
SyncEntityStreamTemplateHandler::SyncEntityStreamTemplateHandler(Network::NetworkInterface & networkInterface):
Task(),
networkInterface_(networkInterface)
{
networkInterface.dispatcher().addTask(this);
MemoryStream accountDefMemoryStream;
ENGINE_COMPONENT_INFO& dbcfg = g_kbeSrvConfig.getDBMgr();
ScriptDefModule* scriptModule = EntityDef::findScriptModule(dbcfg.dbAccountEntityScriptType);
if(scriptModule != NULL)
{
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule->getPersistentPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
if(scriptModule->hasCell())
{
Vector3 pos, dir;
ADD_POSDIR_TO_STREAM(accountDefMemoryStream, pos, dir);
}
for(; iter != propertyDescrs.end(); ++iter)
{
PropertyDescription* propertyDescription = iter->second;
accountDefMemoryStream << propertyDescription->getUType();
propertyDescription->addPersistentToStream(&accountDefMemoryStream, NULL);
}
}
}
示例2: process
//-------------------------------------------------------------------------------------
bool SyncEntityStreamTemplateHandler::process()
{
Components::COMPONENTS& cts = Components::getSingleton().getComponents(DBMGR_TYPE);
Network::Channel* pChannel = NULL;
if(cts.size() > 0)
{
Components::COMPONENTS::iterator ctiter = cts.begin();
if((*ctiter).pChannel == NULL)
return true;
pChannel = (*ctiter).pChannel;
}
if(pChannel == NULL)
return true;
MemoryStream accountDefMemoryStream;
ENGINE_COMPONENT_INFO& dbcfg = g_kbeSrvConfig.getDBMgr();
ScriptDefModule* scriptModule = EntityDef::findScriptModule(dbcfg.dbAccountEntityScriptType);
if(scriptModule == NULL)
{
delete this;
return false;
}
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule->getPersistentPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
if(scriptModule->hasCell())
{
Vector3 pos, dir;
ADD_POSDIR_TO_STREAM(accountDefMemoryStream, pos, dir);
}
for(; iter != propertyDescrs.end(); ++iter)
{
PropertyDescription* propertyDescription = iter->second;
accountDefMemoryStream << propertyDescription->getUType();
propertyDescription->addPersistentToStream(&accountDefMemoryStream, NULL);
}
Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
(*pBundle).newMessage(DbmgrInterface::syncEntityStreamTemplate);
(*pBundle).append(accountDefMemoryStream);
pChannel->send(pBundle);
delete this;
return false;
}
示例3: addPersistentsDataToStream
//-------------------------------------------------------------------------------------
void Base::addPersistentsDataToStream(uint32 flags, MemoryStream* s)
{
std::vector<ENTITY_PROPERTY_UID> log;
// 再将base中存储属性取出
PyObject* pydict = PyObject_GetAttrString(this, "__dict__");
// 先将celldata中的存储属性取出
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule_->getPersistentPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
if(scriptModule_->hasCell())
{
addPositionAndDirectionToStream(*s);
}
for(; iter != propertyDescrs.end(); ++iter)
{
PropertyDescription* propertyDescription = iter->second;
std::vector<ENTITY_PROPERTY_UID>::const_iterator finditer =
std::find(log.begin(), log.end(), propertyDescription->getUType());
if(finditer != log.end())
continue;
const char* attrname = propertyDescription->getName();
if(propertyDescription->isPersistent() && (flags & propertyDescription->getFlags()) > 0)
{
PyObject *key = PyUnicode_FromString(attrname);
if(cellDataDict_ != NULL && PyDict_Contains(cellDataDict_, key) > 0)
{
PyObject* pyVal = PyDict_GetItemString(cellDataDict_, attrname);
if(!propertyDescription->getDataType()->isSameType(pyVal))
{
CRITICAL_MSG(fmt::format("{}::addPersistentsDataToStream: {} persistent[{}] type(curr_py: {} != {}) is error.\n",
this->scriptName(), this->id(), attrname, (pyVal ? pyVal->ob_type->tp_name : "unknown"), propertyDescription->getDataType()->getName()));
}
else
{
(*s) << propertyDescription->getUType();
log.push_back(propertyDescription->getUType());
propertyDescription->addPersistentToStream(s, pyVal);
DEBUG_PERSISTENT_PROPERTY("addCellPersistentsDataToStream", attrname);
}
}
else if(PyDict_Contains(pydict, key) > 0)
{
PyObject* pyVal = PyDict_GetItem(pydict, key);
if(!propertyDescription->getDataType()->isSameType(pyVal))
{
CRITICAL_MSG(fmt::format("{}::addPersistentsDataToStream: {} persistent[{}] type(curr_py: {} != {}) is error.\n",
this->scriptName(), this->id(), attrname, (pyVal ? pyVal->ob_type->tp_name : "unknown"), propertyDescription->getDataType()->getName()));
}
else
{
(*s) << propertyDescription->getUType();
log.push_back(propertyDescription->getUType());
propertyDescription->addPersistentToStream(s, pyVal);
DEBUG_PERSISTENT_PROPERTY("addBasePersistentsDataToStream", attrname);
}
}
else
{
CRITICAL_MSG(fmt::format("{}::addPersistentsDataToStream: {} not found Persistent[{}].\n",
this->scriptName(), this->id(), attrname));
}
Py_DECREF(key);
}
SCRIPT_ERROR_CHECK();
}
Py_XDECREF(pydict);
SCRIPT_ERROR_CHECK();
}