Пример #1
0
PropertyTree &
PropertyTree::addChild(const char *path,
                       const boost::spirit::hold_any &defaultValue)
{
    PropertyTree *ch = this;
    char **names = g_strsplit(path, "/", -1);
    char **name = names;
    assert(*name);
    while (*(name + 1))
    {
	Table::iterator it = ch->m_children.find(*name);
        if (it == ch->m_children.end())
        {
            PropertyTree *newChild = new PropertyTree(*name);
            ch->addChild(*newChild);
            ch = newChild;
        }
        else
            ch = it->second;
        ++name;
    }
    PropertyTree *newChild = new PropertyTree(*name, defaultValue);
    ch->addChild(*newChild);
    g_strfreev(names);
    return *newChild;
}
    DefaultTransitionModel::DefaultTransitionModel( const Map& _map, const PropertyTree& ptree ) :
		map( _map ),
		xNoise( ptree.get_child("x_noise") ),
		yNoise( ptree.get_child("y_noise") ),
		thNoise( ptree.get_child("th_noise") ) {

		SeedDistributions();
	}
Пример #3
0
/** \brief serializes the Plan
 *
 *
 */
Serializable::PropertyTree Timetable::Plan::serialize() const
{
    PropertyTree pt;

    pt.put("start-time", _startTime.time);
    pt.put("end-time", _endTime.time);
    pt.put("interval", _interval.time);
    pt.put("days", _days);
    return pt;
}
Пример #4
0
    void
    updateNode(PropertyTree& node) {
      node.put("Topology.<xmlattr>.TopologyType", topologyType);
      std::stringstream ss;

      for (std::size_t d = 0; d < dimensions.size(); ++d) {
        if (ss.str().empty()) {
          ss << dimensions[d];
        } else {
          ss << ' ' << dimensions[d];
        }
      }

      node.put("Topology.<xmlattr>.Dimensions", ss.str());
    }
Пример #5
0
    LaserSensorModel::LaserSensorModel( const Map& _map, const PropertyTree& ptree ) :
		map( _map ),
		laserSubsample( ptree.get<unsigned int>("laser_subsample") ),
		gaussianWeight( ptree.get<double>("gaussian_weight") ),
		gaussianVarianceScale( ptree.get<double>("gaussian_variance_scale") ),
		uniformWeight( ptree.get<double>("uniform_weight") ),
		exponentialWeight( ptree.get<double>("exponential_weight") ),
		maxRangeWeight( ptree.get<double>("max_range_weight") ),
		gaussianComponent( ptree.get_child("gaussian_component") ),
		uniformComponent( ptree.get_child("uniform_component") ),
		exponentialCoefficient( ptree.get<double>("exponential_coeff") ),
		raytraceStepsize( ptree.get<double>("raytrace_stepsize") ),
		raytraceThreshold( ptree.get<double>("raytrace_threshold") ) {

		numProbsToSkip = std::round( SensorData::ScanSize*ptree.get<double>("percent_outliers") );
		numPoints = std::floor( SensorData::ScanSize/(double)laserSubsample );
	}
Пример #6
0
 void
 updateNode(PropertyTree& node) {
   PropertyTree& attr_node = node.add("Attribute", "");
   attr_node.put("<xmlattr>.Name", name);
   attr_node.put("<xmlattr>.AttributeType", type);
   attr_node.put("<xmlattr>.Center", center);
   item.updateNode(attr_node);
 }
Пример #7
0
  void MaterialObject::build() {
    check();
    if (!debugInactivate_()) {
      // for (auto& currentSensor : sensorNode_) {
      //   ReferenceSensor temporarySensor;
      //   temporarySensor.store(currentSensor.second);
      //   temporarySensor.check();
      //   temporarySensor.cleanup();

      //   std::cout << "[" << currentSensor.first << "]=" << temporarySensor.numChannels() << "; ";
      //   sensorChannels[currentSensor.first] = temporarySensor.numChannels();
      // }
      // std::cout << "}" << std::endl;
      

      static std::map<MaterialObjectKey, Materials*> materialsMap_; //for saving memory
      for (auto& currentMaterialNode : materialsNode_) {
        store(currentMaterialNode.second);

        check();
        if (type_().compare(getTypeString()) == 0) {
          MaterialObjectKey myKey(currentMaterialNode.first, sensorChannels, destination_.state()? destination_() : std::string(""));
          if (materialsMap_.count(myKey) == 0) {
            Materials * newMaterials  = new Materials(materialType_);
            newMaterials->store(currentMaterialNode.second);

            //pass destination to newMaterials
            if(destination_.state()) {
              PropertyTree destinationPt;
              destinationPt.add(destination_.name(), destination_());
              newMaterials->store(destinationPt);
            }

            newMaterials->build(sensorChannels);
            materialsMap_[myKey] = newMaterials;
          }
          materials_ = materialsMap_[myKey];

          break;
        }
      }

    }
    cleanup();
  }
Пример #8
0
    void
    updateNode(PropertyTree& node) {
      PropertyTree& geometry_node = node.add("Geometry", "");
      geometry_node.put("<xmlattr>.GeometryType", geometryType);

      for (auto& item : data_items) {
        item.updateNode(geometry_node);
      }
    }
Пример #9
0
void MoveGenerationDatabase::PopulateDb(const PropertyTree& jsonDb, KnightMovesDB (&vals)[BoardSize_TilesCount * BoardSize_TilesCount], const std::string& name)
{
    int position = 0;
    for (auto& pos : jsonDb.get_child(name))
    {
        
        for (auto& destPos : pos.second)
        {
            vals[position].push_back(destPos.second.get_value<unsigned>());         
        }
        ++position;
    }
}
Пример #10
0
bool PropertyTree::set(const boost::spirit::hold_any &value,
                       bool correct,
                       std::list<std::string> *errors)
{
    boost::spirit::hold_any save(m_value);
    m_value = value;

    bool valid = true;
    for (PropertyTree *p = this; p && !p->m_correcting; p = p->m_parent)
    {
        if (p->m_validator)
            if (!p->m_validator(*p, correct, errors))
                valid = false;
    }
    if (!valid)
    {
        assert(!correct);
        m_value = save;
        return false;
    }
    if (!m_correcting)
        m_changed(*this);
    return true;
}
Пример #11
0
    void
    updateNode(PropertyTree& node) {
      std::stringstream ss;

      for (std::size_t d = 0; d < dimensions.size(); ++d) {
        if (ss.str().empty()) {
          ss << dimensions[d];
        } else {
          ss << ' ' << dimensions[d];
        }
      }

      PropertyTree& dat_node = node.add("DataItem", data);
      dat_node.put("<xmlattr>.Dimensions", ss.str());
      dat_node.put("<xmlattr>.NumberType", numberType);
      dat_node.put("<xmlattr>.Format", format);
    }
Пример #12
0
/** \brief serializes the timetable
 *
 */
Serializable::PropertyTree Timetable::serialize() const
{
    PropertyTree pt;

    pt.put_child("plans.weekday", _plans[PLAN_WEEKDAY].serialize());
    pt.put_child("plans.morning-rush", _plans[PLAN_MORNING_RUSH].serialize());
    pt.put_child("plans.evening-rush", _plans[PLAN_EVENING_RUSH].serialize());
    pt.put_child("plans.weekend", _plans[PLAN_WEEKEND].serialize());
    pt.put_child("plans.night", _plans[PLAN_NIGHT].serialize());
    pt.put_child("plans.custom", _plans[PLAN_CUSTOM].serialize());

    return pt;
}
WiiFishController::WiiFishController(FishMaster* fm, Camera* cam, SimpleSetup* setup, PropertyTree& ptree, StereoCamera* sc) 
    : fm(fm)
    , cam(cam)
    , stereoCam(sc)
    , setup(setup)
    , ptree(ptree)
    , curCamIdx(-1)
    , speed(0)
    , direction(0)
    , jaw(0)
    , up(false) 
    , down(false) 
    , left(false) 
    , right(false) 
    , forward(false) 
    , back(false) 
{
    ptree.PropertiesChangedEvent().Attach(*this);
    ReloadConfig();
    SetKeyBindings();
}
Пример #14
0
void PropertyTree::removeChild(PropertyTree& child)
{
    m_children.erase(child.name());
    child.removeFromList(m_firstChild, m_lastChild);
}
Пример #15
0
void PropertyTree::addChild(PropertyTree &child)
{
    child.addToList(m_firstChild, m_lastChild);
    child.m_parent = this;
    m_children.insert(std::make_pair(child.name(), &child));
}
Пример #16
0
bool PropertyTree::reset(const std::list<const char *> &paths,
                         bool correct,
                         std::list<std::string> *errors)
{
    std::vector<std::pair<PropertyTree *, boost::spirit::hold_any> > saved;
    saved.reserve(paths.size());

    std::list<std::set<PropertyTree *> > levels;
    for (std::list<const char *>::const_iterator it = paths.begin();
         it != paths.end();
         ++it)
    {
        PropertyTree *ch = this;
        std::list<std::set<PropertyTree *> >::iterator it2 = levels.begin();
        char **names = g_strsplit(*it, "/", -1);
        for (char **name = names; *name; ++name)
        {
            ch = ch->m_children.find(*name)->second;
            if (it2 == levels.end())
                it2 = levels.insert(it2, std::set<PropertyTree *>());
            it2->insert(ch);
            ++it2;
        }
        g_strfreev(names);
        saved.push_back(std::make_pair(ch, ch->m_value));
        ch->m_value = ch->m_defaultValue;
    }

    bool valid = true;
    for (std::list<std::set<PropertyTree *> >::reverse_iterator it =
            levels.rbegin();
         it != levels.rend();
         ++it)
    {
        for (std::set<PropertyTree *>::const_iterator it2 = it->begin();
             it2 != it->end();
             ++it2)
        {
            assert(!(*it2)->m_correcting);
            if ((*it2)->m_validator)
                if (!(*it2)->m_validator(**it2, false, errors))
                    valid = false;
        }
    }
    for (PropertyTree *p = this; p && !p->m_correcting; p = p->m_parent)
    {
        if (p->m_validator)
            if (!p->m_validator(*p, false, errors))
                valid = false;
    }

    if (!valid)
    {
        assert(!correct);
        for (std::vector<std::pair<PropertyTree *,
                                   boost::spirit::hold_any> >::const_iterator
                it = saved.begin();
             it != saved.end();
             ++it)
            it->first->m_value = it->second;
        return false;
    }
    for (std::vector<std::pair<PropertyTree *,
                               boost::spirit::hold_any> >::const_iterator
            it = saved.begin();
         it != saved.end();
         ++it)
        if (!it->first->m_correcting)
            it->first->m_changed(*it->first);
    return true;
}
Пример #17
0
 void Configs::merge(const PropertyTree &parent, const PropertyTree::path_type &childPath, const PropertyTree &child)
 {
     mProperties.put(childPath, child.data());
 }