在 ECore 中,遏制和参考之间有什么区别?
在 ECore 实体之间创建引用时,可以将引用标记为“包含”。 有人可以用简单的语言向我解释一下普通引用和包含之间有什么区别吗?到目前为止我发现的定义和解释对我来说并没有什么用处。
When creating references between ECore entities there is the possibility to mark a reference as "containment".
Can somebody explain me in easy words what's the difference between a plain reference and a containment? The definitions and explainations I found so far didn't do the trick for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
参考:参考是一种简单的“A 知道 B”关系。单独的引用不会相互影响。 A可以认识B,B也可以认识C。因此,如果你有A,你可以通过B去C。如果你删除引用,A、B和C仍然存在,只是他们不再认识彼此。
包含:包含是“A有B”类型的关系。通常用于列表,例如“A 有多个 B”。然后,ECore/EMF 可以对此类集合执行原子命令,例如将所有对象从一个容器移动到另一个容器。它还可以强制实施约束,例如所包含对象的最小数量或所包含对象的最大数量,或者确保所包含的对象不包含在任何其他容器中。
示例:
假设您有一个名为
ShoppingCart
的对象,其中包含一个名为Customer
的引用和一个名为OrderedProducts
的容器。OrderedProducts
具有对Product
的引用。这个模型告诉你什么?
Reference: A reference is a plain "A knows B" relation. Separate references do not influence each other. A can know B and B can know C. Hence, if you have A, you can go to C over B. If you remove the reference, A, B and C will still exist, they just don't know each other any more.
Containment: A containment is the "A has B" kind of relation. Usually used for lists, e.g. "A has multiple B". ECore/EMF can then perform atomic commands on such collections, such as move all objects from one containment to another. It can also enforce constraints, such as a minimum amount of contained objects or a maximum amount of contained objects, or ensuring that the contained object is not contained in any other containment.
Example:
Assume you have an object called
ShoppingCart
with a reference calledCustomer
and a containment calledOrderedProducts
. TheOrderedProducts
has a reference to aProduct
.What does this model tell you?
参考:可以像UML中的关联
包含:是UML中的组合关系
如果您设置
包含 为 true,则该行将有一个填充的侧面,显示包含/组成。这是我观察到的。
Reference : can be like association in UML
Containment : is the composition relation from UML
Also this can be seen in the EMF diagram, if you set the
containment
to true, then the line will have a filled side, showing the containment/composition. This is what I have observed.