msvcpp16.txt
来自「c#设计模式WithCla」· 文本 代码 · 共 155 行
TXT
155 行
Generating C++ for Microsoft Visual C++ 1.5
The purpose of this paper is to describe how to generate Visual C++ 1.5 code from class diagrams, state diagrams, and object interaction diagrams. These scripts are "getting started" scripts that must be updated for your development environment. These scripts are "getting started" scripts that must be updated for your development environment.
1. Microsoft Visual C++ 1.5 with QuickWin - Getting Started Visual C++ Script
Class Diagram: vc15car.omt
Script Files: vc15head.sct and vc15func.sct
Main File: vc15main.cpp
The easiest way to use With Class and Visual C++ is to create a QuickWin project. This will permit the use of the C++ iostream objects, e.g. cin and cout. The steps to generate Microsoft Visual C++ 1.5 code with QuickWin and to compile the generated files are as follows:
>> Launch With Class from Windows
>> Open vc15car.omt
>> Double click on the Tire and Passenger classes to add the following in the Library Base Class box
: public CObject. These are on the 1 : Many side. The objects are elements of CObList and CPtrList Collection classes
>> Select "Utilities - Generate State Code/Report"
>> Select h as the file extension
>> Select vc15head.sct to generate the header files (.h)
>> Select "Utilities - Generate State Code/Report"
>> Select cpp as the file extension
>> Select vc15func.sct to generate the source code files (.cpp)
>> Select "File - Edit File" to examine the generated files, e.g. car.h
>> Run Visual C++ environment
>> Create QuickWin Car Project, e.g. carproj.mak and select "Use Microsoft Foundation Classes"
>> Add the .cpp files to the project
>> Compile all .cpp files
>> Compile vc15main.cpp
>> Execute the project
Notes for Visual C++ 1.5. To use iostream.h then create a VC15 QuickWin project. Create a VC15 QuickWin project with vc15main.cpp. Add the following files to the project: vehicle.cpp, car.cpp, clllrphn.cpp, passengr.cpp, tire.cpp, motor.cpp, and vc15main.cpp.
Select "Options Project Linker
Miscellaneous" and enter /NOE. Select "Options Project
Linker Windows-Library" and select COMMDLG and SHELL.
Copy stdafx.h and stdafx.cpp into your directory.
This script uses CPtrList ASSOCIATION_MANY_NAME and CObList AGGREGATION_MANY_NAME for 1 to Many Relationships. For your highest base class of any class whose objects are elements of the CObList or CPtrList collection classes, enter : public Cobject in the Class Specification Library Base Class.
To add serialization to your classes, see VCSERHD.SCT and VCSERFUN.SCT.
2. Microsoft Visual C++ 1.5 with QuickWin - Maximum Code Generation Visual C++ Script
Class Diagram: vc15car1.omt
Script Files: vc15hd1.sct and vc15fu1.sct
Main File: vc15mai1.cpp
>> Launch With Class from Windows
>> Open vc15car1.omt
>> Double click on the Tire and Passenger classes to add the following in the Library Base Class box : public CObject. These are on the 1 : Many side. The objects are elements of CObList and CPtrList Collection classes
>> Select "Utilities - Generate Class Code per File"
>> Select h as the file extension
>> Select vc15hd1.sct to generate the header files (.h)
>> Select "Utilities - Generate Class Code per File"
>> Select cpp as the file extension
>> Select vc15fu1.sct to generate the source code files (.cpp)
>> Select "File - Edit File" to examine the generated files, e.g. car.h
>> Run Visual C++ environment
>> Create QuickWin Car Project, e.g. carproj.mak and select "Use Microsoft Foundation Classes"
>> Add the .cpp files to the project
>> Compile all .cpp files
>> Compile vc15mai1.cpp
>> Execute the project
Notes for Visual C++ 1.5. To use iostream.h then create a VC15 QuickWin project. Create a VC15 QuickWin project with vc15mai1.cpp. Add the following files to the project: vehicle.cpp, car.cpp, clllrphn.cpp, passengr.cpp, tire.cpp, motor.cpp, and vc15mai1.cpp.
Select "Options Project Linker
Miscellaneous" and enter /NOE. Select "Options Project
Linker Windows-Library" and select COMMDLG and SHELL.
Copy stdafx.h and stdafx.cpp into your directory.
This script uses CPtrList ASSOCIATION_MANY_NAME and CObList AGGREGATION_MANY_NAME for 1 to Many Relationships. For your highest base class of any class whose objects are elements of the CObList or CPtrList collection classes, enter : public Cobject in the Class Specification Library Base Class.
3. Microsoft Visual C++ 1.5 for a Windows Application - Getting Started Visual C++ Script
Class Diagram: vc15car.omt
Script Files: vc15hdex.sct and vc15fuex.sct
Main File: N/A
The steps to generate Microsoft Visual C++ 1.5 code for a Windows EXE and to compile the generated files are as follows:
>> Launch With Class from Windows
>> Open vc15car.omt (simplest class diagram) or vc15car1.omt (more complex class diagram)
>> Double click on the Tire and Passenger classes to add the following in the Library Base Class box : public CObject. These are on the 1 : Many side. The objects are elements of CObList and CPtrList Collection classes.
>> Select "Utilities - Generate Class Code per File"
>> Select h as the file extension
>> Select vc15hdex.sct to generate the header files (.h)
>> Select "Utilities - Generate Class Code per File"
>> Select cpp as the file extension
>> Select vc15fuex.sct to generate the source code files (.cpp)
>> Select "File - Edit File" to examine the generated files, e.g. car.h
>> Run Visual C++ environment
>> Select "App Expert"
>> Create Windows Application Car Project, e.g. XXX.mak
>> Add the .cpp files to the project
>> Select "File - Open" XXXdoc.h file to add #include "car.h" as an include file and add Car car1; as a data member
>> Compile all .cpp files
>> Update the XXXdoc with functions to invoke the car functions
>> Execute the project
Note: This script uses CPtrList ASSOCIATION_MANY_NAME and CObList AGGREGATION_MANY_NAME
for 1 to Many Relationships. For your highest base class of any class whose objects are elements of the CObList or CPtrList collection classes, enter : public CObject in the Class Specification Library Base Class.
4. C++ Code Generation from State Diagrams
The following are the general steps to test out the C++ code generation scripts from state diagrams:
1. Create a directory for the state .omt files, script files, and C++ files, e.g. WCSTATE.
2. Copy the appropriate files into each directory, e.g. copy st*.*.
3. In With Class open a state diagram, e.g. ST1STATE.OMT.
4. Select "Utilities - Generate State Code/Report" to generate a text report. Enter a report file name, e.g. RPTSTATE.TXT. Select a state report script, e.g. RPTSTATE.SCT, DDSTATE.SCT, or TABSTATE.SCT. After report generation, select "File - Edit File" to examine the generated report.
5. Select "Utilities - Generate State Code/Report" to generate C++ code.
6. Enter the header file name, e.g. CONTROLL.H
7. Select the header code generation script, e.g. STAHEAD1.SCT.
8. Select "Edit - Edit File" and open CONTROLL.H for review.
9. Select "Utilities - Generate State Code/Report".
10. Enter the source file name, e.g. CONTROLL.CPP
11. Select the source code generation script, e.g. STAFUNC1.SCT.
12. Select "Edit - Edit File" and open CONTROLL.CPP for review.
13. In your C++ environment, create a project, e.g. STATE1.MAK and add the CONTROLL.CPP and ST1MAIN1.CPP.
14. Compile and run the program.
15. Go back to With Class and update the state diagram with new states, events, conditions, and actions and repeat the entire process.
5. Creating Message Sequence Tables from Object Interaction Diagrams
Object Interaction Diagram: CAROBJ.OMT
Script File: TABOBMSG.SCT
The following are the general steps to generate the message sequence table and then update C++ code with messages.
- Open the object interaction diagram, e.g. CAROBJ.OMT.
- Select "Utilities - Generate Object Code/Report".
- Enter a report name, e.g. TABMSG.TXT.
- Browse and select the message sequence table script, e.g. TABOBMSG.SCT to generate the message sequence table.
- Cut and paste messages from the message sequence table into your code.
- As required update the object interaction diagram and the message sequence script (TABOBMSG.SCT) and repeat the process.
6. Updated scripts and comments are requested. Many thanks, Richard Felsinger 960 Scottland Dr, Mt Pleasant, SC 29464 telephone 803-881-3648 e-mail 71162.755@compuserve.com
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?