Viewing C++ code

 

The user can view C++ code generated for a selected model element by using the  "Edit header" and  "Edit body" buttons in the "C++" tab of the auxiliary window.

 

Figure 10. The "Edit header" and "Edit body" buttons in the "C++" tab of the auxiliary window

 

Let's use these buttons to view the code generated for our "SimpleProject" class.  We can see C++ constructors, operators and destructors generated from the model-level Coplien pattern, as well as "TODO" notes.

 

First of all, click on the  "Edit header" button to view the header file code generated for the "SimpleProject" class.

 

#ifndef __SimpleProject_12272_H_INCLUDED

#define __SimpleProject_12272_H_INCLUDED

/*

* File type:  Class header

* Class: SimpleProject

* Maintainer: TODO

* Summary:    TODO

* Generated:  Sat Apr 22 16:08:27 2006

*/

 

//owner package header file

#include "MyPlanner/TaskManagement/TaskManagement.h"

 

//automatic includes (friends, associated classes, etc)

#include "MyPlanner/TaskManagement/SimpleProject.h"

 

namespace MyPlan

{

   namespace TaskManagement

   {

       

        class SimpleProject

        {

        //friends

             

        //enumerations

            

        //typedefs

             

        //inner classes

             

        //attributes

             

        //associations

             

        //operations

             

        public:

              SimpleProject();

              SimpleProject(const SimpleProject& value);

              SimpleProject& operator =(const SimpleProject& value);

              ~SimpleProject();

                  

        //non-modeled members

             

        };

       

   }

}

 

#endif __SimpleProject_12272_H_INCLUDED

 

 

Next, click on the  "Edit body" button to view the body file code generated for the "SimpleProject" class.

 

/*

* File type:  Class body

* Class: SimpleProject

* Maintainer: TODO

* Summary:    TODO

* Generated:  Sat Apr 22 16:08:27 2006

*/

 

//class header file

#include "MyPlanner/TaskManagement/SimpleProject.h"

 

namespace MyPlanner

{

   namespace TaskManagement

   {

        SimpleProject::SimpleProject()

        {

              //modifiable zone @12274@30671900:104@T

 

             

              //modifiable zone @12274@30671900:104@E

 

        }

       

        SimpleProject::SimpleProject(const SimpleProject& value)

        {

              //modifiable zone @12286@30671900:116@T

 

              //TODO: write copy constructor code

             

              //modifiable zone @12286@30671900:116@E

 

        }

       

        SimpleProject& SimpleProject::operator =(const SimpleProject& value)

        {

              //modifiable zone @12304@30671900:134@T

 

              //TODO: write assignment operator code

             

              //modifiable zone @12304@30671900:134@E

 

              //modifiable zone @12305@30671900:135@T

 

              return *this;

              //modifiable zone @12305@30671900:135@E

 

        }

       

        SimpleProject::~SimpleProject()

        {

              //modifiable zone @12311@30671900:141@T

 

              //TODO: write destructor code

             

              //modifiable zone @12311@30671900:141@E

 

        }        

   }

}

 

The "//modifiable zone @...." type of comment provides the markup used to ensure model/code consistency.  You can enter your code between markups, and this code is then transferred back into the model to the respective C++ code notes.

 

Note:      We recommend that the "Edit header" and "Edit body" buttons be used to enter implementation code, and that the code preview function be used to examine how UML model elements and their C++ properties (entered manually or deduced automatically) are translated to C++ code.