Beispiel #1
0
template<class NodeVector> void FileSystem::debugPrintNodes(NodeVector nodes) {
    if( debug) {
        unsigned int ix;
        NodeInfo* node;

        for (ix = 0; ix < nodes.size(); ++ix) {
            node = nodes.at(ix);

            cout << "Node: " << node->getName()
                << "\t\tSize: " << node->getSize()
                << "\tModify: " << node->getModifyTime()
                << "\tPath: " << node->getPath()
                << "\tSimilars: ";
        
            vector<NodeInfo*>::iterator it;
            vector<NodeInfo*> nodes = node->getSimilar();
            for(it=nodes.begin(); it != nodes.end(); ++it) {
                cout << (*it)->getPath() << ", ";
            }

            cout << endl;
        }
    }

}
boost::optional<ParentObject> SetpointManagerMixedAir_Impl::parent() const {
  NodeVector nodes = getObject<ModelObject>().getModelObjectSources<Node>();
  if (nodes.size() == 1u) {
    return nodes[0];
  }
  return boost::none;
}
Beispiel #3
0
void mergeVectors(NodeVector* some, NodeVector more) { // bool keep destination unmodified=TRUE
//	return std::set_union(some,&more);
	for (int i=0; i < more.size(); i++) {
		if (!contains(*some, (Node*) more[i], false))
//		if (std::find(some->begin(), some->end(), more[i]) == some->end())// NOT contains x yet
            some->push_back(more[i]);
	}
}
Beispiel #4
0
shared_ptr<Node> op::Constant::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 0)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }
    return make_shared<Constant>(m_element_type, m_shape, m_data);
}
Beispiel #5
0
shared_ptr<Node> op::Cos::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 1)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }
    return make_shared<Cos>(new_args.at(0));
}
Beispiel #6
0
shared_ptr<Node> op::OneHot::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 1)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }
    return make_shared<OneHot>(new_args.at(0), m_shape, m_one_hot_axis);
}
Beispiel #7
0
shared_ptr<Node> op::Min::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 1)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }
    return make_shared<Min>(new_args.at(0), m_reduction_axes);
}
Beispiel #8
0
shared_ptr<Node> op::GetOutputElement::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 1)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }
    return make_shared<GetOutputElement>(new_args.at(0), m_n);
}
Beispiel #9
0
bool contains(NodeVector& all, Node& node, bool fuzzy) {
//	if(!fuzzy)
//		return contains2(all,&node);
	for (int i=0; i < all.size(); i++) {
		if ((Node*) all[i] == &node) return true;
		if (fuzzy && eq(all[i], &node)) return true;
	}
	return false;
}
Beispiel #10
0
bool contains(NodeVector& all, Node* node, bool fuzzy) {
//	return contains2(all,node);
	for (int i=0; i < all.size(); i++) {
		Node* n=(Node*) all[i];
		if (n == node || (fuzzy && eq(n, node)))
			return true;
	}
	return false;
}
Beispiel #11
0
vector<Algorithm*> Network::innerVisibleAlgorithms(Algorithm* algo) {
  NetworkNode* visibleNetworkRoot = visibleNetwork<NetworkNode>(algo);

  vector<Algorithm*> algos = depthFirstMap(visibleNetworkRoot, returnAlgorithm);

  NodeVector nodes = depthFirstSearch(visibleNetworkRoot);
  for (int i=0; i<(int)nodes.size(); i++) delete nodes[i];

  return algos;
}
Beispiel #12
0
/**
 * Returns true if both qualified types %a and %b are equivalent, i.e. have the
 * same members, interfaces, ranges and native type equivalents.
 */
bool equal(const QualifiedType::Ptr& a, const QualifiedType::Ptr& b)
{
	// Treat the trivial cases where the number of fields does not match.
	const NodeVector& membersA = a->getMembers(), membersB = b->getMembers();
	if (membersA.size() != membersB.size()) return false;
	const NodeVector& funcsA = a->getFuncs(), funcsB = b->getFuncs();
	if (funcsA.size() != funcsB.size()) return false;

	// Check each member separately.
	for (NodeVector::const_iterator ia = membersA.begin(), ib = membersB.begin(); ia != membersA.end() && ib != membersB.end(); ia++, ib++) {
		const QualifiedTypeMember::Ptr& memberA = QualifiedTypeMember::needFrom(*ia), memberB = QualifiedTypeMember::needFrom(*ib);
		if (memberA->getName() != memberB->getName())
			return false;
		if (!equal(memberA->getType(), memberB->getType()))
			return false;
	}

	// TODO: do the same for interface stuff.
	return true;
}
Beispiel #13
0
// this differs from other remove functions because it forcibly removes all the children,
// regardless of read-only status or event exceptions, e.g.
void ContainerNode::removeChildren()
{
    if (!m_firstChild)
        return;

    // The container node can be removed from event handlers.
    RefPtr<ContainerNode> protect(this);

    // exclude this node when looking for removed focusedNode since only children will be removed
    document().removeFocusedNodeOfSubtree(this, true);

#if ENABLE(FULLSCREEN_API)
    document().removeFullScreenElementOfSubtree(this, true);
#endif

    // Do any prep work needed before actually starting to detach
    // and remove... e.g. stop loading frames, fire unload events.
    willRemoveChildren(protect.get());

    NodeVector removedChildren;
    {
        WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
        {
            NoEventDispatchAssertion assertNoEventDispatch;
            removedChildren.reserveInitialCapacity(childNodeCount());
            while (RefPtr<Node> n = m_firstChild) {
                removedChildren.append(m_firstChild);
                removeBetween(0, m_firstChild->nextSibling(), m_firstChild);
            }
        }

        childrenChanged(false, 0, 0, -static_cast<int>(removedChildren.size()));
        
        for (size_t i = 0; i < removedChildren.size(); ++i)
            ChildNodeRemovalNotifier(this).notify(removedChildren[i].get());
    }

    dispatchSubtreeModifiedEvent();
}
Beispiel #14
0
Node* XPathResult::snapshotItem(unsigned long index, ExceptionCode& ec)
{
    if (resultType() != UNORDERED_NODE_SNAPSHOT_TYPE && resultType() != ORDERED_NODE_SNAPSHOT_TYPE) {
        ec = TYPE_ERR;
        return 0;
    }
    
    NodeVector nodes = m_value.toNodeVector();
    if (index >= nodes.size())
        return 0;
    
    return nodes[index].get();
}
Beispiel #15
0
Node* XPathResult::singleNodeValue(ExceptionCode& ec) const
{
    if (resultType() != ANY_UNORDERED_NODE_TYPE && resultType() != FIRST_ORDERED_NODE_TYPE) {
        ec = TYPE_ERR;
        return 0;
    }
  
    NodeVector nodes = m_value.toNodeVector();
    if (nodes.size () == 0)
        return 0;

    return nodes[0].get();
}
Beispiel #16
0
void ContainerNode::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
    Node::reportMemoryUsage(memoryObjectInfo);
    info.ignoreMember(m_firstChild);
    info.ignoreMember(m_lastChild);

    // Report child nodes as direct members to make them look like a tree in the snapshot.
    NodeVector children;
    getChildNodes(const_cast<ContainerNode*>(this), children);
    for (size_t i = 0; i < children.size(); ++i)
        info.addMember(children[i], "child");
}
Beispiel #17
0
/**
 * Simplifies the given TypeSet by removing duplicate types. If the resulting
 * TypeSet contains only one type, that type is returned instead of the set.
 */
NodePtr simplify(const TypeSet::Ptr& input)
{
	// Remove duplicate types.
	NodeVector newTypes;
	copyUnique(input->getTypes(), newTypes);

	// Return either the new set or the only type left in the set, if there's one.
	if (newTypes.size() == 1) {
		return newTypes.front();
	}
	TypeSet::Ptr ts(new TypeSet);
	ts->setTypes(newTypes);
	return ts;
}
Beispiel #18
0
/**
 * Simplifies the given UnionType by removing duplicate types. If the resulting
 * UnionType contains only one type, that type is returned instead of the union.
 */
NodePtr simplify(const UnionType::Ptr& input)
{
	// Remove duplicate types.
	NodeVector newTypes;
	copyUnique(input->getTypes(), newTypes);

	// Return either the new union or the only type left in the vector, if there's one.
	if (newTypes.size() == 1) {
		return newTypes.front();
	}
	UnionType::Ptr ut(new UnionType);
	ut->setTypes(newTypes);
	return ut;
}
Beispiel #19
0
Algorithm* Network::findAlgorithm(const std::string& name) {
  NodeVector nodes = depthFirstSearch(_visibleNetworkRoot);
  for (NodeVector::iterator node = nodes.begin(); node != nodes.end(); ++node) {
    if ((*node)->algorithm()->name() == name) return (*node)->algorithm();
  }

  ostringstream msg;
  msg << "Could not find algorithm with name '" << name << "'. Known algorithms are: ";
  if (!nodes.empty()) msg << '\'' << nodes[0]->algorithm()->name() << '\'';
  for (int i=1; i<(int)nodes.size(); i++) {
    msg << ", '" << nodes[i]->algorithm()->name() << '\'';
  }
  throw EssentiaException(msg);
}
Beispiel #20
0
Value FunSum::doEvaluate() const
{
    Value a = arg(0)->evaluate();
    if (!a.isNodeVector())
        return 0.0;

    double sum = 0.0;
    NodeVector nodes = a.toNodeVector();
    
    for (unsigned i = 0; i < nodes.size(); i++)
        sum += Value(stringValue(nodes[i].get())).toNumber();
    
    return sum;
}
Beispiel #21
0
unsigned sure::keypoints::extractKeypoints(Octree& octree, Scalar samplingrate, Scalar searchRadius, Scalar featureRadius, std::vector<Feature>& features, std::vector<Node*>& keypointNodes)
{
  unsigned samplingDepth = octree.getDepth(samplingrate);
  unsigned keypoints(0);

  for(unsigned int i=0; i<octree[samplingDepth].size(); ++i)
  {
    Node* currNode = octree[samplingDepth][i];
    EntropyPayload* payload = static_cast<EntropyPayload*>(currNode->opt());
    if( payload->flag_ != POSSIBLE )
    {
      continue;
    }
    NodeVector neighbors = octree.getNodes(currNode, octree.getUnitSize(searchRadius));
    for(unsigned int j=0; j<neighbors.size(); ++j)
    {
      Node* currNeighbor = neighbors[j];
      EntropyPayload* neighborPayload = static_cast<EntropyPayload*>(currNeighbor->opt());
      if( neighborPayload->flag_ == IS_MAXIMUM )
      {
        payload->flag_ = SUPPRESSED;
        break;
      }
      else if( neighborPayload->flag_ == POSSIBLE )
      {
        if( payload->entropy_ < neighborPayload->entropy_ )
        {
          payload->flag_ = SUPPRESSED;
          break;
        }
      }
      else
      {
        continue;
      }
    }
    if( payload->flag_ == POSSIBLE )
    {
      payload->flag_ = IS_MAXIMUM;
      sure::feature::Feature f;

      f.radius() = featureRadius;
      f.position() = currNode->fixed().getMeanPosition();
      features.push_back(f);
      keypointNodes.push_back(currNode);
      keypoints++;
    }
  }
  return keypoints;
}
Beispiel #22
0
shared_ptr<Node> op::ReduceWindow::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 2)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }
    auto node = make_shared<ReduceWindow>(new_args.at(0),
                                          new_args.at(1),
                                          m_reduction_function,
                                          m_window_shape,
                                          m_window_movement_strides);
    node->m_reduction_function = clone_function(*m_reduction_function);
    return node;
}
Beispiel #23
0
Surface render(NodeVector nodes)
{
	Surface surf;
	int chx = 0;

	int i=0;
	while (i < nodes.size()) {
		NodePtr node = nodes[i];

		// Check for special case where sub- and super-script
		// preceed one another (in either  order)
		if (i+1 < nodes.size()) {
			NodePtr next = nodes[i+1];

			if ((next->getText() == "^" || next->getText() == "_") &&
				(node->getText() == "^" || node->getText() == "_") &&
				node->getText() != next->getText()) {
				Surface s1, s2;
				s1 = render(node);
				s2 = render(next);
				surf.addSurface(chx, s1);
				surf.addSurface(chx, s2);
				chx += surfMaxW(s1, s2);
				i += 2;
				continue;
			}
		}

		Surface sub = render(node);
		surf.addSurface(chx, sub);
		chx += sub.getBox().w;

		i++;
	}

	return surf;
}
Beispiel #24
0
std::shared_ptr<Node> op::ConvolutionRelu::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 2)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }

    return std::shared_ptr<Node>(new ConvolutionRelu(new_args.at(0),
                                                     new_args.at(1),
                                                     get_window_movement_strides(),
                                                     get_window_dilation_strides(),
                                                     get_padding_below(),
                                                     get_padding_above(),
                                                     get_data_dilation_strides()));
}
Beispiel #25
0
/**
 * Returns true if the types in vector %a are all present in %b, and vice versa.
 * Useful for equality checks on TypeSet and UnionType nodes. The algorithm is
 * quite allergic to vectors that contain duplicate types.
 */
bool equalTypes(const NodeVector& a, const NodeVector& b)
{
	// Catch the trivial case of vectors that are not of equal length.
	if (a.size() != b.size()) return false;

	// Iterate through the first vector, counting the removed nodes in the other.
	// If a node cannot be found in the other, equality fails. If any nodes are
	// left in the other afterwards, equality fails as well.
	int found = 0;
	for (NodeVector::const_iterator ia = a.begin(); ia != a.end(); ia++) {
		bool anythingFound = false;
		for (NodeVector::const_iterator ib = b.begin(); ib != b.end(); ib++) {
			if (equal(*ia,*ib)) {
				found++;
				anythingFound = true;
			}
		}
		if (!anythingFound) return false; // since *ia is not present in b
	}

	// If 'found' does not equal b's length, there are elements left in
	// b that were not present in a, in which case the equality fails.
	return (found == b.size());
}
static void swapInNodePreservingAttributesAndChildren(HTMLElement* newNode, HTMLElement* nodeToReplace)
{
    ASSERT(nodeToReplace->inDocument());
    RefPtr<ContainerNode> parentNode = nodeToReplace->parentNode();

    // FIXME: Fix this to send the proper MutationRecords when MutationObservers are present.
    newNode->cloneDataFromElement(*nodeToReplace);
    NodeVector children;
    getChildNodes(*nodeToReplace, children);
    for (size_t i = 0; i < children.size(); ++i)
        newNode->appendChild(&children[i].get(), ASSERT_NO_EXCEPTION);

    parentNode->insertBefore(newNode, nodeToReplace, ASSERT_NO_EXCEPTION);
    parentNode->removeChild(nodeToReplace, ASSERT_NO_EXCEPTION);
}
Beispiel #27
0
shared_ptr<Node>
    op::ConvolutionBiasBackpropFiltersBias::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 2)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }
    return make_shared<ConvolutionBiasBackpropFiltersBias>(new_args.at(0),
                                                           m_filters_shape,
                                                           m_bias_shape,
                                                           new_args.at(1),
                                                           m_window_movement_strides_forward,
                                                           m_window_dilation_strides_forward,
                                                           m_padding_below_forward,
                                                           m_padding_above_forward,
                                                           m_data_dilation_strides_forward);
}
Beispiel #28
0
// this differs from other remove functions because it forcibly removes all the children,
// regardless of read-only status or event exceptions, e.g.
void ContainerNode::removeChildren()
{
    if (!m_firstChild)
        return;

    // The container node can be removed from event handlers.
    Ref<ContainerNode> protect(*this);

    // exclude this node when looking for removed focusedNode since only children will be removed
    document().removeFocusedNodeOfSubtree(this, true);

#if ENABLE(FULLSCREEN_API)
    document().removeFullScreenElementOfSubtree(this, true);
#endif

    // Do any prep work needed before actually starting to detach
    // and remove... e.g. stop loading frames, fire unload events.
    willRemoveChildren(*this);

    NodeVector removedChildren;
    {
        WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
        {
            NoEventDispatchAssertion assertNoEventDispatch;
            removedChildren.reserveInitialCapacity(countChildNodes());
            while (RefPtr<Node> n = m_firstChild) {
                removedChildren.append(*m_firstChild);
                removeBetween(0, m_firstChild->nextSibling(), *m_firstChild);
            }
        }

        ChildChange change = { AllChildrenRemoved, nullptr, nullptr, ChildChangeSourceAPI };
        childrenChanged(change);
        
        for (size_t i = 0; i < removedChildren.size(); ++i)
            ChildNodeRemovalNotifier(*this).notify(removedChildren[i].get());
    }

    if (document().svgExtensions()) {
        Element* shadowHost = this->shadowHost();
        if (!shadowHost || !shadowHost->hasTagName(SVGNames::useTag))
            document().accessSVGExtensions()->rebuildElements();
    }

    dispatchSubtreeModifiedEvent();
}
void GenImplicitAccessors::process(const NodePtr& node)
{
	// Process children.
	processChildren(node);

	// Gather implicit accessors for root type definitions.
	if (const TypeDef::Ptr& typeDef = TypeDef::from(node)) {
		NodeVector implicits;
		gatherImplAccessors(typeDef, implicits);
		println(0, "Gathered " + lexical_cast<string>(implicits.size()) + " implicit accessors of " + typeDef->getId().str() + ".");

		// Add the accessors to the repository.
		for (NodeVector::iterator it = implicits.begin(); it != implicits.end(); it++) {
			repository.addExportedSymbol((*it)->getId(), (*it)->needNamed()->getName());
		}
	}
}
Beispiel #30
0
shared_ptr<Node> op::Result::copy_with_new_args(const NodeVector& new_args) const
{
    if (new_args.size() != 1)
    {
        throw ngraph_error("Incorrect number of new arguments");
    }

    if (new_args.at(0)->get_outputs().size() != 1)
    {
        throw ngraph_error("Expected a single-output argument");
    }

    auto res = make_shared<Result>(new_args.at(0));
    res->set_needs_copy(m_needs_copy);
    res->set_needs_default_layout(m_needs_default_layout);
    return res;
}