本文整理汇总了C++中NF_SHARE_PTR::AddProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ NF_SHARE_PTR::AddProperty方法的具体用法?C++ NF_SHARE_PTR::AddProperty怎么用?C++ NF_SHARE_PTR::AddProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NF_SHARE_PTR
的用法示例。
在下文中一共展示了NF_SHARE_PTR::AddProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool NFCElementInfoModule::Load(rapidxml::xml_node<>* attrNode, NF_SHARE_PTR<NFILogicClass> pLogicClass)
{
//attrNode is the node of a object
std::string strConfigID = attrNode->first_attribute("ID")->value();
if (strConfigID.empty())
{
NFASSERT(0, strConfigID, __FILE__, __FUNCTION__);
return false;
}
if (ExistElement(strConfigID))
{
NFASSERT(0, strConfigID, __FILE__, __FUNCTION__);
return false;
}
NF_SHARE_PTR<ElementConfigInfo> pElementInfo(NF_NEW ElementConfigInfo());
AddElement(strConfigID, pElementInfo);
//can find all configid by class name
pLogicClass->AddConfigName(strConfigID);
//ElementConfigInfo* pElementInfo = CreateElement( strConfigID, pElementInfo );
NF_SHARE_PTR<NFIPropertyManager> pElementPropertyManager = pElementInfo->GetPropertyManager();
NF_SHARE_PTR<NFIRecordManager> pElementRecordManager = pElementInfo->GetRecordManager();
//1.add property
//2.set the default value of them
NF_SHARE_PTR<NFIPropertyManager> pClassPropertyManager = pLogicClass->GetPropertyManager();
NF_SHARE_PTR<NFIRecordManager> pClassRecordManager = pLogicClass->GetRecordManager();
if (pClassPropertyManager.get() && pClassRecordManager.get())
{
NF_SHARE_PTR<NFIProperty> pProperty = pClassPropertyManager->First();
while (pProperty.get())
{
pElementPropertyManager->AddProperty(NFGUID(), pProperty);
pProperty = pClassPropertyManager->Next();
}
NF_SHARE_PTR<NFIRecord> pRecord = pClassRecordManager->First();
while (pRecord.get())
{
pElementRecordManager->AddRecord(NFGUID(), pRecord->GetName(), pRecord->GetInitData(), pRecord->GetKeyState(), pRecord->GetInitDesc(), pRecord->GetTag(), pRecord->GetRelatedRecord(), pRecord->GetRows(), pRecord->GetPublic(), pRecord->GetPrivate(), pRecord->GetSave(), pRecord->GetView(), pRecord->GetIndex());
pRecord = pClassRecordManager->Next();
}
}
//3.set the config value to them
//const char* pstrConfigID = attrNode->first_attribute( "ID" );
for (rapidxml::xml_attribute<>* pAttribute = attrNode->first_attribute(); pAttribute; pAttribute = pAttribute->next_attribute())
{
const char* pstrConfigName = pAttribute->name();
const char* pstrConfigValue = pAttribute->value();
//printf( "%s : %s\n", pstrConfigName, pstrConfigValue );
NF_SHARE_PTR<NFIProperty> temProperty = pElementPropertyManager->GetElement(pstrConfigName);
if (!temProperty)
{
continue;
}
NFIDataList::TData var;
TDATA_TYPE eType = temProperty->GetType();
switch (eType)
{
case TDATA_INT:
{
if (!LegalNumber(pstrConfigValue))
{
NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__);
}
var.SetInt(lexical_cast<NFINT64>(pstrConfigValue));
}
break;
case TDATA_FLOAT:
{
if (strlen(pstrConfigValue) <= 0)
{
NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__);
}
var.SetFloat((double)atof(pstrConfigValue));
}
break;
case TDATA_STRING:
var.SetString(pstrConfigValue);
break;
case TDATA_OBJECT:
{
if (strlen(pstrConfigValue) <= 0)
{
NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__);
}
var.SetObject(NFGUID());
}
break;
default:
//.........这里部分代码省略.........
示例2: ConvertPBToPropertyManager
bool NFCCreateRoleModule::ConvertPBToPropertyManager(const NFMsg::ObjectPropertyList& pPropertyData, NF_SHARE_PTR<NFIPropertyManager> pProps)
{
if (pProps)
{
for (int i = 0; i < pPropertyData.property_int_list_size(); ++i)
{
const NFMsg::PropertyInt& xData = pPropertyData.property_int_list(i);
if (pProps->ExistElement(xData.property_name()))
{
pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_INT);
}
pProps->SetPropertyInt(xData.property_name(), xData.data());
}
for (int i = 0; i < pPropertyData.property_float_list_size(); ++i)
{
const NFMsg::PropertyFloat& xData = pPropertyData.property_float_list(i);
if (pProps->ExistElement(xData.property_name()))
{
pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_FLOAT);
}
pProps->SetPropertyFloat(xData.property_name(), xData.data());
}
for (int i = 0; i < pPropertyData.property_string_list_size(); ++i)
{
const NFMsg::PropertyString& xData = pPropertyData.property_string_list(i);
if (pProps->ExistElement(xData.property_name()))
{
pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_STRING);
}
pProps->SetPropertyString(xData.property_name(), xData.data());
}
for (int i = 0; i < pPropertyData.property_object_list_size(); ++i)
{
const NFMsg::PropertyObject& xData = pPropertyData.property_object_list(i);
if (pProps->ExistElement(xData.property_name()))
{
pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_OBJECT);
}
pProps->SetPropertyObject(xData.property_name(), NFGUID(xData.data().svrid(), xData.data().index()));
}
for (int i = 0; i < pPropertyData.property_vector2_list_size(); ++i)
{
const NFMsg::PropertyVector2& xData = pPropertyData.property_vector2_list(i);
if (pProps->ExistElement(xData.property_name()))
{
pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_VECTOR2);
}
pProps->SetPropertyVector2(xData.property_name(), NFVector2(xData.data().x(), xData.data().y()));
}
for (int i = 0; i < pPropertyData.property_vector3_list_size(); ++i)
{
const NFMsg::PropertyVector3& xData = pPropertyData.property_vector3_list(i);
if (pProps->ExistElement(xData.property_name()))
{
pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_VECTOR3);
}
pProps->SetPropertyVector3(xData.property_name(), NFVector3(xData.data().x(), xData.data().y(), xData.data().z()));
}
}
return true;
}