ROSE 反向工程(ANSI C++)
以ANSI C++为例
步骤:
1 Component View 中新建一个Component ,命名为NewComponent.
2设置NewComponent的Specification,右键弹出菜单-->open specification-->General,language 选ANSI C++
3这时右键点击NewComponent,弹出菜单中会多出ANSI C++的子菜单,ANSI C++-->open ANSI C++ Specification,在Source file root directory中填入C++源文件所在目录;Reverse engineer directories packages中的默认值是C++ Reverse Engineered,即反向工程生成的类会自动包含在名为“C++ Reverse Engineered”的包中。C++ Reverse Engineered为package名,可自行修改;在Project Files 中选add Files添加c++源文件,即类的代码。
4 右键点击NewComponent,ANSI C++-->Reverse Engineer,在弹出的对话框中选择要生成的类,按-确定,这时Logical View目录中,会出现所有由c++代码生成的类。
——————————————————————————————————————
下面是帮助文件中的原文
Reverse Engineering Source Code
The most common method of reverse engineering is to select an ANSI C++ component and choose reverse engineering. You are then presented with a dialog that allows you to select the classes in the source files listed in that component. The default is to reverse engineer all the classes in those source files. This is the only way to reverse engineer classes that are not already in the model.
If you reverse engineer a class, all of its members, including nested classes will be reverse engineered. It is not possible to reverse engineer just a part of a class. (Though, if the class already exists in the model, it is possible to selectively suppress reverse engineering of certain class members. See 揝ynchronize Property?in the Rose online help for more information. Reverse engineering for classes nested within other classes happens only as part of the reverse engineering for the outer class; it is not possible to reverse engineer a nested class by itself.
If a class already exists in both the model and the code, it is possible to select the class in the model and reverse engineer just that class. ANSI C++ will find the corresponding class in the code and make any necessary changes to the class in the model.
Reverse Engineering from a component or class diagram
1. Open the Class or Component diagram.
2. Select one or more components or classes in the diagram.
3. On the Tools menu, point to ANSI C++ and click Reverse Engineer.
Reverse Engineering from the Rose Browser window
1. Open your model and navigate to the component or class in the Browser window that you want to reverse engineer.
2. Right-click on the component or class.
3. Point to ANSI C++ and click Reverse Engineer.
If you are reverse engineering from the class context menu, the system checks if the selected classes are assigned to a component. If not, the system displays the following dialog. You must choose one of the components before proceeding. You can also cancel this dialog and assign the class to a component using one of the methods described in Create ANSI C++ Components and Assign Classes.
Selecting Classes
If you are reverse engineering a component, the system displays the Class Selection dialog. This dialog displays a list of all classes defined in the files assigned to the selected component, and shows you which ones will be added (displayed in blue with the 揂DD:?prefix), updated (displayed green with the 揢PD:?prefix), or deleted (displayed in red with the 揇EL:?prefix) from the model when reverse engineering is complete. It also shows you which classes have the Synchronize model property set to false (displayed as grayed out). These classes cannot be selected for reverse engineering.
Use the checkboxes to individually select the classes that you want to reverse engineer. The system does not display this dialog if you are reverse engineering from the Class Context menu or Class Diagram.