BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need advice on arranging objects

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Henk
Guest





PostPosted: Fri Jun 10, 2005 8:35 pm    Post subject: Need advice on arranging objects Reply with quote



Hello,

I am not experienced in complex programs but well known in C++.

Please just take your time to read.

(1) I am in a Test-Building (= TB Form)
(2) In this building is a Control-Room (= CR Form)
(3) In this room is a kind of Reactor-Interface (= RI Class)
(4) This interface contains a Control-Program (= CP Thread)
(5) This program controls a Nuclear-Reactor (= NR Thread)
(6) This reactor can show Particle-Actions on a display (= PA Form)

In the constructor of each item I create the object of the next item.
For example: in the constructor of the Reactor-Interface (3) I create the
Control-Program (4) object.

But, if I want temporary access from the Reactor-Interface (3) on the
Nuclear-Reactor (5) functions, then I need to create a temporary function in
the Control-Program (4) object that is called by a (3) function to access a
(5) function.

My questions are:

- Is there a better way to setup/arrange all 6 objects, do I miss
something?
(by deriving classes or combining classes?)

- Is there a way to easily let object (3) functions access object (5)
functions?

I'm anxious to hear...

Regards,

Henk


Back to top
JD
Guest





PostPosted: Sat Jun 11, 2005 4:33 am    Post subject: Re: Need advice on arranging objects Reply with quote




"Henk" <h.van.winkoop (AT) wxs (DOT) nl> wrote:
Quote:

[...] Is there a better way to setup/arrange all 6 objects,

It's good design to seperate the objects but be careful of
of having a thread create a form. You would need to do that
within the context of the main thread by using Syncronize or
by posting a custom message back to the main thread.

This also indicates potential problems with updating the GUI
for PA form because it's indicative of a desire to have the
NR thread performing the updating. Virtually none (if any) of
the VCL objects are thread-safe so you would again need to
perform updates within the context of the main thread. Trust
me ... I was recently thoroughly spanked on this very issue
and I lost a day & 1/2 trying to prove myself right.

Quote:
Is there a way to easily let object (3) functions access
object (5) functions?

Declare those methods as public and simply pass a pointer to
object 3 into the constructor of object 5.

~ JD


Back to top
Henk
Guest





PostPosted: Sat Jun 11, 2005 10:52 am    Post subject: Re: Need advice on arranging objects Reply with quote



Hello,

Quote:
me ... I was recently thoroughly spanked on this very issue
and I lost a day & 1/2 trying to prove myself right.

Well, I believe you!

Quote:
Is there a way to easily let object (3) functions access
object (5) functions?

Declare those methods as public and simply pass a pointer to
object 3 into the constructor of object 5.

As I understand, transport a (3) pointer to object (5) by creating the (5)

object with a (3) pointer in the constructor.
Then I can access (3) memberfunctions from within the (5) object.

But I would like it just the other way around.
I would like memberfunctions of object (3) to have direct access to
memberfunctions of object (5).

Or did I misinterpret your answer?

Henk



Back to top
JD
Guest





PostPosted: Sat Jun 11, 2005 12:01 pm    Post subject: Re: Need advice on arranging objects Reply with quote


"Henk" <h.van.winkoop (AT) wxs (DOT) nl> wrote:
Quote:

[...] Or did I misinterpret your answer?

No, I misunderstood the question.

You *really* don't want to call methods of the NR thread class
from within the RI class. If that's the case, I would suggest
that you re-think your design.

If all you want to do is change a NR members value, you would
need to block the execution of the NR thread (or suspend it)
while changing the member's value.

There is more than one way to approch this problem and it's a
design choice. One way would be to declare a pointer of type
NR in the class RI as public and pass the pointer for RI into
CP which passes it into NR so NR can assign itself to the RI
public member.

Another way would be to pass the RI::NR member by reference
into the CP which again passes that pointer by reference in NR
which assigns the value directly.

Another way is to declare CP::NR as public and from within the
RI class, simply use CP->NR->Member.

~ JD


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.