本文整理汇总了C++中ObjectPool::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectPool::Get方法的具体用法?C++ ObjectPool::Get怎么用?C++ ObjectPool::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectPool
的用法示例。
在下文中一共展示了ObjectPool::Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Push
void Profiler::Push(cstring name)
{
assert(name && started);
Entry* new_e = entry_pool.Get();
new_e->name = name;
timer.Tick();
timer.GetTime(new_e->tick);
stac.back()->e.push_back(new_e);
stac.push_back(new_e);
}
示例2: Start
void Profiler::Start()
{
timer.Start();
e = entry_pool.Get();
e->name = "Start";
timer.GetTime(e->tick);
stac.push_back(e);
started = true;
if(!enabled)
{
frames = 0;
enabled = true;
}
}
示例3: ForLevel
//=================================================================================================
// Get area levels for selected location and level (in multilevel dungeon not generated levels are ignored for -1)
// Level have special meaning here
// >= 0 (dungeon_level, building index)
// -1 whole location
// -2 outside part of city/village
LevelAreaContext* Game::ForLevel(int loc, int level)
{
LevelAreaContext* lac = LevelAreaContextPool.Get();
lac->refs = 1;
lac->entries.clear();
bool active = (current_location == loc);
Location* l = locations[loc];
assert(l->state >= LS_ENTERED);
switch(l->type)
{
case L_CITY:
{
City* city = (City*)l;
if(level == -1)
{
lac->entries.resize(city->inside_buildings.size() + 1);
LevelAreaContext::Entry& e = lac->entries[0];
e.active = active;
e.area = city;
e.level = -2;
e.loc = loc;
for(int i = 0, len = (int)city->inside_buildings.size(); i < len; ++i)
{
LevelAreaContext::Entry& e2 = lac->entries[i + 1];
e2.active = active;
e2.area = city->inside_buildings[i];
e2.level = i;
e2.loc = loc;
}
}
else if(level == -2)
{
LevelAreaContext::Entry& e = Add1(lac->entries);
e.active = active;
e.area = city;
e.level = -2;
e.loc = loc;
}
else
{
assert(level >= 0 && level < (int)city->inside_buildings.size());
LevelAreaContext::Entry& e = Add1(lac->entries);
e.active = active;
e.area = city->inside_buildings[level];
e.level = level;
e.loc = loc;
}
}
break;
case L_CAVE:
case L_DUNGEON:
case L_CRYPT:
{
InsideLocation* inside = (InsideLocation*)l;
if(inside->IsMultilevel())
{
MultiInsideLocation* multi = (MultiInsideLocation*)inside;
if(level == -1)
{
lac->entries.resize(multi->generated);
for(int i = 0; i < multi->generated; ++i)
{
LevelAreaContext::Entry& e = lac->entries[i];
e.active = (active && dungeon_level == i);
e.area = &multi->levels[i];
e.level = i;
e.loc = loc;
}
}
else
{
assert(level >= 0 && level < multi->generated);
LevelAreaContext::Entry& e = Add1(lac->entries);
e.active = (active && dungeon_level == level);
e.area = &multi->levels[level];
e.level = level;
e.loc = loc;
}
}
else
{
assert(level == -1 || level == 0);
SingleInsideLocation* single = (SingleInsideLocation*)inside;
LevelAreaContext::Entry& e = Add1(lac->entries);
e.active = active;
e.area = single;
e.level = 0;
e.loc = loc;
}
}
break;
case L_FOREST:
//.........这里部分代码省略.........