SoftEng 版 (精华区)
发信人: Sun (大灯泡), 信区: SoftEng
标 题: rose和vc5.0协同设计(四)
发信站: 紫 丁 香 (Wed Apr 5 16:41:50 2000), 转信
发信人: longlife (牛牛), 信区: SoftEng
标 题: rose和vc5.0协同设计(四)
发信站: BBS 水木清华站 (Fri Nov 6 12:46:51 1998)
click to enlarge
The diagrams Rose created, are first cuts only. To visually explore
your design, let抯 create a new diagram. Right click on the rosemfc
package in the browser, and select new Class Diagram. Call it Main
design.
click to enlarge
Open the new Diagram by double clicking it in the browser. Do Query |
Add Classes?Select all Classes in the rosemfc package to be added.
Click OK. Do Layout diagram to clean it up.
click to enlarge
You can now start exploring the structure of your design. Select all
classes in your diagram and do Query | Expand Selected Classes. Select
to go one level Click OK. Do Layout Diagram to help you format the
diagram.
click to enlarge
Before we start adding our new classes, we need to specify we work in
C++. Do Tools:Options and go to the Notation tab and make sure you have
C++ as language.
Let's create a new MFC class to encapsulate a simple behavior in the
application. Create a new class called CObject, this class is in MFC,
but is not currently in our model, so create it so we can derive a new
class from it.
Create a new class called TestClass. Draw a generalization from
TestClass to CObject, this means TestClass inherits from CObject.
We're going to add a single function to TestClass called "testMe". On
the class TestClass, right click and do New Operation. Fill in the name
of the new operation as testMe(val:short=99):bool.
Add an attribute by right clicking on TestClass class and do New
Attribute. Create a new attribute ms_lastTestValue : short.
We will also add an association between CMainFrame and the class
TestClass. We want CMainFrame to reference TestClass:
Give the role name on TestClass a name, theTestClass.
Set multiplicity on this role to 1
Turn off navigability on the other role to TestClass
On the CMainFrame role, set ForwardReferenceOnly = True
click to enlarge
Before we generate code, we will set up our code generator. Do Tools |
Options? Select the C++ tab. We will here use xx::yy to mean the yy
property on xx.
First we want to make sure we generate specifically for VC++ hence
To make sure we use the MSVC properties found on the MSVC tab captured
during our reverse engineering in our code generation set:
Project::UseMSVC = True
To generate include statements for "stdafx.h", set
Module Body::AdditionalIncludes = "stdafx.h"
We might also want to turn off the CMIdentification:
Module Body::CmIdentification = 憭
Module Specification::CmIdentification = 憭
Go back to your TestClass, double click and go to the C++ tab. We want
to turn off some default operations:
GenerateCopyConstructor = DoNotDeclare
GenerateAssignmentOperation = DoNotDeclare
GenerateEqualityOperation = DoNotDeclare
And to generate minimal code annotations, we might also want to set
GenerateEmptyRegion = None
Do the same thing for CMainFrame:
GenerateDefaultConstructor= DoNotDeclare
GenerateCopyConstructor = DoNotDeclare
GenerateDestructor = False
GenerateAssignmentOperation = DoNotDeclare
GenerateEqualityOperation = DoNotDeclare
GenerateEmptyRegion = None
Now we will generate code. Select CMainFrame and TestClass (these are
the classes we抳e changed). Use the Tools|C++|Code generation option to
generate the code, there should be no errors. The new source files have
been generated.
--
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 159.226.23.7]
--
太阳就是个大灯泡。(自创)
先天下之光而光,后天下之脱而脱。(摘抄)
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: 202.118.239.237]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:7.952毫秒