xml_node ModelToXmlConverter::appendNode(const Node& node, xml_node& xnode)
{
    Logger::entry("info") << "Appending child " << node.name();
    xml_node newNode = xnode.append_child(node.name().c_str());
    if (node.hasValue())
    {
        newNode.append_child(node_pcdata).set_value(node.value().c_str());
    }
    if (newNode.empty())
    {
        Logger::entry("info") << "Error when adding new xml node " << node.name() << ". Skipping node.";
        return newNode;
    }
    list< Attribute > attributes = node.attributes();
    list< Attribute >::iterator attrIt = attributes.begin();
    for (; attrIt != attributes.end(); ++attrIt)
    {
        xml_attribute attr = newNode.append_attribute(attrIt->name().c_str());
        if (attr.empty())
        {
            Logger::entry("info") << "Error when adding new attribute " << attrIt->name() << " to node " << node.name() << ". Skipping attribute.";
            continue;
        }
        attr.set_value(attrIt->value().c_str());
    }
    return newNode;
}
    void set_default_element_dependent_attributes(Node& node)
    {
        if (boost::empty(node%Name_elementType))
            node%Name_elementType = node.name();

        if (boost::empty(node%Name_id))
            node%Name_id = pstade::ustring("unnamed_")|oven::jointed(node.name());

        if (boost::empty(node%Name_accName))
            node%Name_accName  = node%Name_id;
    }
Example #3
0
static void updateAsPattern( Node node, const bool val_vs_var ) {
	if ( node->hasName( ID ) ) {
		node->name() = VAR;
		node->putAttribute( GNX_VID_PROTECTED, val_vs_var ? "true" : "false" );
	} else if ( node->hasName( CONSTANT ) && node->hasAttribute( CONSTANT_WAS_ANON ) ) {
		node->name() = VAR;
		node->removeAttribute( CONSTANT_TYPE );
		node->removeAttribute( CONSTANT_VALUE );
	} else if ( node->hasName( SEQ ) ) {
		for ( Ginger::MnxChildIterator chit( node ); !!chit; ++chit ) {
			Node child = *chit;
			updateAsPattern( child, val_vs_var );
		}
	}
}
boost::optional<IdfObject> ForwardTranslator::createAirLoopHVACSupplyPath( const Node & demandInletNode )
{
  boost::optional<IdfObject> supplyPathIdf;

  if( auto t_airLoopHVAC = demandInletNode.airLoopHVAC() ) {
    IdfObject supplyPathIdf(openstudio::IddObjectType::AirLoopHVAC_SupplyPath);
    m_idfObjects.push_back(supplyPathIdf);

    supplyPathIdf.setName(t_airLoopHVAC->name().get() + " " + demandInletNode.name().get() + " Supply Path");

    supplyPathIdf.setString(openstudio::AirLoopHVAC_SupplyPathFields::SupplyAirPathInletNodeName,demandInletNode.name().get());

    auto t_comps = t_airLoopHVAC->demandComponents(demandInletNode,t_airLoopHVAC->demandOutletNode());
    auto splitters = subsetCastVector<model::AirLoopHVACZoneSplitter>(t_comps);
    OS_ASSERT(splitters.size() == 1u);

    boost::optional<IdfObject> _zoneSplitter = translateAndMapModelObject(splitters.front());
    OS_ASSERT(_zoneSplitter);
    IdfExtensibleGroup eg = supplyPathIdf.pushExtensibleGroup();
    eg.setString(AirLoopHVAC_SupplyPathExtensibleFields::ComponentObjectType,_zoneSplitter->iddObject().name());
    eg.setString(AirLoopHVAC_SupplyPathExtensibleFields::ComponentName,_zoneSplitter->name().get());

    std::vector<ModelObject> supplyPlenums = t_airLoopHVAC->demandComponents(demandInletNode,t_airLoopHVAC->demandOutletNode(),AirLoopHVACSupplyPlenum::iddObjectType());
    for( auto & supplyPlenum : supplyPlenums )
    {
      eg = supplyPathIdf.pushExtensibleGroup();
      boost::optional<IdfObject> _supplyPlenum = translateAndMapModelObject(supplyPlenum);
      OS_ASSERT(_supplyPlenum);
      eg.setString(AirLoopHVAC_SupplyPathExtensibleFields::ComponentObjectType,_supplyPlenum->iddObject().name());
      eg.setString(AirLoopHVAC_SupplyPathExtensibleFields::ComponentName,_supplyPlenum->name().get());
    }
  }

  return supplyPathIdf;
}
Example #5
0
Node ReadStateClass::readQueryPrec( const int prec ) {
	Node e = this->readExprPrec( prec );
	const std::string name = e->name();
	if ( 
		name == BIND 	||
		name == IN 		||
		name == FROM 	||
		name == WHERE 	||
		name == WHILE   ||
		name == ZIP 	||
		name == CROSS 	||
		name == OK 		||
		name == FINALLY ||
		name == DO
	) {
		return e;
	} else {
		NodeFactory where;
		where.start( WHERE );
		where.start( OK );
		where.end();
		where.add( e );
		where.end();
		return where.build();
	}
}
Example #6
0
void Node::print(const string& connect)
{
   for (CNodeIter iter = m_nodes.begin(); iter != m_nodes.end(); ++iter) {
      Node* pNode    = *iter;
      CNodeIter next = iter;
      ++next;

      if (next != m_nodes.end()) {
         cout << connect << "+---" << pNode->name() << endl;
         pNode->print(connect + "|   ");
      } else {
         cout << connect << "\\---" << pNode->name() << endl;
         pNode->print(connect + "    ");
      }
   }
}
Example #7
0
sg::Node* CSgviewerDoc::pickNode( float x, float y, float* distance )
{
	if ( scene )
	{
		Camera* cam = cameras[camera];

		float dx = ( Math::tan( cam->horizontalFov() / 2.f ) * cam->front() * x );
		float dy = ( Math::tan( cam->verticalFov() / 2.f ) * cam->front() * y );
		Vector3 wtarget = ( cam->worldTransform().translation() + 
			cam->worldTransform().rotation().getColumn(0) * dx +
			cam->worldTransform().rotation().getColumn(1) * dy +
			cam->worldTransform().rotation().getColumn(2) * cam->front() );

		Vector3 wpos = cam->worldTransform().translation();
		Vector3 wdir = (wtarget - wpos).normalize();

		Node* node = CameraUtil::pick( scene, wpos, wdir, distance );
		if ( node )
		{
			OutputDebugString( "Picked " );
			char str[256];
			node->name().getBytes( str, sizeof(str), "ASCII-7" );
			OutputDebugString( str );
			OutputDebugString( "\n" );
		}

		return node;
	}
	return 0;
}
Example #8
0
void MoMa::SceneApp::draw( Node node ) {

    if( node.hasRotation() ) {

        ofBoxPrimitive box; box.set( nodeSize );

        box.setPosition( toVec3f( node.position ) );
        box.setOrientation( toVec3f( node.rotation ) );

        box.draw();

    } else {

        ofSpherePrimitive sphere; sphere.setRadius( nodeSize/2 );
        sphere.setPosition( toVec3f( node.position ) );

        sphere.draw();
    }

    string tag = "";
    if( isNodeNames ) tag  = node.name();
    if( node.hasTime() && isTimeTags ) tag
        += ( "(" + ofToString( node.time() ) + ")" );

    ofPushStyle();
    ofSetColor( ofGetStyle().color, 120 ); // Keep color but add alpha
    ofDrawBitmapString( tag, toVec3f( node.position ) + nodeSize/1.5f );
    ofPopStyle();
}
Example #9
0
Node::Node(const Node &rhs)
{
	m_name = rhs.name();
	m_distanceToParent = rhs.distanceToParent();
	
	m_parent = NULL;
	m_children.clear();
}
Example #10
0
TEST_F(SorterTest, TestOfflineCount)
{
    /*
    fake root group "Contacts"
    real group "Contacts"
    when you group offline contacts, the total number is missing (likely from the fake group)
    */

    auto_ptr<BuddyListSorter> sorter(new BuddyListSorter());
    sorter->addSorter(new ByFakeRoot(L"Contacts"));
    sorter->addSorter(new ByGroup(true, 2));
    sorter->addSorter(new ByOnline(true, true));
    GroupPtr root(new Group(L"root"));
    Group* root1 = new Group(L"root1");
    Group* contacts = new Group(L"contacts");
    Group* root2 = new Group(L"root2");

    Buddy* offlineBuddy = sorter->account(L"digsby01", L"aim")->buddy(L"digsby13");
    offlineBuddy->setStatus(L"offline");
    contacts->addChild(offlineBuddy);

    Buddy* offlineBuddy2 = sorter->account(L"digsby01", L"aim")->buddy(L"digsby2000");
    offlineBuddy->setStatus(L"offline");

    root1->addChild(contacts);

    root2->addChild(offlineBuddy2);

    root->addChild(root1);
    root->addChild(root2);

    sorter->setRoot(root.get()); 
    NodePtr n(sorter->gather()); 
    ASSERT_EQ(2, n->numChildren());

    // the contacts group was merged from a fake root group, and the real
    // contacts group, and should have two "missing" nodes.
    Node* contactsGroup = n->children()[0];
    ASSERT_EQ(L"contacts", contactsGroup->name());
    ASSERT_EQ(2, contactsGroup->missing());

    // both buddies should be in the offline group.
    Node* offlineGroup = n->children()[1];
    ASSERT_EQ(L"Offline", offlineGroup->name());
    ASSERT_EQ(2, offlineGroup->numChildren());
}
Example #11
0
	bool ImplNodeEx::is_path_equal(const Node& other) const noexcept
	{
		if (cstr::compare_ci(name(), other->name()) != 0)
			return false;
		if (parent_)
			return parent_->is_path_equal(other->get_parent());
		return true;
	}
Example #12
0
Node* NodeUtil::findNodeByName( Node* root, const String& name )
{
	for ( Node* node = root ; node ; node = node->nextInHierarchy() )
	{
		if ( node->name() == name )
			return node;
	}
	return 0;
}
Example #13
0
	void squash( NodeFactory acc, Node rhs ) {
		const std::string 
		name = rhs->name();
		if ( name == SEQ ) {
			int n = rhs->size();
			for ( int i = 0; i < n; i++ ) {
				squash( acc, rhs->getChild( i ) );
			}
		} else {
			acc.add( rhs );
		}
	}
Example #14
0
Node *Node::findNode(const std::string &name){
	Node *foundNode = 0;
	for(std::vector<Node*>::iterator it = _nodes.begin(); it != _nodes.end(); ++it){
		Node *node = *it;
		if(node->name() == name){
			foundNode = node;
			break;
		}
	}
	
	return foundNode;
}
Example #15
0
void HaveClip::verificationRequest(const Node &n)
{
	qDebug() << "Verification requested" << n.name() << n.host() << n.port();

	SecurityCodePrompt *prompt = new SecurityCodePrompt(n, manager->connectionManager());

	if(prompt->exec() == QDialog::Accepted)
	{
		//
	}

	prompt->deleteLater();
}
Example #16
0
/// Get full path of this node
std::string Node::uri() const {
  Node* par = _parent;
  std::stringstream path;
  std::deque<std::string> names;
  names.push_front(name());
  while (par != nullptr) {
    names.push_front(par->name());
    par = par->_parent;
  }
  for (size_t i = 1; i < names.size(); ++i) {
    path << "/" << names.at(i);
  }
  return path.str();
}
Example #17
0
bool Node::lookupAttribute( const std::string &name, std::string &data ) const
{
    for( unsigned int i = 0; i < getNodeCount(); ++i )
    {
        Node *node = getNode( i );
        if( node->nodeType() != Attribute || node->name() != name )
            continue;

        data = node->data();
        return true;
    }

    return false;
}
Example #18
0
bool CvsParser::ignore(const Node& node) {
    // No need to check more
    if (_mode == parser_modifiedandothers) {
        return false;
    }

    // Do not ignore control directory
    if (! strcmp(node.name(), _control_dir) && (node.type() == 'd')) {
        return false;
    }

    // Look for match in list
    bool controlled = false;
    for (_i = _files.begin(); _i != _files.end(); _i++) {
        if (! strcmp(_i->name(), node.name()) && (_i->type() == node.type())) {
            controlled = true;
            break;
        }
    }

    // Deal with result
    switch (_mode) {
    // We don't know whether controlled files are modified or not
    case parser_controlled:
    case parser_modified:
        if (controlled) return false;
        else return true;
    case parser_modifiedandothers:
        return false;
    case parser_others:
        if (controlled) return true;
        else return false;
    default:  // parser_disabled
        return false;
    }
}
Example #19
0
void NodeRegistry::printRegisteredNodes() {
    cout << "I has " << _registers.size() << " nodes registered" << endl;
    
    map<string, node_creator>::iterator myIt;
    for(myIt = _registers.begin(); myIt != _registers.end(); myIt++) {
        string myIdentifier = myIt->first;

        node_creator myCreator = myIt->second;
        Node* myNode = myCreator();
        
        cout << "[" << myIdentifier << "] " << myNode->name() << endl;

        delete myNode;
    }
    
}
Example #20
0
	ImplNodeEx::ImplNodeEx(const fsys::IFindStat& stat, const Node& parent) noexcept
		: name_(stat.name())
		, parent_(parent)
	{
		LogTraceObj();
		LogTrace2(L"('%s', '%s')", this->name(), parent ? parent->name() : L"");
		memory::zero(data_);
		data_.dwFileAttributes = static_cast<decltype(data_.dwFileAttributes)>(stat.attr());
		data_.ftCreationTime.dwHighDateTime = static_cast<decltype(data_.ftCreationTime.dwHighDateTime)>(high_part_64(stat.ctime()));
		data_.ftCreationTime.dwLowDateTime = static_cast<decltype(data_.ftCreationTime.dwLowDateTime)>(low_part_64(stat.ctime()));
		data_.ftLastAccessTime.dwHighDateTime = static_cast<decltype(data_.ftLastAccessTime.dwHighDateTime)>(high_part_64(stat.atime()));
		data_.ftLastAccessTime.dwLowDateTime = static_cast<decltype(data_.ftLastAccessTime.dwLowDateTime)>(low_part_64(stat.atime()));
		data_.ftLastWriteTime.dwHighDateTime = static_cast<decltype(data_.ftLastWriteTime.dwHighDateTime)>(high_part_64(stat.mtime()));
		data_.ftLastWriteTime.dwLowDateTime = static_cast<decltype(data_.ftLastWriteTime.dwLowDateTime)>(low_part_64(stat.mtime()));
		data_.nFileSizeHigh = static_cast<decltype(data_.nFileSizeHigh)>(high_part_64(stat.size()));
		data_.nFileSizeLow = static_cast<decltype(data_.nFileSizeLow)>(low_part_64(stat.size()));
	}
Example #21
0
void GameDynamicObject::applyWorldSpaceAnimations()
{
	if ( m_worldAnim )
	{
		for ( Node* node = m_geometry ; node ; node = node->nextInHierarchy() )
		{
			Node* animNode = NodeUtil::findNodeByName( m_worldAnim, node->name() );
			if ( animNode )
			{
				//Animatable* anims[] = {animNode};
				//float weight = 1.f;
				//node->blendState( anims, &m_worldAnimTime, &weight, 1 );
				node->setTransform( animNode->transform() );
			}
		}
	}
}
Example #22
0
static Node makeApp( Node lhs, Node rhs ) {
	if ( lhs->name() == GNX_SYSFN ) {
		NodeFactory sysapp;
		sysapp.start( SYSAPP );
		std::string name = lhs->attribute( GNX_SYSFN_VALUE );
		sysapp.put( SYSAPP_NAME, name );
		sysapp.add( rhs );
		sysapp.end();
		return sysapp.build();
	} else {
		NodeFactory app;
		app.start( APP );
		app.add( lhs );
		app.add( rhs );
		app.end();
		return app.build();
	}
}
Example #23
0
bool Node::lookupAttribute( const std::string &name, int &data ) const
{
    for( unsigned int i = 0; i < getNodeCount(); ++i )
    {
        Node *node = getNode( i );
        if( node->nodeType() != Attribute || node->name() != name )
            continue;

        if( node->data().find( "0x" ) == 0 )
        {
            data = strtol( node->data().substr( 2, node->data().length() - 2 ).c_str(), 0, 16 );
        }
        else
            data = atoi( node->data().c_str() );
        return true;
    }

    return false;
}
Example #24
0
void
Downloader::downloadNode (Node& node, const boost::filesystem::path& path)
{
    TransferProgress saved{};
    {
        std::lock_guard<std::mutex> l{_mut};
        saved = _progress;
    }

    try
    {
        doDownloadNode(node, path);
    }
    catch (const std::exception&)
    {
        if (_downloading != nullptr && _downloading->state() == FileTransferer::State::canceled)
        {
            // Ignore cancel errors
            // TODO: this should be reported.
            std::lock_guard<std::mutex> l{_mut};
            _downloading = nullptr;
            return;
        }

        auto error = utils::exceptionInfos();
        GIGA_DEBUG_LOG(debug, error);
        try
        {
            saved.fileDone += node.type() == Node::Type::file ? 1 : node.nbFiles();
            saved.bytesTransfered += node.size();

            std::lock_guard<std::mutex> l{_mut};
            _progress = saved;
            _onErrorFct(node.id(), node.name(), std::move(error));
            _downloading = nullptr;
        }
        catch (...)
        {
            GIGA_DEBUG_LOG(warning, utils::exceptionInfos());
        }
    }
}
Example #25
0
TEST_F(SorterTest, MergesGroupsCaseInsensitive)
{
    auto_ptr<BuddyListSorter> sorter(new BuddyListSorter());
    sorter->addSorter(new ByGroup(true, 2));

    // Check that two subgroups with the same name (case insensitive) are merged.
    GroupPtr g(new Group(L"root"));
    Group* r1 = new Group(L"subroot");
    Group* r2 = new Group(L"subroot2");
    Group* r3 = new Group(L"subroot3");
    Group* r4 = new Group(L"subroot4");

    // Lots of groups with different case
    Group* dotsyntax1 = new Group(L"dotsyntax");
    Group* dotsyntax2 = new Group(L"dotSyntax");
    Group* dotsyntax3 = new Group(L"dOTSyntaX");
    Group* dotsyntax4 = new Group(L"dotsyntax");

    Buddy* b1 = sorter->account(L"digsby01", L"aim")->buddy(L"buddy1");
    Buddy* b2 = sorter->account(L"digsby01", L"gtalk")->buddy(L"buddy2");

    dotsyntax1->addChild(b1);
    dotsyntax2->addChild(b2);
    r1->addChild(dotsyntax1);
    r2->addChild(dotsyntax2);
    r3->addChild(dotsyntax3);
    r4->addChild(dotsyntax4);
    g->addChild(r1); g->addChild(r2); g->addChild(r3); g->addChild(r4);
    sorter->setRoot(g.get());

    NodePtr n(sorter->gather());
    ASSERT_EQ(1, n->numChildren());

    Node* groupNode = n->children()[0];

    // The most-cased group name should be the one we see.
    EXPECT_EQ(L"dOTSyntaX", groupNode->name());
    ASSERT_EQ(2, groupNode->numChildren());

    ASSERT_TRUE(groupNode->data());
}
Example #26
0
  std::string Node::getRawData(bool includeName) const
  {
	
	std::string s, v = data();

	bool hasV = find_if(v.begin(), v.end(), std::not1(std::ptr_fun(isspace))) != v.end();

	if (includeName) {
		s += "<" + name();
		unsigned int attCnt = 0;
		for( unsigned int i = 0; i < getNodeCount(); ++i )
		{
			Node *node = getNode( i );
			if( node->nodeType() == Attribute) {
				s += " " + node->name() + "='"+ node->asString() + "'";
				attCnt++;
			}
		}
		if (attCnt == getNodeCount()) // have not elements
		{
			if (!hasV) s += "/>";
			else s += ">" + v + "</" + name() + ">\r\n";
			return s;
		}
		else 
		{
			s += ">\r\n";
			if (hasV) s += v + "\r\n";
		}
	}
	for( unsigned int i = 0; i < getNodeCount(); ++i )
	{
		Node *node = getNode( i );
		if( node->nodeType() == Element) 
			s += node->getRawData();
	}
	if (includeName) s += "</" + name() + ">\r\n";

	return s;
}
void ModelToXmlConverter::buildXml(const Node& node, xml_node& xnode)
{
    Logger::entry("info") << "Appending first child " << node.name();

    if (node.children().empty())
    {
        appendNode(node, xnode);
        return;
    }
    list< Node > children = node.children();
    list< Node >::iterator it = children.begin();
    for (; it != children.end(); ++it)
    {
        xml_node newNode = appendNode(*it, xnode);
        
        if (!it->children().empty())
        {
            Logger::entry("info") << "Node " << it->name() << " has children. Appending to the children...";
            buildXml(*it, newNode);
        }
    }
    
}
Example #28
0
File: node.cpp Project: halbbob/dff
std::string	Node::path()
{
  std::string path;
  Node	*tmp;

  if (this->__parent == this)
    return "";
  path = "";
  tmp = this->__parent;
  if (!tmp)
    {
      path = "";
      return path;
    }
  while ((tmp->__parent != tmp) && (tmp->__parent != NULL))
    {
      path = tmp->name() + "/" + path;
      tmp = tmp->parent();
    }
  if (tmp->__parent == tmp)
    path = "/" + path;
  return path;
}
Example #29
0
	Node node(const fsys::IFindStat& stat, const Node& parent)
	{
		LogTrace2(L"('%s', '%s')", stat.name(), parent ? parent->name() : L"");
		return simstd::make_shared<ImplNodeEx>(stat, parent);
	}
Example #30
0
	Node node(const ustring& name, const Node& parent)
	{
		LogTrace2(L"('%s', '%s')", name.c_str(), parent ? parent->name() : L"");
		return simstd::make_shared<ImplNodeEx>(name, parent);
	}