swarm-support
[Top][All Lists]
Advanced

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

saving using subclassed VarProbes


From: Marcus G. Daniels
Subject: saving using subclassed VarProbes
Date: 22 Sep 1997 16:23:29 -0700

I want to archive objects like below, where subclassed VarProbe(s)
provide replacement `probeAsString: Buffer:' and `setData: ToString:'
methods.

#Machine Generated Object-IVAR-Dump
@begin
variables       A,1 B,2 C,3 D,1 E,1 F,1
models  A,B,C:D,E,F A,B,D:C:E:F
@end    

Unfortunately, I found that the ObjectLoader only pulled in a word of
text after reading the field name.  Would you consider adding a
getLine method to InFile, and using it instead of getWord to read in
the archived data?

diff -c -r swarm-1.0.3/src/simtools/InFile.h 
/packages/alife/swarm/src/simtools/InFile.h
*** swarm-1.0.3/src/simtools/InFile.h   Thu May  1 09:34:35 1997
--- /packages/alife/swarm/src/simtools/InFile.h Mon Sep 22 13:08:11 1997
***************
*** 14,19 ****
--- 14,20 ----
  -_setFile_: (FILE *) aFile ;
  
  -(int) getWord: (char *) aWord ;
+ -(int) getLine: (char *) aLine ;
  -(int) getInt: (int *) anInt ;
  -(int) getUnsigned: (unsigned *) anUnsigned;
  -(int) getLong: (long *) aLong ;
diff -c -r swarm-1.0.3/src/simtools/InFile.m 
/packages/alife/swarm/src/simtools/InFile.m
*** swarm-1.0.3/src/simtools/InFile.m   Thu May  1 09:34:36 1997
--- /packages/alife/swarm/src/simtools/InFile.m Mon Sep 22 13:27:02 1997
***************
*** 42,47 ****
--- 42,66 ----
        return 1 ;
  }
  
+ -(int) getLine: (char *) aLine {
+   int c, pos = 0;
+ 
+   while ((c = fgetc (theFile)) != EOF && (c == ' ' || c == '\t'));
+   while (c != EOF && c != '\n')
+     {
+       aLine[pos++] = c;
+       c = fgetc (theFile);
+     }
+   aLine[pos] = '\0';
+   if (c == EOF)
+     return 0 ;
+   else
+     {
+       ungetc ('\n', theFile);
+       return 1 ;
+     }
+ }
+ 
  -(int) getInt: (int *) anInt {
    int retVal ;
  
diff -c -r swarm-1.0.3/src/simtools/ObjectLoader.m 
/packages/alife/swarm/src/simtools/ObjectLoader.m
*** swarm-1.0.3/src/simtools/ObjectLoader.m     Tue Sep  9 13:14:50 1997
--- /packages/alife/swarm/src/simtools/ObjectLoader.m   Mon Sep 22 13:17:30 1997
***************
*** 164,170 ****
      if( !aProbe )
        [self _crash_: anObject] ;
  
!     if(![theFileObject getWord: aString])
        [self _crash_: anObject] ;
         
      if(![aProbe setData: anObject ToString: aString])
--- 164,170 ----
      if( !aProbe )
        [self _crash_: anObject] ;
  
!     if(![theFileObject getLine: aString])
        [self _crash_: anObject] ;
         
      if(![aProbe setData: anObject ToString: aString])
diff -c -r swarm-1.0.3/src/simtools/ObjectSaver.m 
/packages/alife/swarm/src/simtools/ObjectSaver.m
*** swarm-1.0.3/src/simtools/ObjectSaver.m      Tue Oct  1 20:30:50 1996
--- /packages/alife/swarm/src/simtools/ObjectSaver.m    Mon Sep 22 15:19:23 1997
***************
*** 108,114 ****
  
  -saveObject: anObject {
    id aProbeMap, aProbe, anIndex ;
!   char aBuffer[200] ;
  
    if(templateProbeMap)
      aProbeMap = templateProbeMap ;
--- 108,114 ----
  
  -saveObject: anObject {
    id aProbeMap, aProbe, anIndex ;
!   char aBuffer[2000] ;
  
    if(templateProbeMap)
      aProbeMap = templateProbeMap ;

                  ==================================
   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]