Bug 120862 - data types: C++ pointers and references
Summary: data types: C++ pointers and references
Status: CONFIRMED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-27 12:25 UTC by Jose N Hinckel
Modified: 2019-10-23 17:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
screenshot of umbrello git master (10.22 KB, image/png)
2014-09-03 23:26 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jose N Hinckel 2006-01-27 12:25:40 UTC
Version:           1.5.1 (using KDE 3.5.0 Level "a" , SUSE 10.0 UNSUPPORTED)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-15.7-default

Setting the type of an attribute to a pointer (int *), or a reference (int&) creates new datatypes in the Datatypes list.
For the C++ this is not desirable. 
To address this problem, handling of the datatypes would have to be language dependent rendering de model less general. You could have an option of modelling for a particular language or strict uml.
Comment 1 Peter 2006-09-22 11:32:04 UTC
I am missing this feature in building an uml class diagramm too. I'd like to set a variable as a pointer that is pointing to an existing class.

For example:
Car "has" an engine(composition), but "uses" a trailer(aggregation):

class Car
{
private:
    Engine myEngine;
    Trailer* theTrailer;
};
Comment 2 Oliver Kellogg 2006-09-22 20:40:07 UTC
IMHO we need an extra option for this - we can't just equate
pointer types to aggregations: It may be that some association
between classes is designed as a composition although the
implementation type used is a pointer.
Comment 3 Peter 2006-09-23 14:31:59 UTC
Yes, I also think, that an extra option to set a variable as a pointer is the right solution. Now Umbrello(v1.5.1) doesn't recognise the dekleration as a pointer, but think that it is a new class. 
It was just an example, how I'm often handling aggregations.
Comment 4 vittor 2008-03-06 15:48:47 UTC
Why not adding C++-specific stereotypes like <<CppConstRef>> or <<CppPointer>> ?
Comment 5 Ralf Habacker 2014-09-03 23:26:07 UTC
Created attachment 88553 [details]
screenshot of umbrello git master

umbrello git master imports the following code fragement like shown in the screenshot 
----------------------------
/// file comment

/// class Trailer
class Trailer { public: Trailer(); };

/// class Engine
class Engine { public: Engine(); }; 

/// class Engine
class Test { public: Test(); }; 

/// class Car
class Car { private: Engine myEngine; Trailer* theTrailer;  Test &mytest; };
-------------------------------
In datatype folder the following related types are created
Engine
Trailer*& 
Test& 
Test

Trailer* and Test& are used as type for the related class Car members (could be seen from the saved xmi file).
In the class diagram the associations are mapped to the related classes Trailer and Test and are both displayed as aggregations.
Comment 6 Ralf Habacker 2019-10-23 17:59:48 UTC
(In reply to Jose N Hinckel from comment #0)
> Version:           1.5.1 (using KDE 3.5.0 Level "a" , SUSE 10.0 UNSUPPORTED)
> Compiler:          Target: i586-suse-linux
> OS:                Linux (i686) release 2.6.13-15.7-default
> 
> Setting the type of an attribute to a pointer (int *), or a reference (int&)
> creates new datatypes in the Datatypes list.

Looking into a related xmi files one can see that those datatypes are no type duplicate, but contains a reference to the base type.

<UML:DataType visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" elementReference="uySr5L3VImhKn" isRoot="false" xmi.id="u3bdEfBYiP9rT" name="Trailer*"/>

points to 

<UML:Class visibility="public" isSpecification="false" namespace="Logical_View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="uySr5L3VImhKn" comment="class Trailer" name="Trailer">

and 

<UML:DataType visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" elementReference="uTDYU7cG6r3iU" isRoot="false" xmi.id="uGt9gg5Idb37K" name="int*"/>

points to

<UML:DataType visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="uTDYU7cG6r3iU" name="int"/>


Attributes in a class references the specific datatype or class (look for "u3bdEfBYiP9rT")

      <UML:Class visibility="public" isSpecification="false" namespace="Logical_View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="u3Fa94HnsSyef" comment="class Car" name="Car">
       <UML:Classifier.feature>
        <UML:Attribute visibility="private" isSpecification="false" xmi.id="uOcLoZxRkXmgY" type="u3bdEfBYiP9rT" name="theTrailer"/>