setPostImportFcn
Class: slreq.Reference
Namespace: slreq
Syntax
setPostImportFcn(topRef,callbackScript)
Description
setPostImportFcn(
assigns the script specified by topRef,callbackScript)callbackScript as the
PostImportFcn callback script for the Import node
topRef.
Input Arguments
Import node, specified as an slreq.Reference object.
Name of the script to register as the PostImportFcn callback for
the Import node, specified as a string scalar or character vector.
Examples
This example shows how to assign a script as the PostImportFcn callback for an Import node. You get the contents of the PostImportFcn callback for an Import node and register a different script after you import the requirements.
Import the Requirements
Use slreq.import to import the ReqIF file mySpec.reqif into Requirements Toolbox™. Name the imported requirement set myReqSet, register the script myPreImportScript2 as the PreImportFcn, and register the script myPostImportScript as the PostImportFcn callback. Return a handle to the requirement set.
[~,~,rs] = slreq.import("mySpec.reqif",ReqSet= ... "myReqSet",preImportFcn="myPreImportScript2", ... postImportFcn="myPostImportScript");
The script myPreImportScript2 uses slreq.getCurrentImportOptions to get the import options, then specifies the attribute mapping file to use during import.
type myPreImportScript2.mimportOptions = slreq.getCurrentImportOptions; importOptions.MappingFile = "myMappingFile2.xml";
The mapping file myMappingFile2.xml maps these attributes from the ReqIF™ file to these properties in Requirements Toolbox™:
ReqSumtoSummaryDesctoDescriptionIDtoCustom ID
The script myPostImportScript uses slreq.getCurrentObject to get a handle to the Import node, gets the requirement set that the Import node belongs to, and then finds requirements that have the summary Requirement 1 and Requirement 2. Then, the script moves Requirement 2 under Requirement 1.
type myPostImportScript.mtopRef = slreq.getCurrentObject; rsScratch = reqSet(topRef); ref = find(rsScratch,Type="Reference",Summary="Requirement 2"); parentRef = find(rsScratch,Type="Reference",Summary="Requirement 1"); parentID = parentRef.SID; setParent(ref,parentID);
Confirm that Requirement 2 is a child of Requirement 1.
req1 = find(rs,Summary="Requirement 1");
req2 = children(req1);
reqSummary = req2.SummaryreqSummary = 'Requirement 2'
Get and Set the PostImportFcn Callback
Get a handle to the Import node, then register the script myPostImportScrip2 as the PostImportFcn callback. Confirm that the contents of the callback changed.
topRef = children(rs);
setPostImportFcn(topRef,"myPostImportScript2")
newCallback = getPostImportFcn(topRef)newCallback = 'myPostImportScript2'
The myPostImportScript2 script moves Requirement 2 under Requirement 3.
type myPostImportScript2.mtopRef = slreq.getCurrentObject; rsSc = reqSet(topRef); ref = find(rsSc,Type="Reference",Summary="Requirement 2"); parentRef = find(rsSc,Type="Reference",Summary="Requirement 3"); parentID = parentRef.SID; setParent(ref,parentID);
Update the requirement set. The PostImportFcn callback executes after you update the requirement set.
updateReferences(rs,topRef);
Confirm that Requirement 2 is a child of Requirement 3.
req3 = find(rs,Summary="Requirement 3");
req2 = children(req3);
reqSummary = req2.SummaryreqSummary = 'Requirement 2'
Version History
Introduced in R2022a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)