在Enterprise Architect中使用C ++ STL [英] Use the C++ STL in Enterprise Architect

查看:205
本文介绍了在Enterprise Architect中使用C ++ STL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Enterprise Architect中使用C ++ STL的某些部分?

能够将某些类属性指定为 std :: string 或使用 std :: auto_ptr (甚至是 std :: tr1 :: shared_ptr )作为类型



另一有趣的事情是如何能够集成 std :: vector std :: map 放入EA。

解决方案

我已经教过STL容器的用法看起来像EA,我想它也可以扩展到stl指针:



正向工程:



您可以在语言设置中为全局多重性定义集合类,也可以为项目的特定类定义集合类(这将定义它在其他类中的包含方式) th是方式
简单示例设置:



的类确保已为关联的 target 类(而非源)设置了容器类。将目标角色 Multiplicity 设置为倍数(根据代码模板,与0、0..1、1和空字段不同)。另外,将关联的目标角色包含设置为 Value ,以避免生成指向容器的指针。



另一种更灵活的方法是修改设置->代码生成模板中的代码模板。我相信有一种方法可以覆盖构造型连接器的默认模板,尽管我从未尝试过。这可能是生成STL指针的唯一方法,因为EA仅将集合类定义用于大于1的多重性。



逆向工程



转到工具->选项->源代码工程-> C ++,并将以下字符串附加到其他集合类中:

  vector< #TYPE#*> ;; deque< #TYPE#*> ;;列表< #TYPE#*> ;; stack< #TYPE#*> ;; queue&#;#TYPE#*> ;; priority_queue< #TYPE#*> ;; set< #TYPE#*> ;; map< *,#TYPE#*> multiple< #TYPE#*&multiplemap< ; *,#TYPE#*> ;; 

我从未尝试过,但是我认为添加STL指针很简单。



往返工程



我不知道上述方法是否有效如果您进行往返工程。我认为定义不对称会导致问题。


How is it possible to use parts of the C++ STL in Enterprise Architect?
It would be nice to be able to specify certain class attributes as std::string or use std::auto_ptr (or even std::tr1::shared_ptr) as types.

Another interesting thing would be how one is able to integrate container-types like std::vector and std::map into EA.

解决方案

I have taught how STL containers look like to EA, I guess it can be extended to stl pointers too:

Forward engineering:

You can define collection classes for different multiplicities globally in the language settings, or for a specific class of your project (this will define how it is "contained" in other classes) this way. Simple example setting:

Make sure you set the container classes for the target class of the association, not the source. Set the Multiplicity of the Target Role to multiple (different from 0, 0..1, 1 and empty field according to the code template). Also, set the Containment of the Target Role of the association to Value to avoid generating a pointer to a container.

Another, more flexible way would be to modify the code templates in Settings -> Code Generation Templates. I believe there is a way to override the default template for stereotyped connectors, though I never tried. This is probably the only way to generate STL pointers, as collection class definitions are only used by EA for multiplicities bigger than 1.

Reverse engineering:

Go to Tools->Options->Source code engineering->C++ and append to 'Additional Collection Classes' the following string:

vector<#TYPE#*>;deque<#TYPE#*>;list<#TYPE#*>;stack<#TYPE#*>;queue<#TYPE#*>;priority_queue<#TYPE#*>;set<#TYPE#*>;map<*,#TYPE#*>;multiset<#TYPE#*>;multimap<*,#TYPE#*>;

I've never tried, but I assume adding the STL pointers to this is trivial.

Round-trip engineering

I don't know if the above works if you do round-trip engineering. I assume the fact that the definitions are asymmetric will cause issues.

这篇关于在Enterprise Architect中使用C ++ STL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆