本文整理汇总了C++中ObjectList类的典型用法代码示例。如果您正苦于以下问题:C++ ObjectList类的具体用法?C++ ObjectList怎么用?C++ ObjectList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestObject
LNE_NAMESPACE_USING
void TestObject()
{
LNE_UINT i, v;
ObjectList<LNE_UINT> list;
for(int i = 0; i < 3; i++)
list.PushFront(i + 1);
while(list.PopFront(v) == LNERR_OK) {
printf("%u\n", v);
}
DataBlock *block;
ObjectQueue<DataBlock *> queue;
DataBlockPool *pool = DataBlockPool::NewInstance();
for(i = 0; i < 10000; ++i)
queue.Append(pool->Alloc());
i = 0;
while(queue.Extract(block) == LNERR_OK) {
++i;
block->Release();
}
printf("data count: %u\n", i);
pool->Release();
}
示例2: FIXME
void ThreadMessenger::Finalize()
{
#ifndef DEBUG
#warning FIXME(ThreadMessenger::Finalize): Any Nodes still in transit on finalize are leaked. Finalize should force processing of all data.
#endif
ObjectList<Object> *callbacks;
Object *callback;
UnsignedType key;
void *iter_m=NULL, *iter_l=NULL;
while (mCallbacks->Iterate(iter_m, key, (void*&)callbacks))
{
while (callbacks->Iterate(iter_l, callback))
UnReference((Object*)callback);
UnReference(callbacks);
}
while (mCacheCount > 0)
{
Thread::Message *next = mCache->NextArgument();
UnReference(mCache);
mCache = next;
mCacheCount--;
}
UnReference(mSignatures);
UnReference(mCallbacks);
UnReference(mQueue);
Super::Finalize();
}
示例3: replacement
void LoopUnroll::simple_replication(int factor, Source &replicated_body,
Source &epilogue_body,
IdExpression induction_var, Statement loop_body)
{
for (unsigned int i = 0; i < factor; i++)
{
ReplaceSrcIdExpression replacement(_for_stmt.get_scope_link());
replacement.set_ignore_pragma(true);
if (i > 0)
{
std::stringstream ss;
ss << "(" << induction_var << " + " << i << ")";
replacement.add_replacement(induction_var.get_symbol(), ss.str());
}
if (!loop_body.is_compound_statement()
|| there_is_declaration(loop_body))
{
replicated_body
<< replacement.replace(loop_body)
;
}
else
{
ObjectList<Statement> list = loop_body.get_inner_statements();
for (ObjectList<Statement>::iterator it = list.begin();
it != list.end();
it++)
{
replicated_body
<< replacement.replace(*it)
;
}
}
}
}
示例4: UngroupObjects
void ESceneGroupTools::UngroupObjects(bool bUndo)
{
ObjectList lst = m_Objects;
int sel_cnt = 0;
if (!lst.empty()){
bool bModif = false;
for (ObjectIt it=lst.begin(); it!=lst.end(); it++){
if ((*it)->Selected()){
sel_cnt++;
CGroupObject* obj = dynamic_cast<CGroupObject*>(*it); VERIFY(obj);
if (obj->CanUngroup(true)){
Scene->RemoveObject (obj,false);
obj->UngroupObjects ();
xr_delete (obj);
bModif = true;
}else{
ELog.DlgMsg (mtError,"Can't ungroup object: '%s'.",obj->Name);
}
}
}
if (bUndo&&bModif) Scene->UndoSave();
}
if (0==sel_cnt) ELog.Msg (mtError,"Nothing selected.");
}
示例5: ObjectList
ObjectList* FireworkShow::_getInventoryFireworks(PlayerObject* playerObject)
{
ObjectList* returnList = new ObjectList();
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
ObjectIDList* objList = inventory->getObjects();
ObjectIDList::iterator containerObjectIt = objList->begin();
while (containerObjectIt != objList->end())
{
Object* object = gWorldManager->getObjectById((*containerObjectIt));
if (Item* item = dynamic_cast<Item*>(object))
{
if(item->getItemFamily()==ItemFamily_FireWork && item->getItemType()!= ItemType_Firework_Show)
{
returnList->push_back(item);
}
}
++containerObjectIt;
}
return returnList;
}
示例6: Start
bool __fastcall TUI_ControlShapeAdd::Start(TShiftState Shift)
{
TfraShape* F = (TfraShape*)parent_tool->pFrame;
if (F->ebAttachShape->Down){
CEditShape* from = dynamic_cast<CEditShape*>(Scene->RayPickObject(UI->ZFar(),UI->m_CurrentRStart, UI->m_CurrentRNorm, OBJCLASS_SHAPE, 0, 0));
if (from){
ObjectList lst;
int cnt = Scene->GetQueryObjects(lst,OBJCLASS_SHAPE,1,1,0);
if (1!=cnt) ELog.DlgMsg(mtError,"Select one shape.");
else{
CEditShape* base = dynamic_cast<CEditShape*>(lst.back()); R_ASSERT(base);
if (base!=from){
base->Attach(from);
if (!Shift.Contains(ssAlt)){
F->ebAttachShape->Down = false;
ResetActionToSelect ();
}
}
}
}
}else
DefaultAddObject(Shift,0,AfterAppendCallback);
return false;
}
示例7: GetQueryObjects
int EScene::GetQueryObjects(ObjectList& lst, ObjClassID classfilter, int iSel, int iVis, int iLock)
{
if (classfilter==OBJCLASS_DUMMY){
SceneToolsMapPairIt _I = m_SceneTools.begin();
SceneToolsMapPairIt _E = m_SceneTools.end();
for (; _I!=_E; ++_I)
{
ESceneCustomOTool* mt = dynamic_cast<ESceneCustomOTool*>(_I->second);
if (mt) mt->GetQueryObjects(lst, iSel, iVis, iLock);
}
}else{
ESceneCustomOTool* mt = GetOTool(classfilter);
if (mt) mt->GetQueryObjects(lst, iSel, iVis, iLock);
}
return lst.size();
}
示例8: induction_variable_list_contains_variable
bool induction_variable_list_contains_variable( ObjectList<InductionVariableData*> iv_list,
Nodecl::NodeclBase var )
{
bool result = false;
for( ObjectList<InductionVariableData*>::iterator it = iv_list.begin( ); it != iv_list.end( ); ++it )
{
if( Nodecl::Utils::equal_nodecls( ( *it )->get_variable( ).get_nodecl( ), var,
/* skip conversion nodes */ true ) )
{
result = true;
break;
}
}
return result;
}
示例9: getCurrentlySelectedObjects
size_t Player::getCurrentlySelectedObjects(ObjectList &buf, const Coordinate &crnt_coord, SelectionFlags_t flags) const
{
ObjectList cur_selected_objs;
int max_objs = 16;
if(this->m_selection_start_coordinate == crnt_coord)
max_objs = 1;
if(flags != SelectionFlags::SET)
buf = this->m_selected_objs;
this->m_game->findObjectByRect(cur_selected_objs, this->m_selection_start_coordinate, crnt_coord);
this->filterCurSelectedObjects(cur_selected_objs, max_objs);
this->mergeObjectList(buf, cur_selected_objs, flags);
return buf.size();
}
示例10: createAABBFromObjList
AABB DBVH::createAABBFromObjList( const ObjectList& objList )
{
AABB box;
float minX, minY, minZ, maxX, maxY, maxZ;
minX = minY = minZ = FLT_MAX;
maxX = maxY = maxZ = -FLT_MAX;
//Find the minimum and maximum x y and z points
for(unsigned i = 0; i < objList.size(); ++i)
{
const Object& obj = objList[i];
Pt minPt = obj.boundingBox.center - obj.boundingBox.extents;
Pt maxPt = obj.boundingBox.center + obj.boundingBox.extents;
if(minPt.x < minX)
minX = minPt.x;
if(maxPt.x > maxX)
maxX = maxPt.x;
if(minPt.y < minY)
minY = minPt.y;
if(maxPt.y > maxY)
maxY = maxPt.y;
if(minPt.z < minZ)
minZ = minPt.z;
if(maxPt.z > maxZ)
maxZ = maxPt.z;
}
//Extents are just width/height/depth / 2
box.extents.x = abs(maxX - minX) * 0.5f;
box.extents.y = abs(maxY - minY) * 0.5f;
box.extents.z = abs(maxZ - minZ) * 0.5f;
//Center is just the min point plus the extents
Pt minPt(minX, minY, minZ);
box.center = minPt + box.extents;
return box;
}
示例11: MovingStart
//------------------------------------------------------------------------------------
// moving
//------------------------------------------------------------------------------------
bool __fastcall TUI_CustomControl::MovingStart(TShiftState Shift)
{
ObjClassID cls = LTools->CurrentClassID();
if(Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,parent_tool->ClassID); return false;}
if(Scene->SelectionCount(true,cls)==0) return false;
if (Shift.Contains(ssCtrl)){
ObjectList lst;
if (Scene->GetQueryObjects(lst,LTools->CurrentClassID(),1,1,0)){
if (lst.size()==1){
Fvector p,n;
UI->IR_GetMousePosReal(Device.m_hRenderWnd, UI->m_CurrentCp);
Device.m_Camera.MouseRayFromPoint(UI->m_CurrentRStart,UI->m_CurrentRNorm,UI->m_CurrentCp);
if (LUI->PickGround(p,UI->m_CurrentRStart,UI->m_CurrentRNorm,1,&n)){
for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) (*_F)->MoveTo(p,n);
Scene->UndoSave();
}
}else{
Fvector p,n;
Fvector D={0,-1,0};
for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){
if (LUI->PickGround(p,(*_F)->PPosition,D,1,&n)){
(*_F)->MoveTo(p,n);
}
}
}
}
return false;
}else{
if (etAxisY==Tools->GetAxis()){
m_MovingXVector.set(0,0,0);
m_MovingYVector.set(0,1,0);
}else{
m_MovingXVector.set( Device.m_Camera.GetRight() );
m_MovingXVector.y = 0;
m_MovingYVector.set( Device.m_Camera.GetDirection() );
m_MovingYVector.y = 0;
m_MovingXVector.normalize_safe();
m_MovingYVector.normalize_safe();
}
m_MovingReminder.set(0,0,0);
}
return true;
}
示例12: GetScript
bool SmartAI::IsEscortInvokerInRange()
{
ObjectList* targets = GetScript()->GetTargetList(SMART_ESCORT_TARGETS);
if (targets)
{
float checkDist = me->GetInstanceScript() ? SMART_ESCORT_MAX_PLAYER_DIST*2 : SMART_ESCORT_MAX_PLAYER_DIST;
if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin())))
{
Player* player = (*targets->begin())->ToPlayer();
if (me->GetDistance(player) <= checkDist)
return true;
if (Group* group = player->GetGroup())
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
{
Player* groupGuy = groupRef->GetSource();
if (groupGuy && me->IsInMap(groupGuy) && me->GetDistance(groupGuy) <= checkDist)
return true;
}
}
}
else
{
for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
{
if (GetScript()->IsPlayer((*iter)))
{
if (me->GetDistance((*iter)->ToPlayer()) <= checkDist)
return true;
}
}
}
// Xinef: no valid target found
return false;
}
// Xinef: no player invoker was stored, just ignore range check
return true;
}
示例13: GetScript
bool SmartAI::IsEscortInvokerInRange()
{
ObjectList* targets = GetScript()->GetTargetList(SMART_ESCORT_TARGETS);
if (targets)
{
if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin())))
{
Player* player = (*targets->begin())->ToPlayer();
if (me->GetDistance(player) <= SMART_ESCORT_MAX_PLAYER_DIST)
return true;
if (Group* group = player->GetGroup())
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
{
Player* groupGuy = groupRef->GetSource();
if (me->GetDistance(groupGuy) <= SMART_ESCORT_MAX_PLAYER_DIST)
return true;
}
}
}
else
{
for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
{
if (GetScript()->IsPlayer((*iter)))
{
if (me->GetDistance((*iter)->ToPlayer()) <= SMART_ESCORT_MAX_PLAYER_DIST)
return true;
}
}
}
}
return true;//escort targets were not set, ignore range check
}
示例14: compute_pointer_vars_size_rec
void PointerSize::compute_pointer_vars_size_rec(Node* current)
{
if(current->is_visited())
return;
current->set_visited(true);
if(current->is_graph_node())
{
compute_pointer_vars_size_rec(current->get_graph_entry_node());
}
else
{
if(current->has_statements())
{
NBase s;
NBase value;
TL::Type t;
NodeclList stmts = current->get_statements();
for(NodeclList::iterator it = stmts.begin(); it != stmts.end(); ++it)
{
// If assignment (or object init) check whether its for is a dynamic allocation of resources for a pointer type
if(it->is<Nodecl::ObjectInit>() || it->is<Nodecl::Assignment>())
{
// Get the variable assigned and the value used for the assignment
if(it->is<Nodecl::ObjectInit>())
{
Symbol tmp(it->get_symbol());
s = Nodecl::Symbol::make(tmp);
t = tmp.get_type();
s.set_type(t);
value = tmp.get_value().no_conv();
}
else if(it->is<Nodecl::Assignment>())
{
s = it->as<Nodecl::Assignment>().get_lhs().no_conv();
t = s.get_type().no_ref();
if(!s.is<Nodecl::Symbol>() && !s.is<Nodecl::ClassMemberAccess>() && !s.is<Nodecl::ArraySubscript>())
continue;
value = it->as<Nodecl::Assignment>().get_rhs().no_conv();
}
// Check whether this is a pointer and the assignment is a recognized memory operation
if(t.is_pointer() && !value.is_null()) // This can be null if uninitialized ObjectInit
{
if(value.is<Nodecl::FunctionCall>())
{
Symbol called_sym = value.as<Nodecl::FunctionCall>().get_called().get_symbol();
Type return_t = called_sym.get_type().returns();
Nodecl::List args = value.as<Nodecl::FunctionCall>().get_arguments().as<Nodecl::List>();
std::string sym_name = called_sym.get_name();
NBase size = NBase::null();
if((sym_name == "malloc") && (args.size() == 1))
{ // void* malloc (size_t size);
Type arg0_t = args[0].get_type();
if(return_t.is_pointer() && return_t.points_to().is_void() && arg0_t.is_same_type(get_size_t_type()))
{ // We recognize the form 'sizeof(base_type) * n_elemes' and 'n_elemes * sizeof(base_type)'
if(args[0].is<Nodecl::Mul>())
{
NBase lhs = args[0].as<Nodecl::Mul>().get_lhs().no_conv();
NBase rhs = args[0].as<Nodecl::Mul>().get_rhs().no_conv();
if(lhs.is<Nodecl::Sizeof>() && (rhs.is<Nodecl::IntegerLiteral>() || rhs.is<Nodecl::Symbol>()))
size = rhs;
else if(rhs.is<Nodecl::Sizeof>() && (lhs.is<Nodecl::IntegerLiteral>() || lhs.is<Nodecl::Symbol>()))
size = lhs;
}
}
}
else if((sym_name == "calloc") && (args.size() == 2))
{ // void* calloc (size_t num, size_t size);
Type arg0_t = args[0].get_type();
Type arg1_t = args[1].get_type();
if(return_t.is_pointer() && return_t.points_to().is_void()
&& arg0_t.is_same_type(get_size_t_type())
&& arg1_t.is_same_type(get_size_t_type()))
{
size = args[0];
}
}
if(!size.is_null())
_pcfg->set_pointer_n_elems(s, size);
}
}
// Clear up the common variables s, value and t
s = NBase::null();
value = NBase::null();
t = Type();
}
}
}
}
// Keep iterating over the children
ObjectList<Node*> children = current->get_children();
for(ObjectList<Node*>::iterator it = children.begin(); it != children.end(); ++it)
compute_pointer_vars_size_rec(*it);
}
示例15: convert_vla
static void convert_vla(Symbol sym, ObjectList<Symbol>& converted_vlas, ScopeLink sl)
{
if (converted_vlas.contains(sym))
return;
ObjectList<Source> dim_decls;
ObjectList<Source> dim_names;
dimensional_replacements_of_variable_type_aux(sym.get_type(),
sym, dim_names, dim_decls);
Source new_decls;
for (ObjectList<Source>::iterator it = dim_decls.begin();
it != dim_decls.end();
it++)
{
new_decls << *it << ";"
;
}
AST_t point_of_decl = sym.get_point_of_declaration();
AST_t enclosing_stmt_tree;
if (sym.is_parameter())
{
FunctionDefinition
funct_def(point_of_decl.get_enclosing_function_definition(), sl);
enclosing_stmt_tree = funct_def.get_function_body().get_inner_statements()[0].get_ast();
}
else
{
enclosing_stmt_tree = point_of_decl.get_enclosing_statement();
}
AST_t statement_seq
= new_decls.parse_statement(enclosing_stmt_tree, sl);
enclosing_stmt_tree.prepend(statement_seq);
if (!sym.is_parameter())
{
// If this is not a parameter, we'll want to rewrite the declaration itself
Type new_type_spawn = compute_replacement_type_for_vla(sym.get_type(), dim_names.begin(), dim_names.end());
// Now redeclare
Source redeclaration, initializer;
redeclaration
<< new_type_spawn.get_declaration(sym.get_scope(), sym.get_name())
<< initializer
<< ";"
;
if (sym.has_initialization())
{
initializer << sym.get_initialization().prettyprint()
;
}
AST_t redeclaration_tree = redeclaration.parse_statement(enclosing_stmt_tree,
sl, Source::ALLOW_REDECLARATION);
enclosing_stmt_tree.prepend(redeclaration_tree);
// Now remove the declarator of the declaration
Declaration decl(point_of_decl, sl);
if (decl.get_declared_entities().size() == 1)
{
// We have to remove all the whole declaration
enclosing_stmt_tree.remove_in_list();
}
else
{
// Remove only this entity
ObjectList<DeclaredEntity> entities = decl.get_declared_entities();
for (ObjectList<DeclaredEntity>::iterator it = entities.begin();
it != entities.end();
it++)
{
if (it->get_declared_symbol() == sym)
{
it->get_ast().remove_in_list();
}
}
}
}
ObjectList<Source>* new_dim_ptr = new ObjectList<Source>(dim_names);
RefPtr<ObjectList<Source> > dim_names_ref(new_dim_ptr);
sym.set_attribute(OMP_NANOX_VLA_DIMS, dim_names_ref);
converted_vlas.insert(sym);
}