[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
varProbing with inherited variables
From: |
glen e. p. ropella |
Subject: |
varProbing with inherited variables |
Date: |
Fri, 22 Nov 1996 00:56:21 -0700 |
> hi
> can any one out there tell me how I can get a probe to display the
> variable contents of an object that inherits some of its variables
> from its parent class?
>
> e.g.
>
> @implementation superclass : SwarmObject{
> int a;
> int b;
> etc ...
> }
>
> @implementation subclass : superclass {
> int c
> }
>
> and I want to be able to create a varProbe for 'subclass' which will allow
> me to change its values for vars a, b and c etc....
>
> methods to create a custom probMap for 'subclass' don't work....
> e.g
> [probeMap addProbe:
> [probeLibrary getProbeForVariable: "a" inClass: [self class]]];
> [probeMap addProbe:
> [probeLibrary getProbeForVariable: "b" inClass: [self class]]];
>
> Can anyone help?
>
> Matt Hare
Matt,
Here's what I did using the tutorial app v03:
In PplModelSwarm.m, I placed the following:
--------------------------------cut here--------------------------------
-buildObjects {
[...]
// build the ppl
for (inci = 0; inci < numPpl; inci++){
[...]
if (inci == 0) {
pprobeMap = [EmptyProbeMap createBegin: [self getZone]];
[pprobeMap setProbedClass: [person class]];
pprobeMap = [pprobeMap createEnd];
// variables defined in the Person.h object
[pprobeMap addProbe: [probeLibrary getProbeForVariable: "room"
inClass: [person class]]];
[pprobeMap addProbe: [probeLibrary getProbeForVariable: "party"
inClass: [person class]]];
[pprobeMap addProbe: [probeLibrary getProbeForVariable: "name"
inClass: [person class]]];
[pprobeMap addProbe: [probeLibrary getProbeForVariable: "stillhere"
inClass: [person class]]];
[pprobeMap addProbe: [probeLibrary getProbeForVariable: "listOfFriends"
inClass: [person class]]];
[pprobeMap addProbe: [probeLibrary getProbeForVariable: "myColor"
inClass: [person class]]];
// variables defined in the superclass of the Person object
[pprobeMap addProbe: [probeLibrary getProbeForVariable: "x"
inClass: [Agent2d class]]];
[pprobeMap addProbe: [probeLibrary getProbeForVariable: "y"
inClass: [Agent2d class]]];
[probeLibrary setProbeMap: pprobeMap For: [person class]];
[probeDisplayManager createProbeDisplayFor: person];
}
}
----------------------------------cut here--------------------------
And that worked just fine. I guess the secret is to
get the "class" of the superclass of the object in question.
glen