Zurück zu Willert.de

Runtime identification of objects

Rhapsody Model or Codegeneration topics

Runtime identification of objects

Beitragvon knallfrosch » März 17th, 2014, 2:35 pm

So i have a Model which uses an object "itsListener" and an 1-1 associated class; Let's call the class "CoreClass", while the object is an instantiation of the class "ListenerClass."

The problem is that i have to model the object as object (as described in the DDS example for Listeners.) Therefore i can't instantiate them using the CoreClass constructor, like

Code: Alles auswählen
itsObject = new ListenerClass();

(assume the usual attributes and getter/setter methods.)

This way, both instantiations would know each other. That's the way i always used.

But how does an instantiation of "CoreClass" receive a pointer to the "itsListener" object, when it doesn't call the constructor itself?

Is there a global variable (created by Rhapsody) called "itsListener" for the object; do i implement a static method returning ListenerClass* itsListener?
If i model both as objects in Rhapsody, they still don't know each other at runtime..

Background is that i need 1 instantiation of "CoreClass" somehow being able to access the object "itsListener"'s functions/attributes and vice versa.
Beiträge: 1
Registriert: März 17th, 2014, 2:10 pm

Re: Runtime identification of objects

Beitragvon fsjunior » März 19th, 2014, 6:10 pm


I don't understand very well what is your problem, but I'll try to help:

If you have 2 _classes_, with an association between they and If you model 2 _objects_ of these classes in an object diagram, to make a each object "know" each other, you will have to use a link.

Using the class/object analogy, a link is an instance (object) of an association (class). With an association you create the members variable, setters, getters etc. With a link you create a "itsA->setItsB(this)" code. Look: http://pic.dhe.ibm.com/infocenter/rhaph ... grams.html

You are creating "associations" or "direct associations"? The default behaviour of a "direct association" is to create a 1-0 association, while an "association" creates a 1-1 bi directional association. In other ways, a direct association creates only a member variable in one class, while an association create the member variables in the two associated classes. Look: http://pic.dhe.ibm.com/infocenter/rhaph ... grams.html

So, if you created an unique 1-1 association (not a direct association), I think that if you set one member in one object A, the setter method of object A will automatically call the object B setter method.

Also, look the generated code, I think this will help. :)

Beiträge: 19
Registriert: März 22nd, 2013, 8:15 pm

Zurück zu Modelling with Rhapsody

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 3 Gäste