Main Content

hasNext

Class: systemcomposer.rptgen.finder.FunctionFinder
Namespace: systemcomposer.rptgen.finder

Determine if function search result queue is nonempty

Since R2022b

Syntax

nonempty = hasNext(finder)

Description

nonempty = hasNext(finder) determines whether the Function search result queue is nonempty.

Input Arguments

expand all

Function finder, specified as a systemcomposer.rptgen.finder.FunctionFinder object.

Output Arguments

expand all

Whether queue is nonempty, returned as 1 (true) or 0 (false).

Data Types: logical

Examples

expand all

Use the ComponentFinder, ComponentResult, FunctionFinder, and FunctionResult classes to generate a report that finds all components and their functions in a given software architecture model..

import mlreportgen.report.*
import slreportgen.report.*
import systemcomposer.query.*
import systemcomposer.rptgen.finder.*

Open the ACCSoftwareComposition model.

model_name = "ACCSoftwareComposition";
mdl = systemcomposer.loadModel(model_name);

Create a report and append a title page and table of contents.

functionsReport = slreportgen.report.Report(OutputPath=model_name + "_FunctionsReport", ...
    CompileModelBeforeReporting=false);
append(functionsReport,TitlePage(Title="Components and their Functions in " + model_name));
append(functionsReport,TableOfContents);

Create a chapter to contain all sections related to components and their functions.

compChapter = Chapter("Components and their Functions");

Find all components in the architecture model.

componentFinder = ComponentFinder(model_name);
componentFinder.Query = AnyComponent;

Create a section for each component.

while hasNext(componentFinder)
    comp = next(componentFinder);
    compSection = Section(Title=comp.Name);
    compReporter = getReporter(comp);
    compReporter.IncludeSnapshot = 1;
    compReporter.IncludeProperties = 0;
    compReporter.IncludeFunctions = 0;
    append(compSection,compReporter);

Find all functions associated with the component.

    functionFinder = FunctionFinder(model_name);
    functionFinder.ComponentName = comp.Name;
    functionResult = find(functionFinder);
    append(compSection,functionResult);

    append(compChapter,compSection);
end

Append the chapter to the report and view the generated report.

append(functionsReport,compChapter);
close(functionsReport);
rptview(functionsReport);

Version History

Introduced in R2022b