当前位置: 首页>>代码示例>>C++>>正文


C++ AttributeIterator类代码示例

本文整理汇总了C++中AttributeIterator的典型用法代码示例。如果您正苦于以下问题:C++ AttributeIterator类的具体用法?C++ AttributeIterator怎么用?C++ AttributeIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AttributeIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: beginVisit

void PrinterVisitor::beginVisit( AttributeIterator const &i ) {
  thePrinter.startBeginVisit( "AttributeIterator", ++theId );
  if ( i.getQName() )
    thePrinter.addAttribute( "qname", i.getQName()->show().str() );
  printCommons( &i, theId );
  thePrinter.endBeginVisit( theId );
}
开发者ID:cezarfx,项目名称:zorba,代码行数:7,代码来源:printer_visitor_impl.cpp

示例2: btrfs_open_attr_dir

static status_t
btrfs_open_attr_dir(fs_volume *_volume, fs_vnode *_node, void **_cookie)
{
	Inode* inode = (Inode*)_node->private_node;
	TRACE("%s()\n", __FUNCTION__);

	// on directories too ?
	if (!inode->IsFile())
		return EINVAL;

	AttributeIterator* iterator = new(std::nothrow) AttributeIterator(inode);
	if (iterator == NULL || iterator->InitCheck() != B_OK) {
		delete iterator;
		return B_NO_MEMORY;
	}

	*_cookie = iterator;
	return B_OK;
}
开发者ID:DonCN,项目名称:haiku,代码行数:19,代码来源:kernel_interface.cpp

示例3: GetVolume

// RemoveAttribute
status_t
Node::RemoveAttribute(Attribute *attribute)
{
	status_t error = (attribute && attribute->GetNode() == this
					  ? B_OK : B_BAD_VALUE);
	if (error == B_OK) {
		// move all iterators pointing to the attribute to the next attribute
		if (GetVolume()->IteratorLock()) {
			// set the iterators' current entry
			Attribute *nextAttr = fAttributes.GetNext(attribute);
			DoublyLinkedList<AttributeIterator> *iterators
				= attribute->GetAttributeIteratorList();
			for (AttributeIterator *iterator = iterators->First();
				 iterator;
				 iterator = iterators->GetNext(iterator)) {
				iterator->SetCurrent(nextAttr, true);
			}
			// Move the iterators from one list to the other, or just remove
			// them, if there is no next attribute.
			if (nextAttr) {
				DoublyLinkedList<AttributeIterator> *nextIterators
					= nextAttr->GetAttributeIteratorList();
				nextIterators->MoveFrom(iterators);
			} else
				iterators->RemoveAll();
			GetVolume()->IteratorUnlock();
		} else
			error = B_ERROR;
		// remove the attribute
		if (error == B_OK) {
			error = GetVolume()->NodeAttributeRemoved(GetID(), attribute);
			if (error == B_OK) {
				fAttributes.Remove(attribute);
				attribute->SetNode(NULL);
				MarkModified();
			}
		}
	}
	return error;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:41,代码来源:Node.cpp

示例4: btrfs_read_attr_dir

static status_t
btrfs_read_attr_dir(fs_volume* _volume, fs_vnode* _node,
				void* _cookie, struct dirent* dirent, size_t bufferSize,
				uint32* _num)
{
	TRACE("%s()\n", __FUNCTION__);
	AttributeIterator* iterator = (AttributeIterator*)_cookie;

	size_t length = bufferSize;
	status_t status = iterator->GetNext(dirent->d_name, &length);
	if (status == B_ENTRY_NOT_FOUND) {
		*_num = 0;
		return B_OK;
	} else if (status != B_OK)
		return status;

	Volume* volume = (Volume*)_volume->private_volume;
	dirent->d_dev = volume->ID();
	dirent->d_reclen = sizeof(struct dirent) + length;
	*_num = 1;

	return B_OK;
}
开发者ID:DonCN,项目名称:haiku,代码行数:23,代码来源:kernel_interface.cpp

示例5: btrfs_rewind_attr_dir

static status_t
btrfs_rewind_attr_dir(fs_volume* _volume, fs_vnode* _node, void* _cookie)
{
	AttributeIterator* iterator = (AttributeIterator*)_cookie;
	return iterator->Rewind();
}
开发者ID:DonCN,项目名称:haiku,代码行数:6,代码来源:kernel_interface.cpp

示例6: init

void HudScheduling::init( Ui::Menu_HUD* ui, AttributePtr<Attribute_Player> ptr_owner_player )
{
	parent = ui->label_scheduling_background->parentWidget();
	window = ui->label_scheduling_background;
	subWindow = ui->label_scheduling_subbackground;
	progressbar = ui->progressBar_scheduling_progressbar;
	advantageLabel = ui->label_priority_advantage;

	Float2 screenSize;
	screenSize.x = window->parentWidget()->width();
	screenSize.y = window->parentWidget()->height();

	// Compute sizes
	itemHeight = subWindow->height();
	itemWidth = itemHeight*0.8f;
	standardMargin = itemHeight * 0.5f;

	int maxWindowSize = parent->width() - (ui->groupBox_health->width() + ui->groupBox_ammo->width() * 3.3f);
	if(window->width() > maxWindowSize)
		window->resize( maxWindowSize , window->height());
	subWindow->resize(window->width() - 2*standardMargin, subWindow->height());
	progressbar->resize(window->width() - 2*standardMargin, progressbar->height());
	int windowHeight = standardMargin*2 + itemHeight + subWindow->height() + progressbar->height();
	window->resize(window->width(), windowHeight);
	advantageLabel->resize(itemWidth, advantageLabel->height());

	// Compute positions
	window->move(screenSize.x*0.5f - window->width()*0.5, screenSize.y - window->height() - 9);
	progressbar->move(window->x() + standardMargin, window->y() + standardMargin);
	subWindow->move(window->x() + standardMargin, progressbar->y() + progressbar->height() + standardMargin);
	
	advantageLabel->move(subWindow->x(), subWindow->y());


	//hide();
	ui->label_7->hide();
	ui->label_8->hide();
	//ui->label_priority_advantage->hide();
	progressbar->setMaximum(500);


	// Add players
	AttributeIterator<Attribute_Player> itrPlayer = ATTRIBUTE_MANAGER->player.getIterator();
	while(itrPlayer.hasNext())
	{
		AttributePtr<Attribute_Player> ptr_player = itrPlayer.getNext();
		//ptr_player->priority = 5;
		QLabel* l = new QLabel(parent);
		l->resize(itemWidth, standardMargin);
		l->move(subWindow->x() + 0.5f, subWindow->y() + 0.5f);

		// Set color based on player's color
		Float3 color = ptr_player->avatarColor;
		std::string str_backgroundColor	= "rgba("+Converter::IntToStr((int)(color.x * 255))+", "+Converter::IntToStr((int)(color.y * 255))+", "+ Converter::IntToStr((int)(color.z * 255)) +", 200);";
		std::string str_borderColor		= "rgba("+Converter::IntToStr((int)(color.x * 255))+", "+Converter::IntToStr((int)(color.y * 255))+", "+ Converter::IntToStr((int)(color.z * 255)) +", 255);";
		std::string str_sheet = "background: " + str_backgroundColor + "border: 1px solid rgba(0, 0, 0, 30); border-top: 2px solid rgba(255, 255, 255, 30); border-right: 2px solid rgba(255, 255, 255, 30);";
		l->setStyleSheet(QString(str_sheet.c_str()));

		l->show();

		// Save ref to owner player
		if(ptr_player == ptr_owner_player)
			ownerIndex = items.size();

		// Create item
		HudScheduling_Item item;
		item.label = l;
		item.ptr_player = ptr_player;
		item.setPosition(Float2(subWindow->x(), subWindow->y()));
		items.push_back(item);
	}

	// Show advantage label on top
	advantageLabel->raise();
}
开发者ID:L0mion,项目名称:xkill-source,代码行数:75,代码来源:HudScheduling.cpp

示例7: while

bool DomWriter::writeWithNamespaceSupport(
   Element& e, OutputStream* os, int level, DynamicObject& nsPrefixMap)
{
   bool rval = true;

   if(level < 0)
   {
      level = mIndentLevel;
   }

   // add any entries to the current namespace prefix map
   if(e->hasMember("attributes") && e["attributes"]->getType() == Map)
   {
      AttributeIterator attrs = e["attributes"].getIterator();
      while(attrs->hasNext())
      {
         Attribute& attr = attrs->next();

         // check for an xml namespace prefix definition
         const char* attrName = attrs->getName();
         if(strncmp(attrName, "xmlns:", 6) == 0)
         {
            const char* uri = attr["value"]->getString();
            nsPrefixMap[uri] = attrName + 6;
         }
      }
   }

   // create element name, which may require using the namespace prefix map
   string elementName;
   if(e->hasMember("namespace"))
   {
      const char* ns = e["namespace"]->getString();
      if(nsPrefixMap->hasMember(ns))
      {
         // prepend prefix for given namespace
         elementName.append(nsPrefixMap[ns]->getString());
         elementName.push_back(':');
      }
   }
   elementName.append(e["name"]->getString());

   // open start element
   rval =
      ((mCompact || level == 0) ? true : os->write("\n", 1)) &&
      writeIndentation(os, level) &&
      os->write("<", 1) &&
      os->write(elementName.c_str(), elementName.length());

   // write attributes
   e["attributes"]->setType(Map);
   AttributeIterator attrs = e["attributes"].getIterator();
   while(rval && attrs->hasNext())
   {
      Attribute& attr = attrs->next();

      // create attribute name, which may require using the namespace prefix map
      string attrName;
      if(attr->hasMember("namespace"))
      {
         const char* ns = attr["namespace"]->getString();
         if(nsPrefixMap->hasMember(ns))
         {
            // prepend prefix for given namespace
            attrName.append(nsPrefixMap[ns]->getString());
            attrName.push_back(':');
         }
      }
      attrName.append(attr["name"]->getString());

      rval =
         os->write(" ", 1) &&
         os->write(attrName.c_str(), attrName.length()) &&
         os->write("=\"", 2) &&
         os->write(attr["value"]->getString(), attr["value"]->length()) &&
         os->write("\"", 1);
   }

   // close start element, if element is empty, use compact element
   e["data"]->setType(String);
   e["children"]->setType(Map);
   int dataLength = e["data"]->length();
   bool empty = (dataLength == 0 && e["children"]->length() == 0);
   rval = rval && (empty ? os->write("/>", 2) : os->write(">", 1));

   // write element data and children
   if(rval && !empty)
   {
      // write element children
      if(rval && e["children"]->length() > 0)
      {
         // serialize each child
         DynamicObjectIterator lists = e["children"].getIterator();
         while(rval && lists->hasNext())
         {
            DynamicObject& list = lists->next();
            list->setType(Array);
            ElementIterator children = list.getIterator();
            while(rval && children->hasNext())
            {
//.........这里部分代码省略.........
开发者ID:zengyuxing007,项目名称:monarch,代码行数:101,代码来源:DomWriter.cpp

示例8: frustumInit

bool FrustumPhysicsObject::frustumInit(unsigned int attributeIndex,short collisionFilterGroup)
{
	if(attributeIndex < 0)
	{
		return false;
	}
	attributeIndex_ = attributeIndex;
	collisionFilterGroup_ = collisionFilterGroup;
	AttributePtr<Attribute_Camera> ptr_camera = itrCamera_3.at(attributeIndex);
	btVector3 localInertia;
	localInertia.setZero();
	btCollisionShape* collisionShape = CollisionShapes::Instance()->getFrustumShape(attributeIndex_);
	btScalar mass = static_cast<btScalar>(1);
	setMassProps(mass, localInertia);
	setCollisionShape(collisionShape);
	btTransform world;
	
	AttributePtr<Attribute_Spatial> ptr_spatial = itrCamera_3.at(attributeIndex_)->ptr_spatial;
 	AttributePtr<Attribute_Position> ptr_position = ptr_spatial->ptr_position;
 	world.setOrigin(convert(ptr_position->position));
	world.setRotation(convert(ptr_spatial->rotation));
	setWorldTransform(world);
	setCollisionFlags(getCollisionFlags() | CF_NO_CONTACT_RESPONSE); 
	forceActivationState(DISABLE_DEACTIVATION);
	return true;
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:26,代码来源:FrustumPhysicsObject.cpp

示例9: handleInput

void PlayerPhysicsObject::handleInput(float delta)
{
    std::vector<int> playerAttributes = itrPhysics_3.ownerAt(attributeIndex_)->getAttributes(ATTRIBUTE_PLAYER);
    if(playerAttributes.size() > 1)
    {
        ERROR_MESSAGEBOX("More than one controller for one player. Not tested.")
    }
    for(unsigned int i=0; i<playerAttributes.size(); i++)
    {
        AttributePtr<Attribute_Player> ptr_player = ptr_player = itrPlayer.at(playerAttributes.at(i));
        AttributePtr<Attribute_Input> ptr_input = ptr_player->ptr_input;
        AttributePtr<Attribute_Health> health = ptr_player->ptr_health;
        if(health->health <= 0)
        {
            continue;
        }

        //--------------------------------------------------------------------------------------
        //Look and move
        //--------------------------------------------------------------------------------------
        yaw_ += ptr_input->rotation.x;
        btVector3 move = ptr_player->currentSpeed*btVector3(ptr_input->position.x, 0, ptr_input->position.y);

        //lower player speed when recently damaged
        if(ptr_player->timeSinceLastDamageTaken < 1.0f)
        {
            move *= 0.75f;
        }

        //Move player
        move = move.rotate(btVector3(0,1,0),yaw_);
        move = btVector3(move.x(), getLinearVelocity().y(), move.z());
        setLinearVelocity(move);

        //Rotate player
        btTransform world;
        world = getWorldTransform();
        world.setRotation(btQuaternion(yaw_,0,0));
        setWorldTransform(world);

        //Jetpack
        if(ptr_player->jetpack)
        {
            float jetpackPower = -getGravity().y()*1.5f;
            world = getWorldTransform();
            btVector3 velocity = getLinearVelocity();
            if(world.getOrigin().y() < 18.0f)
            {
                setLinearVelocity(btVector3(move.x(), velocity.y()+jetpackPower*delta, move.z()));
            }
        }
        else if(ptr_input->jump && ptr_player->hovering) //Jump
        {
            float jumpPower = 600.0f;
            applyCentralImpulse(btVector3(0.0f, jumpPower, 0.0f));
            //applyCentralForce(btVector3(0.0f, jumpPower, 0.0f));
        }
    }
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:59,代码来源:PlayerPhysicsObject.cpp

示例10: hover

void PlayerPhysicsObject::hover(float delta, float hoverHeight)
{
    float deltaHeightMaximum = 0.0f;
    btVector3 offset[] = {btVector3( 0.15f, 0.0f,  0.15f),
                          btVector3( 0.15f, 0.0f, -0.15f),
                          btVector3(-0.15f, 0.0f,  0.15f),
                          btVector3(-0.15f, 0.0f, -0.15f)
                         };
    for(unsigned int i=0; i<4; i++)
    {
        btVector3 from = btVector3(0.0f, 0.0f, 0.0f);
        btVector3 to = (from - btVector3(0.0f,hoverHeight*2.0f,0.0f)) + offset[i];
        from += offset[i];

        from += getWorldTransform().getOrigin();
        to   += getWorldTransform().getOrigin();

        btQuaternion btqt = getWorldTransform().getRotation();

        btCollisionWorld::ClosestRayResultCallback ray(from,to);
        ray.m_collisionFilterGroup = XKILL_Enums::PhysicsAttributeType::RAY;
        ray.m_collisionFilterMask = XKILL_Enums::PhysicsAttributeType::WORLD;
        dynamicsWorld_->rayTest(from,to,ray); //cast ray from player position straight down
        if(ray.hasHit())
        {
            btVector3 point = from.lerp(to,ray.m_closestHitFraction);
            float length = (point - from).length();
            float deltaHeight = hoverHeight-length;
            if(deltaHeight > deltaHeightMaximum)
            {
                deltaHeightMaximum = deltaHeight;
            }
        }
        debugDrawer_->drawLine(from, to, btVector3(0.2f, 1.0f, 0.2f));
    }

    bool isHovering = false;

    if(deltaHeightMaximum > 0.0f)
    {
        btTransform worldTransform;
        worldTransform = getWorldTransform();
        worldTransform.setOrigin(worldTransform.getOrigin() + btVector3(0.0f,deltaHeightMaximum,0.0f)*delta/0.25f);
        setWorldTransform(worldTransform);

        setLinearVelocity(getLinearVelocity()+btVector3(0.0f,-getLinearVelocity().y(),0.0f));

        isHovering = true;
    }

    std::vector<int> playerAttributes = itrPhysics_3.ownerAt(attributeIndex_)->getAttributes(ATTRIBUTE_PLAYER);
    for(unsigned int i=0; i<playerAttributes.size(); i++)
    {
        AttributePtr<Attribute_Player> ptr_player = itrPlayer.at(playerAttributes.at(i));
        ptr_player->hovering = isHovering;
    }
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:57,代码来源:PlayerPhysicsObject.cpp

示例11: onUpdate

void FrustumPhysicsObject::onUpdate(float delta)
{
	btMatrix3x3 view = convert(itrCamera_3.at(attributeIndex_)->mat_view);
	btVector3 pos =  convert(itrCamera_3.at(attributeIndex_)->ptr_spatial->ptr_position->position);
	btQuaternion q;
	view.getRotation(q);
	btTransform world = getWorldTransform();
	world.setRotation(q);
	world.setOrigin(pos);
	setWorldTransform(world);
	
	setCollisionShape(CollisionShapes::Instance()->getFrustumShape(attributeIndex_));
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:13,代码来源:FrustumPhysicsObject.cpp

示例12: subClassSpecificInitHook

bool PlayerPhysicsObject::subClassSpecificInitHook()
{
    forceActivationState(DISABLE_DEACTIVATION); //Prevent the player from getting stuck when standing still
    //setCollisionFlags(getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);

    Float4 q = itrPhysics_3.at(attributeIndex_)->ptr_spatial->rotation;
    yaw_ = -atan2(2*q.y*q.w-2*q.x*q.z , 1 - 2*q.y*q.y - 2*q.z*q.z);
    return true;
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:9,代码来源:PlayerPhysicsObject.cpp

示例13: onUpdate

void PlayerPhysicsObject::onUpdate(float delta)
{
    PhysicsObject::onUpdate(delta);

    std::vector<int> playerAttributes = itrPhysics_3.ownerAt(attributeIndex_)->getAttributes(ATTRIBUTE_PLAYER);
    for(unsigned int i=0; i<playerAttributes.size(); i++)
    {
        AttributePtr<Attribute_Player> ptr_player = itrPlayer.at(playerAttributes.at(i));

        if(!ptr_player->detectedAsDead)
        {
            handleInput(delta);
        }

        if( !(ptr_player->jetpack) && !(ptr_player->detectedAsDead) && !(ptr_player->ptr_input->jump))
        {
            float height = 1.5;
            hover(delta, height);
        }
    }
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:21,代码来源:PlayerPhysicsObject.cpp

示例14: writeNonSynchronizedPhysicsObjectDataToPhysicsAttribute

void PhysicsObject::writeNonSynchronizedPhysicsObjectDataToPhysicsAttribute()
{
	AttributePtr<Attribute_Physics> ptr_physics = itrPhysics_.at(attributeIndex_);

	ptr_physics->angularVelocity = convert(&getAngularVelocity());
	ptr_physics->collisionFilterGroup = getCollisionFilterGroup();
	ptr_physics->collisionResponse = (getCollisionFlags() & btCollisionObject::CF_NO_CONTACT_RESPONSE) == 0;
	ptr_physics->gravity = convert(&getGravity());
	ptr_physics->linearVelocity = convert(&getLinearVelocity());
	//ptr_physics->collisionFilterMask = 
	//ptr_physics->mass = physicsObject->getInvMass(); //only mass inverse is stored in physics object
	//ptr_physics->meshID = //not stored in physics object
}
开发者ID:L0mion,项目名称:xkill-source,代码行数:13,代码来源:physicsObject.cpp

示例15: subClassCalculateLocalInertiaHook

btVector3 PlayerPhysicsObject::subClassCalculateLocalInertiaHook(btScalar mass)
{
    Entity* playerEntity = itrPhysics_3.ownerAt(attributeIndex_);
    std::vector<int> playerId = playerEntity->getAttributes(ATTRIBUTE_PLAYER);
    bool detectedAsDead = false;

    for(unsigned int i = 0; i < playerId.size(); i++)
    {
        detectedAsDead = itrPlayer.at(playerId.at(i))->detectedAsDead;
    }

    btVector3 localInertia;
    if(detectedAsDead)
    {
        localInertia = localInertiaBasedOnCollisionShapeAndMass(itrPhysics_3.at(attributeIndex_)->mass);
    }
    else
    {
        localInertia = zeroLocalInertia();
    }

    return localInertia;
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:23,代码来源:PlayerPhysicsObject.cpp


注:本文中的AttributeIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。