9.4.3 命名空间
如下的操作以一个环境对象的形式返回命名空间的内容信息,其中环境是在本章定义的类。注意,环境的parent关联并无填充。
因为该操作的定义完全依赖UML元模型,并且该模型会在2.0版本中发生翻天覆地的变化,因此该定义尚未完成。
context Namespace::getEnvironmentWithoutParents() : Environment
post: self.isTypeOf(Classifier) implies -- TBD when aligning with UML 2.0 Infrastructure
-- include all class features and contained classifiers
post: self.isTypeOf(Package) implies -- TBD when aligning with UML 2.0 Infrastructure
-- include all classifiers and subpackages
post: self.isTypeOf(StateMachine) implies -- TBD when aligning with UML 2.0 Infrastructure
-- include all states
post: self.isTypeOf(Subsystem) implies -- TBD when aligning with UML 2.0 Infrastructure
-- include all classifiers and subpackages
下面的操作返回一个包含其父环境引用的环境,后者也是由该操作以递归调用的方式创建的,因此也包含一个父环境。
context Namespace::getEnvironmentWithParents() : Environment
post: result.NamedElements = self.getEnvironmentWithoutParents()
post: if self.namespace->notEmpty() -- this namespace has an owning namespace
then result.parent = self.namespace.getEnvironmentWithParents()
else result.parent = invalid
endif