本文整理汇总了C++中PropertyDescription类的典型用法代码示例。如果您正苦于以下问题:C++ PropertyDescription类的具体用法?C++ PropertyDescription怎么用?C++ PropertyDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PropertyDescription类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Task
//-------------------------------------------------------------------------------------
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: WARNING_MSG
//-------------------------------------------------------------------------------------
void Base::createCellData(void)
{
if(!scriptModule_->hasCell() || !installCellDataAttr())
{
if(scriptModule_->getCellPropertyDescriptions().size() > 0)
{
if(!scriptModule_->hasCell())
{
WARNING_MSG(fmt::format("{}::createCellData: do not create cellData, cannot find the cellapp script({})!\n",
scriptModule_->getName(), scriptModule_->getName()));
}
}
return;
}
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule_->getCellPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
for(; iter != propertyDescrs.end(); ++iter)
{
PropertyDescription* propertyDescription = iter->second;
DataType* dataType = propertyDescription->getDataType();
if(dataType)
{
PyObject* pyObj = propertyDescription->newDefaultVal();
PyDict_SetItemString(cellDataDict_, propertyDescription->getName(), pyObj);
Py_DECREF(pyObj);
}
else
{
ERROR_MSG(fmt::format("{}::createCellData: {} PropertyDescription the dataType is NULL.\n",
this->scriptName(), propertyDescription->getName()));
}
SCRIPT_ERROR_CHECK();
}
// 初始化cellEntity的位置和方向变量
PyObject* position = PyTuple_New(3);
PyTuple_SET_ITEM(position, 0, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(position, 1, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(position, 2, PyFloat_FromDouble(0.0));
PyObject* direction = PyTuple_New(3);
PyTuple_SET_ITEM(direction, 0, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(direction, 1, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(direction, 2, PyFloat_FromDouble(0.0));
PyDict_SetItemString(cellDataDict_, "position", position);
PyDict_SetItemString(cellDataDict_, "direction", direction);
Py_DECREF(position);
Py_DECREF(direction);
SCRIPT_ERROR_CHECK();
}
示例3: ADD_POSDIR_TO_STREAM
//-------------------------------------------------------------------------------------
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;
}
示例4: PyObject_GetAttrString
//-------------------------------------------------------------------------------------
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();
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(PyDict_Contains(cellDataDict_, key) > 0)
{
PyObject* pyVal = PyDict_GetItemString(cellDataDict_, attrname);
(*s) << propertyDescription->getUType();
log.push_back(propertyDescription->getUType());
propertyDescription->getDataType()->addToStream(s, pyVal);
DEBUG_PERSISTENT_PROPERTY("addCellPersistentsDataToStream", attrname);
}
else if(PyDict_Contains(pydict, key) > 0)
{
(*s) << propertyDescription->getUType();
log.push_back(propertyDescription->getUType());
propertyDescription->getDataType()->addToStream(s, PyDict_GetItem(pydict, key));
DEBUG_PERSISTENT_PROPERTY("addBasePersistentsDataToStream", attrname);
}
else
{
CRITICAL_MSG("%s::addPersistentsDataToStream: %d not found Persistent[%s].\n",
this->getScriptName(), this->getID(), attrname);
}
Py_DECREF(key);
}
}
Py_XDECREF(pydict);
}
示例5: addCellDataToStream
//-------------------------------------------------------------------------------------
void Base::addCellDataToStream(uint32 flags, MemoryStream* s)
{
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule_->getCellPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
for(; iter != propertyDescrs.end(); iter++)
{
PropertyDescription* propertyDescription = iter->second;
if((flags & propertyDescription->getFlags()) > 0)
{
PyObject* pyVal = PyDict_GetItemString(cellDataDict_, propertyDescription->getName());
(*s) << propertyDescription->getUType();
propertyDescription->getDataType()->addToStream(s, pyVal);
}
}
}
示例6: PyDict_New
//-------------------------------------------------------------------------------------
PyObject* Base::createCellDataDict(uint32 flags)
{
PyObject* cellData = PyDict_New();
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule_->getCellPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
for(; iter != propertyDescrs.end(); iter++)
{
PropertyDescription* propertyDescription = iter->second;
if((flags & propertyDescription->getFlags()) > 0)
{
PyObject* pyVal = PyDict_GetItemString(cellDataDict_, propertyDescription->getName());
PyDict_SetItemString(cellData, propertyDescription->getName(), pyVal);
}
}
return cellData;
}
示例7: ERROR_MSG
//-------------------------------------------------------------------------------------
void EntityComponent::initProperty(bool isReload)
{
ScriptDefModule::PROPERTYDESCRIPTION_MAP* oldpropers = NULL;
if (isReload)
{
ScriptDefModule* pOldScriptDefModule =
EntityDef::findOldScriptModule(pComponentDescrs_->getName());
if (!pOldScriptDefModule)
{
ERROR_MSG(fmt::format("{}::initProperty: not found old_module!\n",
pComponentDescrs_->getName()));
KBE_ASSERT(false && "EntityComponent::initProperty: not found old_module");
}
oldpropers = &pOldScriptDefModule->getPropertyDescrs();
}
const ScriptDefModule::PROPERTYDESCRIPTION_MAP* pPropertyDescrs = pChildPropertyDescrs();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = pPropertyDescrs->begin();
for (; iter != pPropertyDescrs->end(); ++iter)
{
PropertyDescription* propertyDescription = iter->second;
DataType* dataType = propertyDescription->getDataType();
if (oldpropers)
{
ScriptDefModule::PROPERTYDESCRIPTION_MAP::iterator olditer = oldpropers->find(iter->first);
if (olditer != oldpropers->end())
{
if (strcmp(olditer->second->getDataType()->getName(),
propertyDescription->getDataType()->getName()) == 0 &&
strcmp(olditer->second->getDataType()->getName(),
propertyDescription->getDataType()->getName()) == 0)
continue;
}
}
if (dataType)
{
PyObject* defObj = propertyDescription->newDefaultVal();
PyObject_SetAttrString(static_cast<PyObject*>(this),
propertyDescription->getName(), defObj);
Py_DECREF(defObj);
/* DEBUG_MSG(fmt::format("EntityComponent::"#CLASS": added [{}] property ref={}.\n",
propertyDescription->getName(), defObj->ob_refcnt));*/
}
else
{
ERROR_MSG(fmt::format("EntityComponent::initProperty: {} dataType is NULL.\n",
propertyDescription->getName()));
}
}
}
示例8: PyObject_GetAttrString
//-------------------------------------------------------------------------------------
void Entity::addCellDataToStream(uint32 flags, MemoryStream* mstream)
{
PyObject* cellData = PyObject_GetAttrString(this, "__dict__");
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs =
scriptModule_->getCellPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
for(; iter != propertyDescrs.end(); iter++)
{
PropertyDescription* propertyDescription = iter->second;
if((flags & propertyDescription->getFlags()) > 0)
{
PyObject* pyVal = PyDict_GetItemString(cellData, propertyDescription->getName());
(*mstream) << propertyDescription->getUType();
propertyDescription->getDataType()->addToStream(mstream, pyVal);
}
}
Py_XDECREF(cellData);
SCRIPT_ERROR_CHECK();
}
示例9: ERROR_MSG
//-------------------------------------------------------------------------------------
void ClientObject::onUpdatePropertys(MemoryStream& s)
{
ENTITY_ID eid;
s >> eid;
Entity* entity = pEntities_->find(eid);
if(entity == NULL)
{
s.opfini();
ERROR_MSG(boost::format("ClientObject::onUpdatePropertys: not found entity(%1%).\n") % eid);
return;
}
if(s.wpos() > 0)
{
ENTITY_PROPERTY_UID uid;
s >> uid;
// 如果是位置或者朝向信息则
switch(uid)
{
case ENTITY_BASE_PROPERTY_UTYPE_POSITION_XYZ:
break;
case ENTITY_BASE_PROPERTY_UTYPE_DIRECTION_ROLL_PITCH_YAW:
break;
case ENTITY_BASE_PROPERTY_UTYPE_SPACEID:
{
SPACE_ID spaceID;
s >> spaceID;
//entity->spaceID(spaceID);
}
break;
};
PropertyDescription* pPropertyDescription = entity->getScriptModule()->findClientPropertyDescription(uid);
PyObject* pyobj = pPropertyDescription->createFromStream(&s);
PyObject_SetAttrString(entity, pPropertyDescription->getName(), pyobj);
Py_DECREF(pyobj);
}
示例10: PyDict_SetItemString
//-------------------------------------------------------------------------------------
void Base::createCellData(void)
{
if(!installCellDataAttr())
return;
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule_->getCellPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
for(; iter != propertyDescrs.end(); iter++)
{
PropertyDescription* propertyDescription = iter->second;
DataType* dataType = propertyDescription->getDataType();
if(dataType)
{
PyObject* pyObj = propertyDescription->newDefaultVal();
PyDict_SetItemString(cellDataDict_, propertyDescription->getName(), pyObj);
}
else
{
ERROR_MSG("Base::createCellData: %s PropertyDescription the dataType is NULL.\n",
propertyDescription->getName());
}
}
// 初始化cellEntity的位置和方向变量
PyObject* position = PyTuple_New(3);
PyTuple_SET_ITEM(position, 0, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(position, 1, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(position, 2, PyFloat_FromDouble(0.0));
PyObject* direction = PyTuple_New(3);
PyTuple_SET_ITEM(direction, 0, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(direction, 1, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(direction, 2, PyFloat_FromDouble(0.0));
PyDict_SetItemString(cellDataDict_, "position", position);
PyDict_SetItemString(cellDataDict_, "direction", direction);
}
示例11: PyObject_GetAttrString
//-------------------------------------------------------------------------------------
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();
}
示例12: addPositionAndDirectionToStream
//-------------------------------------------------------------------------------------
void Base::addCellDataToStream(uint32 flags, MemoryStream* s, bool useAliasID)
{
addPositionAndDirectionToStream(*s, useAliasID);
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule_->getCellPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
for(; iter != propertyDescrs.end(); ++iter)
{
PropertyDescription* propertyDescription = iter->second;
if(flags == 0 || (flags & propertyDescription->getFlags()) > 0)
{
PyObject* pyVal = PyDict_GetItemString(cellDataDict_, propertyDescription->getName());
if(useAliasID && scriptModule_->usePropertyDescrAlias())
{
(*s) << propertyDescription->aliasIDAsUint8();
}
else
{
(*s) << propertyDescription->getUType();
}
if(!propertyDescription->getDataType()->isSameType(pyVal))
{
ERROR_MSG(fmt::format("{}::addCellDataToStream: {}({}) not is ({})!\n", this->scriptName(),
propertyDescription->getName(), (pyVal ? pyVal->ob_type->tp_name : "unknown"), propertyDescription->getDataType()->getName()));
PyObject* pydefval = propertyDescription->getDataType()->parseDefaultStr("");
propertyDescription->getDataType()->addToStream(s, pydefval);
Py_DECREF(pydefval);
}
else
{
propertyDescription->getDataType()->addToStream(s, pyVal);
}
if (PyErr_Occurred())
{
PyErr_PrintEx(0);
DEBUG_MSG(fmt::format("{}::addCellDataToStream: {} is error!\n", this->scriptName(),
propertyDescription->getName()));
}
}
}
}
示例13: tableName
//-------------------------------------------------------------------------------------
bool EntityTableRedis::initialize(ScriptDefModule* sm, std::string name)
{
// 获取表名
tableName(name);
// 找到所有存储属性并且创建出所有的字段
ScriptDefModule::PROPERTYDESCRIPTION_MAP& pdescrsMap = sm->getPersistentPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = pdescrsMap.begin();
std::string hasUnique = "";
for(; iter != pdescrsMap.end(); ++iter)
{
PropertyDescription* pdescrs = iter->second;
EntityTableItem* pETItem = this->createItem(pdescrs->getDataType()->getName());
pETItem->pParentTable(this);
pETItem->utype(pdescrs->getUType());
pETItem->tableName(this->tableName());
bool ret = pETItem->initialize(pdescrs, pdescrs->getDataType(), pdescrs->getName());
if(!ret)
{
delete pETItem;
return false;
}
tableItems_[pETItem->utype()].reset(pETItem);
tableFixedOrderItems_.push_back(pETItem);
}
// 特殊处理, 数据库保存方向和位置
if(sm->hasCell())
{
ENTITY_PROPERTY_UID posuid = ENTITY_BASE_PROPERTY_UTYPE_POSITION_XYZ;
ENTITY_PROPERTY_UID diruid = ENTITY_BASE_PROPERTY_UTYPE_DIRECTION_ROLL_PITCH_YAW;
Network::FixedMessages::MSGInfo* msgInfo =
Network::FixedMessages::getSingleton().isFixed("Property::position");
if(msgInfo != NULL)
{
posuid = msgInfo->msgid;
msgInfo = NULL;
}
msgInfo = Network::FixedMessages::getSingleton().isFixed("Property::direction");
if(msgInfo != NULL)
{
diruid = msgInfo->msgid;
msgInfo = NULL;
}
EntityTableItem* pETItem = this->createItem("VECTOR3");
pETItem->pParentTable(this);
pETItem->utype(posuid);
pETItem->tableName(this->tableName());
pETItem->itemName("position");
tableItems_[pETItem->utype()].reset(pETItem);
tableFixedOrderItems_.push_back(pETItem);
pETItem = this->createItem("VECTOR3");
pETItem->pParentTable(this);
pETItem->utype(diruid);
pETItem->tableName(this->tableName());
pETItem->itemName("direction");
tableItems_[pETItem->utype()].reset(pETItem);
tableFixedOrderItems_.push_back(pETItem);
}
init_db_item_name();
return true;
}