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


C++ GraphComponentPtr::index方法代码示例

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


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

示例1: removeChild

void GraphComponent::removeChild( GraphComponentPtr child )
{
	if( child->m_parent!=this )
	{
		throw Exception( "Object is not a child." );
	}

	if( refCount() )
	{
		// someone is pointing to us, so we may have a ScriptNode ancestor and we should do things
		// in an undoable way.
		Action::enact(
			this,
			// ok to bind raw pointers to this, because enact() guarantees
			// the lifetime of the subject.
			boost::bind( &GraphComponent::removeChildInternal, this, child, true ),
			boost::bind( &GraphComponent::addChildInternal, this, child, child->index() )
		);
	}
	else
	{
		// we have no references to us - chances are we're in construction still. adding ourselves to an
		// undo queue is impossible, and creating temporary smart pointers to ourselves (as above) will
		// cause our destruction before construction completes. just do the work directly.
		removeChildInternal( child, true );
	}
}
开发者ID:dmar,项目名称:gaffer,代码行数:27,代码来源:GraphComponent.cpp

示例2: addChild

void GraphComponent::addChild( GraphComponentPtr child )
{
	if( child->m_parent==this )
	{
		return;
	}

	throwIfChildRejected( child.get() );

	if( refCount() )
	{
		// someone is pointing to us, so we may have a ScriptNode ancestor and we should do things
		// in an undoable way. figure out what our undo function should be - it varies based on what
		// the previous parent was.
		Action::Function undoFn;
		if( child->m_parent )
		{
			if( child->m_parent->isInstanceOf( (IECore::TypeId)ScriptNodeTypeId ) )
			{
				// use raw pointer to avoid circular reference between script and undo queue
				undoFn = boost::bind( &GraphComponent::addChildInternal, child->m_parent, child, child->index() );
			}
			else
			{
				// use smart pointer to ensure parent remains alive, even if something unscrupulous
				// messes it with non-undoable actions that aren't stored in the undo queue.
				undoFn = boost::bind( &GraphComponent::addChildInternal, GraphComponentPtr( child->m_parent ), child, child->index() );
			}
		}
		else
		{
			// no previous parent.
			undoFn = boost::bind( &GraphComponent::removeChildInternal, this, child, true );
		}

		Action::enact(
			this,
			// ok to use raw pointer for this - lifetime of subject guaranteed.
			boost::bind( &GraphComponent::addChildInternal, this, child, m_children.size() ),
			undoFn
		);
	}
	else
	{
		// we have no references to us - chances are we're in construction still. adding ourselves to an
		// undo queue is impossible, and creating temporary smart pointers to ourselves (as above) will
		// cause our destruction before construction completes. just do the work directly.
		addChildInternal( child, m_children.size() );
	}
}
开发者ID:dmar,项目名称:gaffer,代码行数:50,代码来源:GraphComponent.cpp


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