예제 #1
0
//-----------------------------------------------------------------------------
bool datareader_c::read_model( component_ptr owner, xml_element_ptr top, std::string key ) {
  xml_attribute_ptr attribute = top->attribute( "id" );
  if( !attribute ) return false;

  std::string name = attribute->get_value();
  xml_element_ptr element;
  std::string tag;

  model_ptr model = model_ptr( new model_c() );
  if( owner->component_type() == component_c::TRIAL ) {
    trial_ptr trial = boost::dynamic_pointer_cast<trial_c>( owner );
    trial->models.push_back( model );
  } else if( owner->component_type() == component_c::SOLUTION ) {
    solution_ptr solution = boost::dynamic_pointer_cast<solution_c>( owner );
    solution->models.push_back( model );
  } else {
    return false;
  }

  key = name;
  model->id = name;

  for( unsigned i = 0; i < top->elements(); i++ ) {
    element = top->element( i );
    tag = element->get_name();
    if( tag == "Link" ) {
      read_link( model, element, key );
    } else if( tag == "Joint" ) {
      read_joint( model, element, key );
    }
  }

  return true;
}
예제 #2
0
boost::shared_ptr<const FrameModel>
Block::model_ptr (const symbol key) const
{ 
  const Frame& frame = find_frame (key);
  if (frame.is_reference (key))
    return model_ptr (expand_reference (key));

  return frame.model_ptr (key); 
}
예제 #3
0
const FrameModel& 
Block::model (const symbol key) const
{ return *model_ptr (key); }