home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Instrumentation SDK / Documentation / Sample Code / SampleGrowthAndMag.c next >
Encoding:
C/C++ Source or Header  |  1998-06-19  |  1.2 KB  |  55 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    This code illustrates how to create growth and magnitude statistic nodes 
  3.  *    and how to update their values.
  4.  */
  5.  
  6. #include "Instrumentation.h"
  7.  
  8.  
  9. OSStatus    InitInstrumentation( void);
  10. void        UpdateStatistics( UInt32 monthsElapsed, SInt32 profit);
  11.  
  12. InstGrowthClassRef        gMonthsStat;
  13. InstMagnitudeClassRef    gCashStat;
  14.  
  15.  
  16. void        main()
  17. {
  18. OSStatus        err;
  19.  
  20.     if ( noErr == ( err = InitInstrumentation()))
  21.     {
  22.         UpdateStatistics( 6, 120);        // hummin' along
  23.         UpdateStatistics( 3, -760);        // oops, bad quarter
  24.         UpdateStatistics( 3, -32);        // the recovery...
  25.     }
  26. }
  27.  
  28.  
  29. OSStatus    InitInstrumentation( void)
  30. /* Create and enable our statistics nodes. They are initially zero. */
  31. {
  32. OSStatus        err;
  33.  
  34.     err = InstCreateGrowthClass( kInstRootClassRef, "Samples:Months Past", 
  35.                                     kInstEnableClassMask, &gMonthsStat);
  36.  
  37.     if ( noErr == err)
  38.         err = InstCreateMagnitudeClass( kInstRootClassRef, "Samples:Revenue", 
  39.                                         kInstEnableClassMask, &gCashStat);
  40.     return err;
  41. }
  42.  
  43.  
  44. void        UpdateStatistics( UInt32 monthsElapsed, SInt32 profit)
  45. /* Update the statistics with some new values. */
  46. {
  47.     // update the number of months that have gone by
  48.     InstUpdateGrowth( gMonthsStat, monthsElapsed);
  49.  
  50.     // update the cash total with the new delta
  51.     InstUpdateMagnitudeDelta( gCashStat, profit);
  52. }
  53.  
  54.  
  55.