本文整理汇总了C++中gd::Project::GetObjectsCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Project::GetObjectsCount方法的具体用法?C++ Project::GetObjectsCount怎么用?C++ Project::GetObjectsCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::Project
的用法示例。
在下文中一共展示了Project::GetObjectsCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateBehaviorsSharedData
void Layout::UpdateBehaviorsSharedData(gd::Project & project)
{
std::vector < gd::String > allBehaviorsTypes;
std::vector < gd::String > allBehaviorsNames;
//Search in objects for the type and the name of every behaviors.
for (std::size_t i = 0;i<initialObjects.size();++i)
{
std::vector < gd::String > objectBehaviors = initialObjects[i]->GetAllBehaviorNames();
for (unsigned int j = 0;j<objectBehaviors.size();++j)
{
gd::Behavior & behavior = initialObjects[i]->GetBehavior(objectBehaviors[j]);
allBehaviorsTypes.push_back(behavior.GetTypeName());
allBehaviorsNames.push_back(behavior.GetName());
}
}
for (std::size_t i = 0;i<project.GetObjectsCount();++i)
{
std::vector < gd::String > objectBehaviors = project.GetObject(i).GetAllBehaviorNames();
for (std::size_t j = 0;j<objectBehaviors.size();++j)
{
gd::Behavior & behavior = project.GetObject(i).GetBehavior(objectBehaviors[j]);
allBehaviorsTypes.push_back(behavior.GetTypeName());
allBehaviorsNames.push_back(behavior.GetName());
}
}
//Create non existing shared data
for (std::size_t i = 0;i<allBehaviorsTypes.size() && i < allBehaviorsNames.size();++i)
{
if ( behaviorsInitialSharedDatas.find(allBehaviorsNames[i]) == behaviorsInitialSharedDatas.end() )
{
std::shared_ptr<gd::BehaviorsSharedData> behaviorsSharedDatas = project.CreateBehaviorSharedDatas(allBehaviorsTypes[i]);
if ( behaviorsSharedDatas )
{
behaviorsSharedDatas->SetName(allBehaviorsNames[i]);
behaviorsInitialSharedDatas[behaviorsSharedDatas->GetName()] = behaviorsSharedDatas;
}
}
}
//Remove useless shared data:
//First construct the list of existing shared data.
std::vector < gd::String > allSharedData;
for (std::map < gd::String, std::shared_ptr<gd::BehaviorsSharedData> >::const_iterator it = behaviorsInitialSharedDatas.begin();
it != behaviorsInitialSharedDatas.end();++it)
{
allSharedData.push_back(it->first);
}
//Then delete shared data not linked to a behavior
for (std::size_t i = 0;i<allSharedData.size();++i)
{
if ( std::find(allBehaviorsNames.begin(), allBehaviorsNames.end(), allSharedData[i]) == allBehaviorsNames.end() )
behaviorsInitialSharedDatas.erase(allSharedData[i]);
}
}
示例2: GetTypeOfBehavior
gd::String GD_CORE_API GetTypeOfBehavior(const gd::Project & project, const gd::Layout & layout, gd::String name, bool searchInGroups)
{
for (std::size_t i = 0;i<layout.GetObjectsCount();++i)
{
vector < gd::String > behaviors = layout.GetObject(i).GetAllBehaviorNames();
for (std::size_t j = 0;j<behaviors.size();++j)
{
if ( layout.GetObject(i).GetBehavior(behaviors[j]).GetName() == name )
return layout.GetObject(i).GetBehavior(behaviors[j]).GetTypeName();
}
}
for (std::size_t i = 0;i<project.GetObjectsCount();++i)
{
vector < gd::String > behaviors = project.GetObject(i).GetAllBehaviorNames();
for (std::size_t j = 0;j<behaviors.size();++j)
{
if ( project.GetObject(i).GetBehavior(behaviors[j]).GetName() == name )
return project.GetObject(i).GetBehavior(behaviors[j]).GetTypeName();
}
}
return "";
}