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


C++ NodeRef类代码示例

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


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

示例1: testCopy

        void testCopy() {

            NodeRef orig = DeviceInterface::create ( "orig" );
            orig->add_child(Terminal::create("child1"));
            orig->add_child(Terminal::create("child2"));
            NodeRef copy(orig);
            
            CPPUNIT_ASSERT ( copy->has_children() );
            CPPUNIT_ASSERT ( std::string("child1") == copy->get_child("child1")->get_name() );
            CPPUNIT_ASSERT ( std::string("child2") == copy->get_child("child2")->get_name() );
            CPPUNIT_ASSERT_THROW ( copy->get_child("child3") , Exception );

            NodeRef orig2 = DeviceInterface::create("orig");
            orig2->add_child(Terminal::create("child3"));
            orig2->add_child(Terminal::create("child4"));
            CPPUNIT_ASSERT_THROW ( orig2->add_child(Terminal::create("child3")), Exception );
            copy = orig2;
            
            CPPUNIT_ASSERT ( copy->has_children() );
            CPPUNIT_ASSERT_THROW ( copy->get_child("child1"), Exception );
            CPPUNIT_ASSERT_EQUAL ( std::string("child3") , copy->get_child("child3")->get_name() );

            int children=0;
            for (DITreeIter i = copy->child_begin(); i != copy->child_end(); ++i ) {
               children += 1; 
            }
            CPPUNIT_ASSERT ( children == 2 );
        };
开发者ID:ubixum,项目名称:nitro,代码行数:28,代码来源:node.cpp

示例2: assert

void Path::moveLeft(unsigned Level) {
  assert(Level != 0 && "Cannot move the root node");

  // Go up the tree until we can go left.
  unsigned l = 0;
  if (valid()) {
    l = Level - 1;
    while (path[l].offset == 0) {
      assert(l != 0 && "Cannot move beyond begin()");
      --l;
    }
  } else if (height() < Level)
    // end() may have created a height=0 path.
    path.resize(Level + 1, Entry(nullptr, 0, 0));

  // NR is the subtree containing our left sibling.
  --path[l].offset;
  NodeRef NR = subtree(l);

  // Get the rightmost node in the subtree.
  for (++l; l != Level; ++l) {
    path[l] = Entry(NR, NR.size() - 1);
    NR = NR.subtree(NR.size() - 1);
  }
  path[l] = Entry(NR, NR.size() - 1);
}
开发者ID:0x00evil,项目名称:llvm,代码行数:26,代码来源:IntervalMap.cpp

示例3: STAT3

  __m256 BVH2Intersector8Chunk<TriangleIntersector>::occluded(const BVH2Intersector8Chunk* This, Ray8& ray, const __m256 valid_i)
  {
    avxb valid = valid_i;
    avxb terminated = !valid;
    const BVH2* bvh = This->bvh;
    STAT3(shadow.travs,1,popcnt(valid),8);

    NodeRef stack[1+BVH2::maxDepth]; //!< stack of nodes that still need to get traversed
    NodeRef* stackPtr = stack;                    //!< current stack pointer
    NodeRef cur = bvh->root;                      //!< in cur we track the ID of the current node

    /* let inactive rays miss all boxes */
    const avx3f rdir = rcp_safe(ray.dir);
    avxf rayFar  = select(terminated,avxf(neg_inf),ray.tfar);

    while (true)
    {
      /*! downtraversal loop */
      while (likely(cur.isNode()))
      {
        STAT3(normal.trav_nodes,1,popcnt(valid),8);

        /* intersect packet with box of both children */
        const Node* node = cur.node();
        const size_t hit0 = intersectBox(ray.org,rdir,ray.tnear,rayFar,node,0);
        const size_t hit1 = intersectBox(ray.org,rdir,ray.tnear,rayFar,node,1);
        
        /*! if two children are hit push both onto stack */
        if (likely(hit0 != 0 && hit1 != 0)) {
          *stackPtr = node->child(0); stackPtr++; cur = node->child(1);
        }
        
        /*! if one child hit, continue with that child */
        else {
          if      (likely(hit0 != 0)) cur = node->child(0);
          else if (likely(hit1 != 0)) cur = node->child(1);
          else goto pop_node;
        }
      }

      /*! leaf node, intersect all triangles */
      {
        STAT3(shadow.trav_leaves,1,popcnt(valid),8);
        size_t num; Triangle* tri = (Triangle*) cur.leaf(NULL,num);
        for (size_t i=0; i<num; i++) {
          terminated |= TriangleIntersector::occluded(valid,ray,tri[i],bvh->vertices);
          if (all(terminated)) return terminated;
        }

        /* let terminated rays miss all boxes */
        rayFar = select(terminated,avxf(neg_inf),rayFar);
      }

      /*! pop next node from stack */
pop_node:
      if (unlikely(stackPtr == stack)) break;
      cur = *(--stackPtr);
    }
    return terminated;
  }
开发者ID:1510649869,项目名称:tungsten,代码行数:60,代码来源:bvh2_intersector8.cpp

示例4: Dijkstra

int Dijkstra(NodeRef start, int want, color color){	//to find distance, create node.prev which contains the prev node.you can go backwards and add up all nodes. 
	priority_queue<NodeRef, vector<NodeRef>, Compare> openSet;
	vector<NodeRef> closedSet;
	openSet.push(start);											//add initial node to open set
	while(openSet.size()!=0){
		NodeRef current = openSet.top();								//node with least cost
		closedSet.push_back(current);
		current -> visited = true;
		if(current->GetId() == want){									//if wanted node is found
			return CalculateCost(edgeList.at(want));		
		}
		openSet.pop();												//remove current node from open set
		if(current->GetCost()==INT_MAX){                               //current node has no connections
			cout<<"No connections found, break"<<endl;
			break;	
		}	 
		for(int link=0; link<(current)->links.size(); link++){
			if((!current->links.at(link)->visited) && current->links.at(link)->color == color){		//if unvisited and correct color
				current->links.at(link)->Visited(true);
				current->links.at(link)->prev = current;											
				int alt = CalculateCost(current) + (CalculateCost(current->links.at(link)) - CalculateCost(current));		//relaxing the edge
				if(alt<CalculateCost(current)){									//if found a faster way
					(current->links.at(link))->cost = alt;				
			}	
				openSet.push(current->links.at(link));							
			}

		}
	}
	return INT_MAX;										//failed to find node
}
开发者ID:smorad,项目名称:advanced-programming,代码行数:31,代码来源:Source.cpp

示例5: loadBoneWeights

void ModelTargetSkinnedVboMesh::loadBoneWeights( const std::vector<BoneWeights>& boneWeights )
{
	std::vector<ci::Vec4f> boneWeightsBuffer;
	std::vector<ci::Vec4f> boneIndicesBuffer;
	
	for( const auto& boneWeight : boneWeights ) {
		ci::Vec4f vWeights = ci::Vec4f::zero();
		ci::Vec4f vIndices = ci::Vec4i::zero();
		for( unsigned int b =0; b < boneWeight.mActiveNbWeights; ++b ) {
			NodeRef bone = boneWeight.getBone( b );
			vWeights[b] = boneWeight.getWeight(b);
			//FIXME: Maybe use ints on the desktop?
			vIndices[b] = bone->getBoneIndex();
		}
		boneWeightsBuffer.push_back( vWeights );
		boneIndicesBuffer.push_back( vIndices );
	}
	
	size_t dataSize = sizeof(GLfloat) * ci::Vec4f::DIM * boneWeightsBuffer.size();
	
	bufferSubData< std::vector<ci::Vec4f> >( boneWeightsBuffer, dataSize );
	setCustomAttribute( mAttribLocation, "boneWeights" );
	incrementOffsets( dataSize );
	
	bufferSubData< std::vector<ci::Vec4f> >( boneIndicesBuffer, dataSize);
	setCustomAttribute( mAttribLocation, "boneIndices" );
	incrementOffsets( dataSize );
	
	mSkinnedVboMesh->getActiveSection()->boneMatrices = &mSkinnedVboMesh->mBoneMatrices;
	mSkinnedVboMesh->getActiveSection()->invTransposeMatrices = &mSkinnedVboMesh->mInvTransposeMatrices;
}
开发者ID:UIKit0,项目名称:Cinder-Skinning,代码行数:31,代码来源:ModelTargetSkinnedVboMesh.cpp

示例6: update_node_location

 /**
  * Update all nodes in a way with the ID of the given NodeRef with the
  * location of the given NodeRef.
  */
 void update_node_location(const NodeRef& new_node_ref) {
     for (auto& node_ref : nodes()) {
         if (node_ref.ref() == new_node_ref.ref()) {
             node_ref.location(new_node_ref.location());
         }
     }
 }
开发者ID:natsumiirimura,项目名称:libosmium,代码行数:11,代码来源:way.hpp

示例7: main

int main()
{
	AudioGraphRef graph = new AudioGraph();

	/*------------------------------------------------------------------------
	 * Create a simple envelope-modulated triangle wave.
	 *-----------------------------------------------------------------------*/
	NodeRef triangle = new Triangle(1000);
	NodeRef envelope = new ASR(0.01, 0.0, 0.1);
	NodeRef output = triangle * envelope;

	/*------------------------------------------------------------------------
	 * Pan the output across the stereo field.
	 *-----------------------------------------------------------------------*/
	NodeRef panned = new Pan(2, output);

	graph->add_output(panned);
	graph->start();

	while (true)
	{
		/*------------------------------------------------------------------------
		 * Periodically, retrigger the envelope, panned to a random location.
		 *-----------------------------------------------------------------------*/
		usleep(random_integer(1e4, 1e6));
		panned->set_input("pan", random_uniform(-1, 1));
		envelope->trigger();
	}
}
开发者ID:cequencer,项目名称:signal,代码行数:29,代码来源:trigger-example.cpp

示例8: signal_assert

void Synth::set_input(std::string name, float value)
{
	NodeRef current = this->inputs[name];
	signal_assert(this->inputs[name] != nullptr, "Synth has no such parameter: %s", name.c_str());
	NodeRef input = this->inputs[name];
	Constant *constant = (Constant *) input.get();
	constant->value = value;
}
开发者ID:cequencer,项目名称:signal,代码行数:8,代码来源:synth.cpp

示例9: id_from_string

void ForwarderRank::_generateDelegatesFor(const DataObjectRef &dObj, const NodeRef &target, const NodeRefList *other_targets)
{
						
	List<Pair<NodeRef, bubble_metric_t> > sorted_delegate_list;
	
	// Figure out which node to look for:
	bubble_node_id_t target_id = id_from_string(target->getIdStr());
	
	LABEL_T targetLabel = rib[target_id].first;
	//RANK_T targetRank = rib[target_id].second;
	
	HAGGLE_DBG("HAGGLE_DBG:_generateDelegatesFor node %d string %s label %s\n", target_id, target->getIdStr(), targetLabel.c_str());


	for (bubble_rib_t::iterator it = rib.begin();it != rib.end(); it++)
	{
		if (it->first != this_node_id && it->first != target_id) {

			NodeRef delegate = kernel->getNodeStore()->retrieve(id_number_to_nodeid[it->first], true);

			if (delegate && !isTarget(delegate, other_targets)) {
				
				LABEL_T &neighborLabel = it->second.first;
				RANK_T &neighborRank = it->second.second;
				
				HAGGLE_DBG("HAGGLE_DBG: _generateDelegatesFor neighborLabel=%s, targetLabel=%s\n", neighborLabel.c_str(), targetLabel.c_str());
				
				if (neighborLabel.compare(targetLabel)==0)
				{
					//NodeRef delegate = Node::create_with_id(Node::TYPE_PEER, id_number_to_nodeid[it->first].c_str(), "Label delegate node");
					sortedNodeListInsert(sorted_delegate_list, delegate, it->second);
					HAGGLE_DBG("HAGGLE_DBG: _generateDelegatesFor Label same: Node '%s' is a good delegate for target '%s' [label=%s, rank=%ld]\n", 
					delegate->getName().c_str(), target->getName().c_str(), neighborLabel.c_str(), neighborRank);
					
				}
			}
		}
	}
	
	// Add up to max_generated_delegates delegates to the result in order of decreasing metric
	if (!sorted_delegate_list.empty()) {
		
		NodeRefList delegates;
		unsigned long num_delegates = max_generated_delegates;
		
		while (num_delegates && sorted_delegate_list.size()) {
			NodeRef delegate = sorted_delegate_list.front().first;
			sorted_delegate_list.pop_front();
			delegates.push_back(delegate);
			num_delegates--;
		}
		kernel->addEvent(new Event(EVENT_TYPE_DELEGATE_NODES, dObj, target, delegates));
		HAGGLE_DBG("HAGGLE_DBG: Forward Generated %lu delegates for target %s\n", delegates.size(), target->getName().c_str());
	} else {
                HAGGLE_DBG("No delegates found for target %s\n", target->getName().c_str());
    }

}
开发者ID:eikoyoneki,项目名称:haggle-cambridge,代码行数:58,代码来源:ForwarderRank.cpp

示例10: update

bool NodeStore::update(NodeRef &node, NodeRefList *nl)
{
        Mutex::AutoLocker l(mutex);
	bool found = false;
	
	if (!node)
		return false;

	// There may be undefined nodes in the node store that should
	// be removed/merged with a 'defined' node that we create from a 
	// node description. We loop through all nodes in the store and
	// compare their interface lists with the one in the 'defined' node.
	// If any interfaces match, we remove the matching nodes in the store 
	// and eventually replace them with the new one.
	for (NodeStore::iterator it = begin(); it != end();) {
		NodeRecord *nr = *it;
		bool found_now = false;
		
		nr->node.lock();

		const InterfaceRefList *ifaces = nr->node->getInterfaces();

		for (InterfaceRefList::const_iterator it2 = ifaces->begin(); it2 != ifaces->end(); it2++) {
			InterfaceRef iface = *it2;

			if (node->hasInterface(iface)) {
				// Transfer all the "up" interface states to the updated node
				if (iface->isUp())
					node->setInterfaceUp(iface);

				found_now = true;
			}
		}
		nr->node.unlock();

		if (found_now) {
			if (nl)
				nl->push_back(nr->node);
			
			nr->node->setStored(false);

			node->setExchangedNodeDescription(nr->node->hasExchangedNodeDescription());
				
			it = erase(it);
			delete nr;
			found = true;
		} else {
			it++;
		}
	}
	if (found) {
		node->setStored(true);
		push_back(new NodeRecord(node));
	}

	return found;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:57,代码来源:NodeStore.cpp

示例11: decode

 virtual void decode(NodeRef& node) {
     string rd;
     in >> rd;
     if (rd == "@") {
         node.reset();
     } else {
         node.set(NodeId(rd));
     }
 }
开发者ID:fabianschuiki,项目名称:Maxwell,代码行数:9,代码来源:Serializer.cpp

示例12: insertChildAt

void Node::insertChildAt( NodeRef child, size_t index )
{
  Node *former_parent = child->getParent();
  if( former_parent ) // remove child from parent (but skip notifying child)
  { vector_remove( &former_parent->mChildren, child ); }
  child->setParent( this );
  mChildren.insert( mChildren.begin() + index, child );
  childAdded( child );
}
开发者ID:Surfincolin,项目名称:Choreograph,代码行数:9,代码来源:Node.cpp

示例13: testRefs

 void testRefs() {
     NodeRef orig = DeviceInterface::create("top");
     orig->add_child(Terminal::create("child1"));
     NodeRef child2 = Register::create("child2");
     CPPUNIT_ASSERT_NO_THROW(orig->get_child ( "child1")->add_child(child2));
     child2->set_attr("test", "hello" );
     CPPUNIT_ASSERT_NO_THROW(orig->get_child ( "child1")->get_child("child2")->get_attr("test"));
     CPPUNIT_ASSERT_EQUAL ( std::string("hello"), (std::string)orig->get_child("child1")->get_child("child2")->get_attr("test"));
 }
开发者ID:ubixum,项目名称:nitro,代码行数:9,代码来源:node.cpp

示例14: getSource

ci::vec2 Event::getScenePos()
{
    NodeRef source = getSource();
    if (source) {
        return source->windowToScene(getWindowPos());
    }

    return getWindowPos();
}
开发者ID:whitegfx,项目名称:Cinder-poScene,代码行数:9,代码来源:poEvents.cpp

示例15: cloneTraversal

void cloneTraversal( const NodeRef& origin, NodeRef& copy )
{
	for( const auto& originChild : origin->getChildren() ) {
		NodeRef copyChild = originChild->clone();
		copyChild->setParent( copy );
		copy->addChild( copyChild );
		cloneTraversal( originChild, copyChild );
	}
}
开发者ID:UIKit0,项目名称:Cinder-Skinning,代码行数:9,代码来源:Skeleton.cpp


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