swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Probing string variables


From: Ken Cline
Subject: Re: Probing string variables
Date: Tue, 2 Sep 1997 09:14:21 -0400 (EDT)

On Sat, 30 Aug 1997, Phil Knight wrote:

> In article <address@hidden>, Ken Cline
> wrote:
> >
> >Use a char *.  With an object, eg String object, the probe
> >doesn't have a way to get the value and will probably show
> >the class type of the object instead, eg String_c.  I think
> >this is true for any non base data type.  Is that right,
> >folks?
> >
> 
> Thanks, it appears to work now. I was using char c[] instead of char *c,
> the probe won't show the value of the former, but works ok with the
> latter even though I thought the two should be equivalent.
> 
> >Or, you could probe the "string" variable for the String
> >class.  But the ProbeMap for an object, foo, can only
> >contain var probes of foo's instance variables, AFAIK. So,
> >you couldn't create a probe display for your modelswarm that
> >contains a var probe for the "string" ivar in the String
> >class.
> 
> I tried the following (not the best way I know!!!, but I'd still like to
> know why it doesn't work):
> 
> initialFile is id *
> 
> in modelswarm.m 
>   in createBegin:
>     obj->initialFile = [String create: aZone setC: "Initial.data"];
>   in createEnd:
>     ProbeMap * probeMap;
>     ...
>     probeMap = [EmptyProbeMap createBegin: [self getZone]];
>     [probeMap setProbedClass: [initialFile class]];
>     probeMap = [probeMap createEnd];
>     [probeMap addProbe: [probeLibrary getProbeForVariable: "string"
>                                     inClass: [initialFile class]]];
>     [probeLibrary setProbeMap: probeMap For: [initialFile class]];
> 
> But when I do a 
> [probeDisplayManager createProbeDisplayFor: modelswarm->initialFile]
> in the observerswarm, I end up with a complete probe display rather than
> one for the probe map. Any ideas?

That's a good question... I think the answer lies in the
following code from src/simtools/ProbeDisplayManager.m:

-createProbeDisplayFor: (id) anObject {
  //  if ([anObject respondsTo: @selector(getProbeMap)]) {
  if ( ([anObject respondsTo: @selector(getProbeMap)]) &&
       ([probeLibrary isProbeMapDefinedFor: [anObject class]]) ) {
    return [[[[ProbeDisplay createBegin: [self getZone]]
           setProbedObject: anObject]
          setProbeMap: [anObject getProbeMap]]
         createEnd];
  }
  else
    return [self createDefaultProbeDisplayFor: (id) anObject];
}


Note that if the object (for which a probe display is being
created) does *not* respond to `getProbeMap' then a default
probe display will be create.

If you really want to create a custom probe display for a
String object then I you could subclass the String 
implementation and add a `getProbeMap' method.

Another possiblity would be to change the `createProbeDisplayFor'
method to something like:

-createProbeDisplayFor: (id) anObject {
  //  if ([anObject respondsTo: @selector(getProbeMap)]) {
  if ( ([anObject respondsTo: @selector(getProbeMap)]) &&
       ([probeLibrary isProbeMapDefinedFor: [anObject class]]) ) {
    return [[[[ProbeDisplay createBegin: [self getZone]]
           setProbedObject: anObject]
          setProbeMap: [anObject getProbeMap]]
         createEnd];
  }
 
  if ( [probeLibrary isProbeMapDefinedFor: [anObject class]] ) {
    return [[[[ProbeDisplay createBegin: [self getZone]]
           setProbedObject: anObject]
          setProbeMap: [probeLibrary getProbeMapFor: [anObject class] ]]
         createEnd];
  }
 
  return [self createDefaultProbeDisplayFor: (id) anObject];
}


This seems to work okay for me but I haven't tested it
thoroughly, of course.  You may want to get a blessing from
an SFI developer before changing any of the library code.


Ken.


_________________________________________________________
Ken Cline                             address@hidden
SAIC                                 VOICE (410) 571-0413
Annapolis, MD                          FAX (301) 261-8427


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]