Responder.m
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:2k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. /*
  2. Name:           Responder.m
  3. Description:    Responder class implementation
  4. Test suite:     activity
  5. */               
  6. #import "Responder.h"
  7. #import <activity.h>
  8. /*
  9. Messages array is used for keeping track of the order of invocation of 
  10. m1..m5 messages. (This is a bit of a hack, but useful for diagnosis in 
  11. tests, where ordering is being tested)
  12. */
  13. int messages[10];
  14. /*
  15. Ids array is used for keeping track of different Responders in a collections
  16. that which received mId message. (Again a hack, but useful in testing
  17. ordering in collection related actions - ForEach).
  18. */
  19.  
  20. int ids[10];
  21. /*
  22. Rtimes array is used for keeping track of times when the mTimeId method was 
  23. invoked. (Useful for Schedule testing)
  24. */
  25. int rtimes[10];
  26. /*
  27.  Index variables for messages, ids and times arrays
  28. */
  29. int morder,idorder, timer;
  30. void 
  31. init_tables (void)
  32. {
  33.   int i;
  34.   for (i = 0; i < 10; i++)
  35.     {
  36.       messages[i] = 0;
  37.       ids[i] = 0;
  38.       rtimes[i] = 0;
  39.     }
  40.   morder = 1;
  41.   idorder = 1;
  42.   timer = 0;
  43. }
  44. @implementation Responder
  45. + create: aZone withId: (int)val
  46. {
  47.   Responder *resp = [aZone allocIVars: self];
  48.   resp->Id = val;
  49.   return resp; 
  50. }
  51. - setId: (int)val
  52. {
  53.   Id = val;
  54.   return self;
  55. }
  56. - (int)getId
  57. {
  58.   return Id;
  59. }
  60. - m1 
  61. {
  62.   printf ("m1n");
  63.   fflush (stdout);
  64.   messages[0] = morder++;
  65.   return self;
  66. }
  67. - m2 
  68. {
  69.   printf ("m2n");
  70.   fflush (stdout);
  71.   messages[1] = morder++;
  72.   return self;
  73. }
  74. - m3
  75. {
  76.   printf ("m3n");
  77.   fflush (stdout);
  78.   messages[2] = morder++;
  79.     return self;
  80. }
  81. - m4 
  82. {
  83.   printf ("m4n");
  84.   fflush (stdout);
  85.   messages[3] = morder++;
  86.   return self;
  87. }
  88. - m5 
  89. {
  90.   printf ("m5n");
  91.   fflush (stdout);
  92.   messages[4] = morder++;
  93.   return self;
  94. }
  95. - mId 
  96. {
  97.   printf ("%dn", Id);
  98.   fflush (stdout);
  99.   ids[Id - 1] = idorder++;
  100.   return self;
  101. }
  102. - mTimeId
  103. {
  104.   printf ("%d: %dn", (int) getCurrentTime (), Id);
  105.   ids[timer] = Id;
  106.   rtimes[timer++] = getCurrentTime ();
  107.   return self;
  108. }
  109. @end