Re: accessing external class members in steve

Marc Szymanski <[email protected]> Wed, 20 Apr 2005 09:06:19 +0200
Newsgroups gmane.comp.breve
Message-ID <[email protected]>
Hi,

you could write a method in the controller class that returns the pointer to 
the body.

Control : myController {
	+ variables:
		body, gripper (object).
	...
	+ to get-gripper:
		return gripper.

	+ to get-body:
		return body.
}

You could now access the body and the gripper in every other class with 
"(controller get-body) method-of-body." or "(controller get-gripper) 
method-of-gripper.".

An ohter way would be, if you want to have several bodies with grippers that 
belong to each other, to initialize the gripper with the body.

Real : Gripper {
	+ variables:
		myBody (object).

	+ to init-with body theBody (object):
		myBody = theBody.
		# the following line is very important.
		return self. 		
}

I think this would be the most elegant way. Cause you have a typical 
OO-connection like a "gripper has a body". You could create the gripper in 
the init method of the body. I think this is much cleaner than statics or 
friends even C++ because it defines their connection. Did you read the stuff 
about the Multibody? Because you need to link the gripper with the body if 
you want to move the gripper when moving the body.

I hope I understood your question.

\Marc


On Wednesday, 20. April 2005 04:38, Mithila Patwardhan wrote:
> Hi,
>
> I have a question about accessing items outside a class. I am trying to
> build a vehicular robot with a gripper. I have a class for the body of
> the robot and another for the gripper. I want to use an object which
> belongs to the class for the body inside the iterate procedure in the
> gripper class.
>
> I have read through the breve documentation and was unable to come up
> with a way of doing this. In fact, what is a clean way of referring to
> objects from other classes without instantiating the class (something
> along the lines of static members or friend functions?)
>
> Thanks,
> Mithila
> _______________________________________________
> breve mailing list
> [email protected]
> http://lists.spiderland.org/mailman/listinfo/breve

-- 
--------------------------------------------------------------------------
Dipl.-Inform. Marc Szymanski
Institute for Process Control and Robotics(IPR), Universität Karlsruhe(TH)
Kaiserstr. 12, D-76128 Karlsruhe, Germany
Phone: +49 721 608 6694, Fax: +49 721 608 7141
WWW http://wwwipr.ira.uka.de/~szymansk

_______________________________________________
breve mailing list
[email protected]
http://lists.spiderland.org/mailman/listinfo/breve