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); }
CActionDirector& CActionDirector::append(const CAction::Ptr& action) { Component::Ptr existing_child = get_child_ptr(action->name()); if(is_null(existing_child)) { if(action->has_parent()) { CLink& action_link = create_component<CLink>(action->name()); action_link.link_to(action); } else { add_component(action); } on_action_added(*action); } else { // If a child with the given name existed, check that it corresponds to the supplied action CAction::Ptr existing_action = boost::dynamic_pointer_cast<CAction>(existing_child); if(is_null(existing_action)) throw ValueExists(FromHere(), "A component named " + action->name() + " already exists in " + uri().string() + ", but it is not a CAction"); if(existing_action != action) throw ValueExists(FromHere(), "An action named " + action->name() + " already exists in " + uri().string() + ", but it is different from the appended action"); } Option& actions_prop = option("ActionOrder"); std::vector<std::string> actions; actions_prop.put_value(actions); actions.push_back(action->name()); actions_prop.change_value(actions); return *this; }
/*============================================================================= *NAME :TYSIniFile::WriteStringList : *MODULE :YSIniFiles.cpp : *FUNCTION :文字列リスト書き込み処理関数です : *PROCESS :・文字列リストの書き込みです。 : *INPUT :const CString section :セクション名 *INPUT :const CString iname :Ident名 *INPUT :const TStringList& slist :内容 : *PROGRAMMED :Y.Sasai *HISTORY : *ID -- DATE ------- NOTE ------------------------------------------------------ *00 03.02.13 Y.Sasai Ver.0.90 初期作成 */ void TYSIniFile::WriteStringList( const CString section, const CString iname, TStringList& slist ) { CString ident; int tempi; for ( tempi = 0; true; tempi++ ) { ident = iname + Number[tempi]; // 2003.02.13 Y.Sasai Ver.0.00 Ident名作成 if ( tempi < slist.Count ) { // 2003.02.13 Y.Sasai Ver.0.00 文字列リスト行数内なら… WriteString( section, iname + Number[tempi], slist[tempi] ); // 2003.02.13 Y.Sasai Ver.0.90 文字列書き込み } else { // 2003.02.13 Y.Sasai Ver.0.00 行数を超えたら… if ( ValueExists( section, ident ) == false ) { // 2003.02.13 Y.Sasai Ver.0.90 Ident名がなかったら… break; // 2003.02.13 Y.Sasai Ver.0.00 ぬけるぞ } DeleteKey( section, ident ); // 2003.02.13 Y.Sasai Ver.0.00 削除だ } } }
/*============================================================================= *NAME :TYSIniFile::ReadStringList : *MODULE :YSIniFiles.cpp : *FUNCTION :文字列リスト読み込み処理関数です : *PROCESS :・文字列リスト読み込み処理です。 : *INPUT :const CString section :セクション名 *INPUT :const CString iname :Ident名 *INPUT :TStringList& slist :設定クラス : *RETURN :読み込み行数 : *PROGRAMMED :Y.Sasai *HISTORY : *ID -- DATE ------- NOTE ------------------------------------------------------ *00 03.02.13 Y.Sasai Ver.0.90 初期作成 */ int TYSIniFile::ReadStringList( const CString section, const CString iname, TStringList& slist ) { int result = 0; // 2003.02.13 Y.Sasai Ver.0.90 初期化だ CString ident; CString txt; slist.Clear(); // 2003.02.13 Y.Sasai Ver.0.90 全消去だ while ( true ) { ident = iname + Number[result]; // 2003.02.13 Y.Sasai Ver.0.90 Ident名作成 if ( ValueExists( section, ident ) == false ) { // 2003.02.13 Y.Sasai Ver.0.90 Ident名がなかったら… break; // 2003.02.13 Y.Sasai Ver.0.90 ぬけるぞ } txt = ReadString( section, ident, "" ); // 2003.02.13 Y.Sasai Ver.0.90 文字列読み込み slist.Add( txt ); // 2003.02.13 Y.Sasai Ver.0.90 追加だ result++; // 2003.02.13 Y.Sasai Ver.0.00 加算だ } return ( result ); // 2003.02.13 Y.Sasai Ver.0.90 おわりだ }