Exemplo n.º 1
0
Game::Game(const PTree& root) :
    background_tiles(get_background_tiles(root.get_child("game.board"))),
    hashed_background_tiles(make_hashed_pair(background_tiles)),
    turn_max(root.get<int>("game.maxTurns")),
    turn(root.get<int>("game.turn")),
    state(root, hashed_background_tiles)
{
    assert( state == state );
    assert( hash_value(state) == hash_value(state) );

    int kk = 0;
    const PTree& child_heroes = root.get_child("game.heroes");
    for (PTree::const_iterator ti=child_heroes.begin(), tie=child_heroes.end(); ti!=tie; ti++)
    {
#if !defined(NDEBUG)
        const int id = ti->second.get<int>("id");
        assert( kk+1 == id );
#endif

        const_cast<HeroInfo&>(hero_infos[kk]) = HeroInfo(ti->second);

        assert( kk < 4 );
        kk++;
    }

}
Exemplo n.º 2
0
vector<SurfaceSample> SurfaceSample::loadFromXML(const std::string& filename) {
    vector<SurfaceSample> samples;

    try {
        PTree tree;
        read_xml(filename, tree);

        PTree root = tree.get_child("SurfaceSamples");

        for (CI p = root.begin(); p != root.end(); ++p) {
            if (p->first == "Sample") {
                Q posq = XMLHelpers::readQ(p->second.get_child("Pos"));
                Q rpyq = XMLHelpers::readQ(p->second.get_child("RPY"));
                double graspW = XMLHelpers::readDouble(p->second.get_child("GraspW"));
                //cout << "pos=" << posq << " rot=" << rpyq << " graspW=" << graspW << endl;

                Vector3D<> pos(posq[0], posq[1], posq[2]);
                RPY<> rpy(rpyq[0], rpyq[1], rpyq[2]);
                samples.push_back(SurfaceSample(Transform3D<>(pos, rpy.toRotation3D()), graspW));
            }
        }
    } catch (const ptree_error& e) {
        RW_THROW(e.what());
    }

    return samples;
}
Exemplo n.º 3
0
Series Series::fromPTree(PTree& pt)
{
  Series s;

  s.id = pt.get<String>("id");
  s.key = pt.get<String>("key");

  BOOST_FOREACH(PTree::value_type &v,
      pt.get_child("tags"))
    s.tags.push_back(v.second.data());

  BOOST_FOREACH(PTree::value_type &v,
      pt.get_child("attributes"))
    s.attributes[v.first.data()] = v.second.data();

  return s;
}