void NLink::go_to_target(SignalArgs & ) { if ( is_null(m_target) ) throw ValueNotFound (FromHere(), "Target of this link is not set or not valid"); QModelIndex index = NTree::global()->index_from_path(m_target->uri()); if(index.isValid()) NTree::global()->set_current_index(index); else throw ValueNotFound (FromHere(), m_target->uri().string() + ": path does not exist"); }
void FieldGenerator::signal_update(Common::SignalArgs& node) { Component::Ptr mesh_component = access_component_ptr(URI(option("Mesh").value_str())); if(!mesh_component) throw ValueNotFound(FromHere(), "The path for the mesh is incorrect"); CMesh::Ptr mesh = boost::dynamic_pointer_cast<CMesh>(mesh_component); if(!mesh) throw BadValue(FromHere(), "The given path does not point to a mesh"); const std::string field_name = option("FieldName").value_str(); const std::string var_name = option("VariableName").value_str(); const Real value = option("Value").value<Real>(); // Get the field, if it exists CField::Ptr field = boost::dynamic_pointer_cast<CField>(mesh->get_child_ptr(field_name)); // We can update the field if it exists AND contains the variable that we need if(field && !field->has_variable(var_name)) { throw ValueExists(FromHere(), "A field with name " + field_name + " already exists, but it does not contain a variable named " + var_name); } // If the field didn't exist, we create it if(!field) { mesh->create_scalar_field(field_name, var_name, CF::Mesh::CField::Basis::POINT_BASED); } // Proto placeholder MeshTerm<0, ScalarField> s(field_name, var_name); // Update the field value for_each_node(mesh->topology(), s = value); }
void NetworkQueue::add_to_transaction( const QString & uuid, SignalArgs & args ) { if ( m_new_transactions.contains(uuid) ) m_new_transactions[uuid]->actions.append(args); else throw ValueNotFound( FromHere(), "No transaction found with UuiD [" + uuid.toStdString() + "]."); }
void OptionList::erase( const std::string& name) { OptionStorage_t::iterator itr = store.find(name); if ( itr != store.end() ) store.erase(itr); else throw ValueNotFound(FromHere(), "Option with name [" + name + "] not found" ); }
void PropertyList::erase( const std::string& pname) { PropertyStorage_t::iterator itr = store.find(pname); if ( itr != store.end() ) store.erase(itr); else throw ValueNotFound(FromHere(), "Property with name [" + pname + "] not found" ); }
boost::any & PropertyList::property( const std::string& pname) { PropertyStorage_t::iterator itr = store.find(pname); if ( itr != store.end() ) return itr->second; else { std::string msg; msg += "Property with name ["+pname+"] not found. Available properties are:\n"; PropertyStorage_t::iterator it = store.begin(); for (; it!=store.end(); it++) msg += " - " + it->first + "\n"; throw ValueNotFound(FromHere(),msg); } }
const Option & OptionList::operator [] (const std::string & pname) const { Option::ConstPtr opt; OptionStorage_t::const_iterator itr = store.find(pname); if ( itr != store.end() ) opt = itr->second; else { std::string msg; msg += "Option with name ["+pname+"] not found. Available options are:\n"; OptionStorage_t::const_iterator it = store.begin(); for (; it!=store.end(); it++) msg += " - " + it->first + "\n"; throw ValueNotFound(FromHere(),msg); } return *opt.get(); }
void NetworkQueue::insert_transaction( const QString & uuid, NetworkQueue::Priority priority ) { if ( !m_new_transactions.contains(uuid) ) throw ValueNotFound( FromHere(), "No transaction found with UuiD [" + uuid.toStdString() + "]."); else { Transaction * transaction = m_new_transactions[uuid]; switch ( priority ) { case HIGH: m_transactions.prepend( transaction ); m_current_index++; break; case MEDIUM: if( m_current_index == -1 ) m_transactions.append( transaction ); else { m_transactions.insert( m_current_index, transaction ); m_current_index++; } break; case LOW: m_transactions.append( transaction ); break; case IMMEDIATE: throw BadValue( FromHere(), "Immediate priority cannot be applied to a transaction." ); } start(); // run the transaction (ignored if another one is already being executed) SignalFrame args = transaction->actions[0]; m_new_transactions.remove( uuid ); } }
void OptionList::configure_option(const std::string& pname, const boost::any& val) { OptionStorage_t::iterator itr = store.find(pname); if (itr == store.end()) { std::string msg; msg += "Option with name ["+pname+"] not found. Available options are:\n"; if (store.size()) { OptionStorage_t::iterator it = store.begin(); for (; it!=store.end(); it++) msg += " - " + it->first + "\n"; } throw ValueNotFound(FromHere(),msg); } Option::Ptr prop = itr->second; // update the value and trigger its actions prop->change_value(val); }
void CField::create_data_storage() { cf_assert( m_var_types.size()!=0 ); cf_assert( is_not_null(m_topology->follow()) ); // Check if there are coordinates in this field, and add to map m_coords = find_parent_component<CMesh>(topology()).nodes().coordinates().as_ptr<CTable<Real> >(); Uint row_size(0); boost_foreach(const VarType var_size, m_var_types) row_size += Uint(var_size); m_data->set_row_size(row_size); switch (m_basis) { case Basis::POINT_BASED: { m_used_nodes = CElements::used_nodes(topology()).as_ptr<CList<Uint> >(); m_data->resize(m_used_nodes->size()); break; } case Basis::ELEMENT_BASED: { Uint data_size = 0; boost_foreach(CEntities& field_elements, find_components_recursively<CEntities>(topology())) { if (field_elements.exists_space(m_space_name) == false) throw ValueNotFound(FromHere(),"space \""+m_space_name+"\" does not exist in "+field_elements.uri().path()); m_elements_start_idx[field_elements.as_ptr<CEntities>()] = data_size; CFieldView field_view("tmp_field_view"); data_size = field_view.initialize(*this,field_elements.as_ptr<CEntities>()); } m_data->resize(data_size); break; } case Basis::CELL_BASED: { Uint data_size = 0; boost_foreach(CEntities& field_elements, find_components_recursively<CCells>(topology())) { //CFinfo << name() << ": creating cellbased field storage in " << field_elements.uri().path() << CFendl; if (field_elements.exists_space(m_space_name) == false) throw ValueNotFound(FromHere(),"space \""+m_space_name+"\" does not exist in "+field_elements.uri().path()); m_elements_start_idx[field_elements.as_ptr<CEntities>()] = data_size; CFieldView field_view("tmp_field_view"); data_size = field_view.initialize(*this,field_elements.as_ptr<CEntities>()); } m_data->resize(data_size); break; } case Basis::FACE_BASED: { Uint data_size = 0; boost_foreach(CEntities& field_elements, find_components_recursively_with_tag<CEntities>(topology(),Mesh::Tags::face_entity())) { if (field_elements.exists_space(m_space_name) == false) throw ValueNotFound(FromHere(),"space \""+m_space_name+"\" does not exist in "+field_elements.uri().path()); m_elements_start_idx[field_elements.as_ptr<CEntities>()] = data_size; CFieldView field_view("tmp_field_view"); data_size = field_view.initialize(*this,field_elements.as_ptr<CEntities>()); } m_data->resize(data_size); break; } default: throw NotSupported(FromHere() , "Basis can only be ELEMENT_BASED or NODE_BASED"); break; } }