Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004E1-1 “Essential” Tool Training Basic Rhapsody Basic Rhapsody Rhapsody in C++ V5.0.1 17/01/04.

Similar presentations


Presentation on theme: "Www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004E1-1 “Essential” Tool Training Basic Rhapsody Basic Rhapsody Rhapsody in C++ V5.0.1 17/01/04."— Presentation transcript:

1 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004E1-1 “Essential” Tool Training Basic Rhapsody Basic Rhapsody Rhapsody in C++ V5.0.1 17/01/04

2 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-2 Agenda  Setting up Rhapsody in C++  Exercise 1: Hello World  Exercise 2 : Count Down  Properties  Exercise 3 : Dishwasher  Exercise 4 : Relations

3 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-3 Setting Up Rhapsody  Install Microsoft Visual C++ 6.0, or alternatively Microsoft Visual Studio.NET or Borland bcc55 (note that this compiler can be downloaded from www.inprise.com)www.inprise.com  Install Rhapsody in C++ V5.0.1 (Ensure that you do a “custom” installation and select the C++ framework source)  Install license (license.dat)  Create a work directory ex: “C:\Work” If you are using Visual Studio.NET 2003, then you may need to rebuild the Rhapsody framework.

4 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-4 Before We Start  Rhapsody uses C++, which is CASE sensitive. Most of the errors that students make during this training course are due to entering text incorrectly  During this training, we will be using a naming convention where all classes start with an upper case, all operations and attributes with lower case. If two words are concatenated then the first letter of each word is capitalised ex: thisIsAnOperation, MyClass, anAttribute, …  Often during the training course, students take different lengths of time to complete the exercises. For those students who finish early there are many “Extended Exercises” that they can do.

5 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-5 Exercise 1 : Hello World

6 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-6 Creating a Project  Start up Rhapsody in C++ (development edition)  Within Rhapsody use the icon or file->new to create a new project called Hello in the directory C:\Work  Click OK then Yes to save project Make sure that the project is saved into the subdirectory with the same name “Hello” in directory C:\Work

7 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-7 The Browser Browser Object Model Diagram The browser shows us everything that is in the model. Note that Rhapsody creates an Object Model Diagram

8 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-8 Drawing a Class  In this Object Model Diagram, use the class icon to draw a class named Display Expand the browser to see that the class “Display” also appears in the browser

9 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-9 Remove from View / Delete from Model  There are two ways of deleting a class, we can either remove the class from the view (this is what the “delete” key does) or we can delete the class from the model.  If we use the delete key or the menu “Remove from View” then the class Display is just removed from this diagram, but remains in the browser.  If we select “Delete from Model” then we must confirm with “Yes” in order to remove the class from the entire model.

10 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-10 Adding a Constructor  The simplest way to add a constructor to our class is to double-click on the class to open the features (or right- click and select features).  Select the “Operations” tab and click on and select “Constructor”.  We don’t need any constructor arguments, so click “OK” to the following menu.

11 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-11 Display Options  We would expect to see the constructor shown on the class on our Object Model Diagram.  We can control what gets displayed on this view of the class using the “Display Options”.  Right-click on the Display class and select “Display Options”, set the options to display “All” attributes and “All” operations.

12 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-12 Display Constructor  We should be able to see that the constructor is now shown in both the browser and the OMD (Object Model Diagram) Constructor

13 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-13 Adding an Implementation  Select the Display constructor in the browser and double- click to open the features window.  Select the implementation tab and enter the following: cout << “Hello World” << endl; If you want to close the window by clicking on the then make sure that you “Apply” the changes first.

14 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-14 #include  Since we have used “cout”, we must do an include of the “iostream” header in our Display class.  In the browser, select the Display class and double-click to bring up the features.  Select the Properties tab (ensure that the “Common” filter is selected and enter into the “ImpIncludes” property. “ImpIncludes” is an abbreviation for Implementation Includes

15 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-15 Renaming a Component  In order to generate code, we must first create a component.  Expand the components in the browser and rename the existing component called “DefaultComponent” to “Test”. Executable

16 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-16 The Test Component  Now expand the Configurations and rename the DefaultConfig to Release

17 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-17 Initial Instance  Select the Initialization tab, expand the Default package and select the Display class.  This means that the main will now create an initial instance of the Display class.

18 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-18 Settings  We need to select an environment so that Rhapsody knows how to create an appropriate Makefile.  Select the Settings tab  Since we have the Microsoft Visual C++ compiler, we’ll use the default setting which is Microsoft We’ll explain the many other settings later

19 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-19 Renaming our OMD  Expand the Object Model Diagrams in the browser and use the features dialog to rename the diagram from Model1 to “Overview”

20 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-20 Generating Code  We’re now ready to generate code.  Save the model  Select Generate/Make/Run  Answer Yes to the question:

21 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-21 Hello World  You should see the following:  Before continuing make sure that you stop the executable. You can do this by either closing the console window or by using the icon If there was a compilation error during compilation, then simply double-click on the error and Rhapsody will indicate where in the model the error occurred.

22 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-22 The Generated Files  The generated files will be located in the following directory: Display class Main Executable Makefile

23 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-23 Editing the Code  We can edit the generated files from within Rhapsody  Select the Display class, right-click and select “Edit Code”

24 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-24 Modifying the Code  We can modify the generated code  In the Display.cpp file, change the implementation to print out “Constructed” instead of “Hello World”  Transfer the focus back to another window to roundtrip the modifications back into the model  Note that the model has been updated automatically In general, the roundtripping works very well, but beware not everything can be roundtripped!

25 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-25 Displaying the Main and Make  The Main and Makefile can be displayed from within Rhapsody by simply right-clicking on the configuration and selecting edit:

26 www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-26 Project Files Generated code AutoSave The model Event History List Visual Basic Macros Reverse Engineering Log Rhapsody Workspace


Download ppt "Www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004E1-1 “Essential” Tool Training Basic Rhapsody Basic Rhapsody Rhapsody in C++ V5.0.1 17/01/04."

Similar presentations


Ads by Google