Book a Demo

Author Topic: Collections specify pointers or not  (Read 5234 times)

BlackPopaz

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Collections specify pointers or not
« on: March 26, 2019, 08:26:52 pm »
Hello,
This is a presales question.
How can I specify, if A has several B, where in EA can I decide for if I want :
std::vector<B> or std::vector<B*> or std::vector<std::shared_ptr<B> > ?

Of course, it depends of the classes, in some cases, I want pointers and sometimes not.
Thanks

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Collections specify pointers or not
« Reply #1 on: March 26, 2019, 08:52:47 pm »
I'm guessing you are talking about some Cxx stuff and how to model that with EA? Looks like template binding. Not sure, though.

q.

BlackPopaz

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Collections specify pointers or not
« Reply #2 on: March 26, 2019, 11:35:14 pm »
Well, I want something really basic :
Code: [Select]
#ifndef _A_H
#define _A_H

#include "B.h" // or // class B;
#include <memory>

class A {
   
private:
    std::vector<B> m_B; // choice 1
    std::vector<B*> m_B; // choice 2
    std::vector<std::shared_ptr<B> > m_B; // choice 3

};

#endif //_BAR_H

Where can I select if I want choice 1, 2, or 3?
« Last Edit: March 26, 2019, 11:37:42 pm by BlackPopaz »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Collections specify pointers or not
« Reply #3 on: March 26, 2019, 11:40:49 pm »
Check Configure | Model | Options | Source code Engineering | C(++)

Loot at the settings here and the ones behind the button Collection Classes


Geert

BlackPopaz

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Collections specify pointers or not
« Reply #4 on: March 27, 2019, 01:09:18 am »
Hello,
I have checked already and I wrote std::vector<#TYPE#> in the default collection class.
But it doesn't say if the Type is a pointer, a smart pointer or a standard object.

And as I said, this depends of the classes in the class diagram, some require pointers, some not.
Am I missing something?

BlackPopaz

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Collections specify pointers or not
« Reply #5 on: March 28, 2019, 08:02:55 pm »
Are there people working for EA on this forum to help?
I am very surprised not to find any help for this very basic question :(
« Last Edit: March 28, 2019, 08:16:46 pm by BlackPopaz »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Collections specify pointers or not
« Reply #6 on: March 28, 2019, 08:41:11 pm »
Obviously none with obligation. There are a couple (handful?) of Sparxians reading and posting here.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Collections specify pointers or not
« Reply #7 on: March 29, 2019, 09:25:51 am »
Hello,
I have checked already and I wrote std::vector<#TYPE#> in the default collection class.
But it doesn't say if the Type is a pointer, a smart pointer or a standard object.

And as I said, this depends of the classes in the class diagram, some require pointers, some not.
Am I missing something?
In you example code, the collection class would be std::vector<#TYPE#>, std::vector<#TYPE#*> or std::vector<std::shared_ptr<#TYPE#> >.

There's also a field on the association role page that allows you to specify an alternative to your default.

BlackPopaz

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Collections specify pointers or not
« Reply #8 on: March 29, 2019, 07:37:18 pm »
Hello,
I have checked already and I wrote std::vector<#TYPE#> in the default collection class.
But it doesn't say if the Type is a pointer, a smart pointer or a standard object.

And as I said, this depends of the classes in the class diagram, some require pointers, some not.
Am I missing something?
In you example code, the collection class would be std::vector<#TYPE#>, std::vector<#TYPE#*> or std::vector<std::shared_ptr<#TYPE#> >.

There's also a field on the association role page that allows you to specify an alternative to your default.

Thanks Eve :) That's what I am looking for. Where can you find this field please? When I select the aggregration connector of my diagram, I can't see such option.
Also, where can i change the name of the aggregation "attribute"pleae? It writes std::vector<B> m_B and I would like m_Bs as there are many.
« Last Edit: March 29, 2019, 08:08:55 pm by BlackPopaz »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Collections specify pointers or not
« Reply #9 on: April 01, 2019, 09:35:20 am »
Open the association properties and go to the source or target tab. The top entry in the advanced group of role properties is member type. That's the one that allows a per-role member type to be assigned.

I you want a specific role name (including a plural) there's a big field at the top of the dialog for that too.