C++ Node::Clone方法代码示例

本文整理汇总了C++中Node::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::Clone方法的具体用法?C++ Node::Clone怎么用?C++ Node::Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node的用法示例。


C++ Node::Clone方法代码示例

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

示例1:

Llist& Llist::operator = (Llist& rho)
{
	if (rho.GetFirst() == NULL)
	{
		ClearList();
		return *this;
	}
	// check to see if this object is equal to the right hand object
	if (this != &rho)
	{
		ClearList();

		Node* oldNode = rho.GetFirst();
		//clone the old head node
		_headNode = oldNode->Clone();
		//get the next old node
		oldNode = oldNode->GetNextNode();
		//clone the next old node
		Node* newNode = oldNode->Clone();
		//set Next Node for head node
		_headNode->SetNextNode(newNode);
		//set prev node for next node to the new _headNode
		newNode->SetPrevNode(_headNode);
		//get the pointer to the next node in the old list
		oldNode = oldNode->GetNextNode();
		while (oldNode != NULL)
		{
			//clone the old Node
			Node* nextNode = oldNode->Clone();
			//set the next node of newNode
			newNode->SetNextNode(nextNode);
			//set the prev node of nextNode to newNode
			nextNode->SetPrevNode(newNode);
			//point newNode to nextNode						//TODO check this
			newNode = nextNode;
			//get the pointer to the next node in the old list
			oldNode = oldNode->GetNextNode();
		}
		_endNode = newNode;
		_nodeCount = rho.GetCount();
	}
	//Return a reference to this object.
	return *this;
}
开发者ID:spikesynergy,项目名称:CS1410,代码行数:44,代码来源:Llist.cpp

示例2: typeid

Llist::Llist(Llist& lst)
{
	//--- Test for empty list ------------
	if (lst._headNode == NULL)
		return;

	// check to see if this object is equal to the right hand object
	if (this != &lst)
	{
		ClearList();
		Node* oldNode = lst.GetFirst();
		//clone the old head node
		_headNode = oldNode->Clone();
		//get the next old node
		oldNode = oldNode->GetNextNode();
		//clone the next old node
		Node* newNode = oldNode->Clone();
		//set Next Node for head node
		_headNode->SetNextNode(newNode);
		//set prev node for next node to the new _headNode
		newNode->SetPrevNode(_headNode);
		//get the pointer to the next node in the old list
		oldNode = oldNode->GetNextNode();
		while (oldNode != NULL)
		{
			//clone the old Node
			Node* nextNode = oldNode->Clone();
			//set the next node of newNode
			newNode->SetNextNode(nextNode);
			//set the prev node of nextNode to newNode
			nextNode->SetPrevNode(newNode);
			//point newNode to nextNode						//TODO check this
			newNode = nextNode;
			//get the pointer to the next node in the old list
			oldNode = oldNode->GetNextNode();
		}
		_endNode = newNode;
		_nodeCount = lst.GetCount();
	}
	//print out the copy constructor message
	string classname = typeid(*this).name();
	cout << classname << COPY_CONSTRUCTOR << endl;
}
开发者ID:spikesynergy,项目名称:CS1410,代码行数:43,代码来源:Llist.cpp

示例3: CloneNode

bool CloneNode()
{
    Node *srcNode = new Node();
    srcNode->SetName("Tested Node");
    
    Node *dstNullNode = dynamic_cast<Node *>(srcNode->Clone());
    
    Node *dstNode = NULL;
    dstNode = dynamic_cast<Node *>(srcNode->Clone(dstNode));
    
	if(dstNode && dstNullNode)
	{
		bool compareResult = (dstNode->GetName() == dstNullNode->GetName());
		SafeRelease(srcNode);
		SafeRelease(dstNode);
		SafeRelease(dstNullNode);
		
		return compareResult;
	}

    return false;
}
开发者ID:abaradulkin,项目名称:dava.framework,代码行数:22,代码来源:CloneTest.cpp

示例4: Clone

Llist* Llist::Clone()
{
	//clone this list object, return a pointer to the clone
	Node* oldNode = _headNode;
	//clone the old head node
	Node* newHead = oldNode->Clone();
	//get the next old node
	oldNode = oldNode->GetNextNode();
	//clone the next old node
	Node* newNode = oldNode->Clone();
	//set Next Node for head new head node
	newHead->SetNextNode(newNode);
	//set prev node for next node to the new _headNode
	newNode->SetPrevNode(newHead);
	//get the pointer to the next node in the old list
	oldNode = oldNode->GetNextNode();
	//copy the rest of the list
	while (oldNode != NULL)
	{
		//clone the old Node
		Node* nextNode = oldNode->Clone();
		//set the next node of newNode
		newNode->SetNextNode(nextNode);
		//set the prev node of nextNode to newNode
		nextNode->SetPrevNode(newNode);
		//point newNode to nextNode						//TODO check this
		newNode = nextNode;
		//get the pointer to the next node in the old list
		oldNode = oldNode->GetNextNode();
	}
	Node* newEnd = newNode;

	Llist* newList = new Llist(_nodeCount);
	newList->SetFirst(newHead);
	newList->SetLast(newEnd);
	//Return a reference to the new Llist
	return newList;
}
开发者ID:spikesynergy,项目名称:CS1410,代码行数:38,代码来源:Llist.cpp

示例5: TreeCacheLookup

//=================================================================================
// Note that we don't provide any mechanism for invalidating cache entries
// when the file on disk is modified in a way that it doesn't match what
// we have loaded in cache memory.
Node* Context::TreeCacheLookup( const Path& path )
{
	if( !treeCacheMap )
		return 0;

	std::string key;
	if( !path.GetPath( key, true ) )
		return 0;

	TreeCacheMap::iterator iter = treeCacheMap->find( key );
	if( iter == treeCacheMap->end() )
		return 0;

	Node* root = iter->second;
	Node::CopyParameters copyParameters;
	Node* clone = root->Clone( *this, copyParameters );
	return clone;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:22,代码来源:Context.cpp

示例6: Controller

// the constructor
CCDIKSolver::CCDIKSolver(Actor* actor, Node* startNode, Node* endNode, bool cloneNodes) : Controller( actor )
{
	mStartNode	= startNode;
	mEndNode	= endNode;

	// if we want to clone the IK chain
	if (cloneNodes) 
	{
		mEndNode_Clone = endNode->Clone(actor);
		Node *tempNode = mEndNode_Clone;

		Node *i = endNode->GetParent();
		while (i != startNode)
		{
			tempNode->SetParent(i->Clone(actor));
			tempNode->GetParent()->AddChild(tempNode);
			tempNode = tempNode->GetParent();
			i = i->GetParent();
		}

		mStartNode_Clone = mStartNode->Clone(actor);
		tempNode->SetParent(mStartNode_Clone);
		mStartNode_Clone->AddChild(tempNode);
		mStartNode_Clone->SetParent(startNode->GetParent());

		// when cloning nodes, one iteration is enough to find the new solution
		mMaxIterations  = 1;
	}
	else
	{
		mEndNode_Clone	 = mEndNode;
		mStartNode_Clone = mStartNode;
		
		// The solver usually doesn't take more than 10 iterations to find the solution if its in reach.
		// Its usually below 5. If this is set higher, then the solver will meerly take longer to realise
		// that it cant reach the goal.
		mMaxIterations  = 10;
	}
	
	mHasSolution	= false;
	mDistThreshold	= 0.1f;
	mDoJointLimits  = true;
	mGoal.Set(0, 0, 0);
}
开发者ID:ak4hige,项目名称:myway3d,代码行数:45,代码来源:CCDIKSolver.cpp

示例7: metaDataCreatorFunc

//=================================================================================
/*virtual*/ bool Node::Copy( const Node* node, Context& context, const CopyParameters& copyParameters )
{
	if( copyParameters.copyIdentityInfo )
	{
		// Copy the name.
		name = node->name;

		// Copy the explanations.  In the idea of clonnig a template tree,
		// this explanation text will become very redundant and in that way,
		// potentially take up a lot of space unecessarily.
		for( int index = 0; index < EXPLANATION_COUNT; index++ )
			explanation[ index ] = node->explanation[ index ];
	}

	// We don't know who are parent is yet unless we're just copying the node value.
	if( copyParameters.copyChildrenDisposition != COPY_NODE_AND_LEAVE_CHILDREN_UNTOUCHED )
		parent = 0;
	
	// Remove children in preparation for copying over a new set of children, or do so if told to do so.
	if( copyParameters.copyChildrenDisposition == COPY_NODE_AND_CHILDREN || copyParameters.copyChildrenDisposition == COPY_NODE_AND_REMOVE_ALL_CHILDREN )
		DeleteChildren();

	// Clone the children of the given node if told to do so.
	if( node->children && copyParameters.copyChildrenDisposition == COPY_NODE_AND_CHILDREN )
	{
		children = new std::list< Node* >();

		for( List::iterator iter = node->children->begin(); iter != node->children->end(); iter++ )
		{
			Node* child = *iter;
			Node* clone = child->Clone( context, copyParameters );
			if( !clone )
				return context.IssueError( "Failed to clone node \"%s\" of type \"%s\".", child->name.c_str(), child->GetType().c_str() );

			children->push_back( clone );
			clone->parent = this;
		}
	}

	// Clone any meta-data.
	if( node->metaData && copyParameters.copyMetaData )
	{
		if( !metaData )
		{
			Context::MetaDataCreatorFunc metaDataCreatorFunc = context.GetMetaDataCreatorFunc();
			if( metaDataCreatorFunc )
				metaData = metaDataCreatorFunc();
			else
				return context.IssueError( "Failed to copy meta-data of node \"%s\" of type \"%s\", because there is no meta-data creator function.", name.c_str(), GetType().c_str() );
				
			if( !metaData )
				return context.IssueError( "Failed to copy meta-data of node \"%s\" of type \"%s\", because the meta-data creator failed.", name.c_str(), GetType().c_str() );

			metaData->PostCreate( this );
		}

		if( !metaData->Copy( node->metaData, context ) )
			return context.IssueError( "Failed to copy meta-data of node \"%s\" of type \"%s\".", name.c_str(), GetType().c_str() );
	}

	return true;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:63,代码来源:Node.cpp

示例8: Scene

//.........这里部分代码省略.........
    auto* ballBody = ball->CreateComponent<RigidBody2D>();
    ballBody->SetBodyType(BT_DYNAMIC);
    ballBody->SetLinearDamping(0.0f);
    ballBody->SetAngularDamping(0.0f);
    auto* ballShape = ball->CreateComponent<CollisionCircle2D>(); // Create circle shape
    ballShape->SetRadius(0.16f); // Set radius
    ballShape->SetDensity(1.0f); // Set shape density (kilograms per meter squared)
    ballShape->SetFriction(0.5f); // Set friction
    ballShape->SetRestitution(0.6f); // Set restitution: make it bounce

    // Create a polygon
    Node* polygon = scene_->CreateChild("Polygon");
    polygon->SetPosition(Vector3(1.6f, -2.0f, 0.0f));
    polygon->SetScale(0.7f);
    auto* polygonSprite = polygon->CreateComponent<StaticSprite2D>();
    polygonSprite->SetSprite(cache->GetResource<Sprite2D>("Urho2D/Aster.png"));
    auto* polygonBody = polygon->CreateComponent<RigidBody2D>();
    polygonBody->SetBodyType(BT_DYNAMIC);
    auto* polygonShape = polygon->CreateComponent<CollisionPolygon2D>();
    // TODO: create from ea::vector<Vector2> using SetVertices()
    polygonShape->SetVertexCount(6); // Set number of vertices (mandatory when using SetVertex())
    polygonShape->SetVertex(0, Vector2(-0.8f, -0.3f));
    polygonShape->SetVertex(1, Vector2(0.5f, -0.8f));
    polygonShape->SetVertex(2, Vector2(0.8f, -0.3f));
    polygonShape->SetVertex(3, Vector2(0.8f, 0.5f));
    polygonShape->SetVertex(4, Vector2(0.5f, 0.9f));
    polygonShape->SetVertex(5, Vector2(-0.5f, 0.7f));
    polygonShape->SetDensity(1.0f); // Set shape density (kilograms per meter squared)
    polygonShape->SetFriction(0.3f); // Set friction
    polygonShape->SetRestitution(0.0f); // Set restitution (no bounce)

    // Create a ConstraintDistance2D
    CreateFlag("ConstraintDistance2D", -4.97f, 3.0f); // Display Text3D flag
    Node* boxDistanceNode = box->Clone();
    Node* ballDistanceNode = ball->Clone();
    auto* ballDistanceBody = ballDistanceNode->GetComponent<RigidBody2D>();
    boxDistanceNode->SetPosition(Vector3(-4.5f, 2.0f, 0.0f));
    ballDistanceNode->SetPosition(Vector3(-3.0f, 2.0f, 0.0f));

    auto* constraintDistance = boxDistanceNode->CreateComponent<ConstraintDistance2D>(); // Apply ConstraintDistance2D to box
    constraintDistance->SetOtherBody(ballDistanceBody); // Constrain ball to box
    constraintDistance->SetOwnerBodyAnchor(boxDistanceNode->GetPosition2D());
    constraintDistance->SetOtherBodyAnchor(ballDistanceNode->GetPosition2D());
    // Make the constraint soft (comment to make it rigid, which is its basic behavior)
    constraintDistance->SetFrequencyHz(4.0f);
    constraintDistance->SetDampingRatio(0.5f);

    // Create a ConstraintFriction2D ********** Not functional. From Box2d samples it seems that 2 anchors are required, Urho2D only provides 1, needs investigation ***********
    CreateFlag("ConstraintFriction2D", 0.03f, 1.0f); // Display Text3D flag
    Node* boxFrictionNode = box->Clone();
    Node* ballFrictionNode = ball->Clone();
    boxFrictionNode->SetPosition(Vector3(0.5f, 0.0f, 0.0f));
    ballFrictionNode->SetPosition(Vector3(1.5f, 0.0f, 0.0f));

    auto* constraintFriction = boxFrictionNode->CreateComponent<ConstraintFriction2D>(); // Apply ConstraintDistance2D to box
    constraintFriction->SetOtherBody(ballFrictionNode->GetComponent<RigidBody2D>()); // Constraint ball to box
    //constraintFriction->SetOwnerBodyAnchor(boxNode->GetPosition2D());
    //constraintFriction->SetOtherBodyAnchor(ballNode->GetPosition2D());
    //constraintFriction->SetMaxForce(10.0f); // ballBody.mass * gravity
    //constraintDistance->SetMaxTorque(10.0f); // ballBody.mass * radius * gravity

    // Create a ConstraintGear2D
    CreateFlag("ConstraintGear2D", -4.97f, -1.0f); // Display Text3D flag
    Node* baseNode = box->Clone();
    auto* tempBody = baseNode->GetComponent<RigidBody2D>(); // Get body to make it static
    tempBody->SetBodyType(BT_STATIC);
开发者ID:rokups,项目名称:Urho3D,代码行数:67,代码来源:Urho2DConstraints.cpp

示例9: ApplyNode

virtual void ApplyNode(Node &node) {
		assert(root);
		root->AddChild(node.Clone());
	}
开发者ID:zugz,项目名称:pioneer,代码行数:4,代码来源:Model.cpp

本文标签属性:

示例:示例英语

代码:代码大全可复制

上一篇:Python numpy.nextafter方法代码示例
下一篇:C# BuildingBlock.SetFlag方法代码示例

为您推荐