Esempio n. 1
0
  Implementation(const URI& file) :
    filename(build_filename(file, PE::Comm::instance().rank())),
    xml_filename(file),
    index(0),
    xml_doc("1.0", "ISO-8859-1"),
    m_total_count(0)
  {
    const Uint v = version();
    out_file.open(filename, std::ios_base::out | std::ios_base::binary);
    out_file.write(reinterpret_cast<const char*>(&v), sizeof(Uint));

    PE::Comm& comm = PE::Comm::instance();
    // Rank 0 writes out an XML file that lists all filenames for all CPUs
    if(comm.rank() == 0)
    {
      XmlNode cfbinary = xml_doc.add_node("cfbinary");
      cfbinary.set_attribute("version", to_str(version()));
      node_xml_data.reserve(comm.size());
      XmlNode node_list = cfbinary.add_node("nodes");
      for(Uint i = 0; i != comm.size(); ++i)
      {
        XmlNode node = node_list.add_node("node");
        node.set_attribute("filename", build_filename(file, i));
        node.set_attribute("rank", to_str(i));
        node_xml_data.push_back(node);
      }
    }
  }
Esempio n. 2
0
  boost::shared_ptr<XmlDoc> Protocol::create_doc ()
  {
    boost::shared_ptr<XmlDoc> xmldoc ( new XmlDoc("1.0", "UTF-8") );
    XmlDoc& doc = *xmldoc.get();

    // add root node
    XmlNode root = doc.add_node( Tags::node_doc() );

    root.set_attribute("version", "1.0");
    root.set_attribute("type", "message");

    return xmldoc;
  }
Esempio n. 3
0
void CJournal::add_signal ( const SignalArgs & signal_node )
{
  rapidxml::xml_attribute<> * type_attr = signal_node.node.content->first_attribute("type");

  if( m_options["RecordReplies"].value<bool>() ||
     (type_attr != nullptr && std::strcmp(type_attr->value(), "signal") == 0) )
  {
    XmlNode copy = copy_node(signal_node.node, m_signals_map.content);

    boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
    copy.set_attribute("time", boost::posix_time::to_simple_string(now));
  }
}
Esempio n. 4
0
SignalFrame & SignalFrame::map ( const std::string & name )
{
  cf3_assert ( node.is_valid() );
  cf3_assert ( !name.empty() );

  if( m_maps.find(name) == m_maps.end() ) // if the node does not exist yet, we create it
  {
    XmlNode node = main_map.content.add_node( Protocol::Tags::node_value() );
    node.set_attribute( Protocol::Tags::attr_key(), name );
    m_maps[name] = SignalFrame(node); // SignalFrame() adds a map under the node
  }

  return m_maps[name];
}
Esempio n. 5
0
  XmlNode Protocol::add_signal_frame ( XmlNode& node, const std::string & target,
                                       const URI & sender, const URI & receiver,
                                       bool user_trans )
  {
    cf3_assert(sender.scheme() == URI::Scheme::CPATH);
    cf3_assert(receiver.scheme() == URI::Scheme::CPATH);

    XmlNode signalnode = node.add_node( Tags::node_frame() );

    signalnode.set_attribute( "type", Tags::node_type_signal() );
    signalnode.set_attribute( "target", target );
    signalnode.set_attribute( "sender", sender.string() );
    signalnode.set_attribute( "receiver", receiver.string() );
    signalnode.set_attribute( "transaction", user_trans ? "user" : "auto" );
    signalnode.set_attribute( "frameid", common::UUCount().string() );

    return signalnode;
  }
Esempio n. 6
0
XmlNode CJournal::copy_node(const XmlNode & in, XmlNode & out) const
{
  rapidxml::xml_node<>* content = in.content;

  XmlNode copy = out.add_node(content->name(), content->value());
  rapidxml::xml_attribute<>* attr = content->first_attribute();
  XmlNode node( content->first_node() );

  while( attr != nullptr )
  {
    copy.set_attribute(attr->name(), attr->value());
    attr = attr->next_attribute();
  }


  while( node.is_valid() )
  {
    copy_node(node, copy);

    node = node.content->next_sibling();
  }

  return copy;
}
Esempio n. 7
0
  XmlNode Protocol::add_signal_frame ( XmlNode& node, const std::string & target,
                                       const URI & sender, const URI & receiver,
                                       bool user_trans )
  {
    cf_assert(sender.scheme() == URI::Scheme::CPATH);
    cf_assert(receiver.scheme() == URI::Scheme::CPATH);

    std::string uuid = boost::lexical_cast<std::string>(boost::uuids::random_generator()());

    XmlNode signalnode = node.add_node( Tags::node_frame() );

    signalnode.set_attribute( "type", Tags::node_type_signal() );
    signalnode.set_attribute( "target", target );
    signalnode.set_attribute( "sender", sender.string() );
    signalnode.set_attribute( "receiver", receiver.string() );
    signalnode.set_attribute( "transaction", user_trans ? "user" : "auto" );
    signalnode.set_attribute( "frameid", uuid );

    return signalnode;
  }
Esempio n. 8
0
  XmlNode Protocol::add_reply_frame ( XmlNode& node )
  {
    cf3_assert( node.is_valid() );
    cf3_assert( is_not_null(node.content->parent()) );

    rapidxml::xml_node<>* xml_node = node.content;

    XmlNode replynode = XmlNode(node.content->parent()).add_node( Tags::node_frame());

    replynode.set_attribute( "type", Tags::node_type_reply() );

    // reply with same target
    rapidxml::xml_attribute<>* target_att = xml_node->first_attribute("target");
    std::string target = is_not_null(target_att) ? target_att->value() : "";
    replynode.set_attribute("target", target);

    // the sender becomes the receiver
    rapidxml::xml_attribute<>* sender_att = xml_node->first_attribute("sender");
    std::string receiver = is_not_null(sender_att) ? sender_att->value() : "";
    replynode.set_attribute("receiver", receiver);

    // same transaction type
    rapidxml::xml_attribute<>* trans_att = xml_node->first_attribute("transaction");
    std::string trans = is_not_null(trans_att) ? trans_att->value() : "auto";
    replynode.set_attribute("transaction", trans);

    // copy uuids, if any
    rapidxml::xml_attribute<>*  client_uuid_att = xml_node->first_attribute( Tags::attr_clientid() );
    rapidxml::xml_attribute<>*  frame_uuid_att = xml_node->first_attribute( Tags::attr_frameid() );

    if( is_not_null(client_uuid_att) )
      replynode.set_attribute(Tags::attr_clientid(), client_uuid_att->value());

    if( is_not_null(frame_uuid_att) )
      replynode.set_attribute(Tags::attr_frameid(), frame_uuid_att->value() );

    return replynode;
//    return XmlNode();
  }