2.2 Model Center
29
Definitions related to a particular topic are usually grouped into a package. This
makes finding these definitions easier, and the code becomes clearer.
Packages provide encapsulation and large-scale structuring, which reduces the
complexity of large systems. An important example is the use of packages to create
hierarchical class libraries.
Name conflicts between definitions in different packages are excluded because the
package name is prefixed with the name of the definition declared in the package.
Information hiding and encapsulation can be supported to some extent by declaring protected classes, types, and other definitions that are available only inside the
package and therefore not accessible to external code.
Modelica defines a package search method by standard mapping of package names
to storage locations, usually in files or directories in the file system.
General package syntax:
p package PackageName "Description of package" "
// Package contains definitions of classes,
functions and constants.
end PackageName;
Packages can also be nested, for example,
package OuterPackage "Package containing
an external package"
// Contents of the external package
package NestedPackage "Internalpackage"
// Contents of the internal package
end NestedPackage;
end OuterPackage;
More complete information about the packages can be obtained in [2, 4].
Search classes
If you know the class name (or part of its name), you can use the search bar at the
top of the class navigator. This function can be useful if you do not know the exact
location of the class. After entering the text, all classes corresponding to the input
are shown in the search bar, as shown in Fig. 2.5. To see which particular package
has the class you need, in the search results you can right-click on it and select “Go
to Class in Class Browser” in the pop-up menu.
29
Definitions related to a particular topic are usually grouped into a package. This
makes finding these definitions easier, and the code becomes clearer.
Packages provide encapsulation and large-scale structuring, which reduces the
complexity of large systems. An important example is the use of packages to create
hierarchical class libraries.
Name conflicts between definitions in different packages are excluded because the
package name is prefixed with the name of the definition declared in the package.
Information hiding and encapsulation can be supported to some extent by declaring protected classes, types, and other definitions that are available only inside the
package and therefore not accessible to external code.
Modelica defines a package search method by standard mapping of package names
to storage locations, usually in files or directories in the file system.
General package syntax:
p package PackageName "Description of package" "
// Package contains definitions of classes,
functions and constants.
end PackageName;
Packages can also be nested, for example,
package OuterPackage "Package containing
an external package"
// Contents of the external package
package NestedPackage "Internalpackage"
// Contents of the internal package
end NestedPackage;
end OuterPackage;
More complete information about the packages can be obtained in [2, 4].
Search classes
If you know the class name (or part of its name), you can use the search bar at the
top of the class navigator. This function can be useful if you do not know the exact
location of the class. After entering the text, all classes corresponding to the input
are shown in the search bar, as shown in Fig. 2.5. To see which particular package
has the class you need, in the search results you can right-click on it and select “Go
to Class in Class Browser” in the pop-up menu.
