home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Programming / MR_Classes / Dev / Source / supermodel / boopsi_IsMemberOf.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-09  |  1.5 KB  |  64 lines

  1. #include <intuition/classusr.h>
  2. #include <intuition/classes.h>
  3.  
  4. #include <string.h>
  5.  
  6. /****** extras.lib/SM_IsMemberOf ******************************************
  7. *
  8. *   NAME
  9. *       extras.lib/SM_IsMemberOf -- Check if Object belongs to a Class
  10. *
  11. *   SYNOPSIS
  12. *       memberof = SM_IsMemberOf(Object, ClassPtr, ClassID)
  13. *
  14. *       BOOL SM_IsMemberOf(Object *, Class *, STRPTR);
  15. *
  16. *   FUNCTION
  17. *
  18. *
  19. *   INPUTS
  20. *
  21. *   RESULT
  22. *
  23. *   EXAMPLE
  24. *
  25. *   NOTES
  26. *         Stolen from someone...
  27. *          
  28. *         Here's some IsMemberOf() code I whipped up quickly.  Might be nice if we all
  29. *         posted useful little BOOPSI snippets like this... maybe even collected them
  30. *         together on a web site.  (I volunteer NOT to maintain this site :)
  31. *
  32. *   BUGS
  33. *
  34. *   SEE ALSO
  35. *
  36. ******************************************************************************
  37. *
  38. */
  39.  
  40. BOOL __asm LIB_SM_IsMemberOf(register __a0 Object *obj, register __a1 Class *class, register __a2 STRPTR class_id)
  41. {
  42.     BOOL found = FALSE;
  43.  
  44.     Class *obj_class = OCLASS(obj);
  45.  
  46.     while (!found && obj_class)
  47.     {
  48.         if (class)
  49.         {
  50.             if (obj_class == class)
  51.                 found = TRUE;
  52.         }
  53.         else if (class_id && obj_class->cl_ID)
  54.         {
  55. //            D( kprintf("comparing class names: %s and %s\n", class_id, obj_class->cl_ID); )
  56.             if (strcmp(class_id, obj_class->cl_ID) == 0)
  57.                 found = TRUE;
  58.         }
  59.         if (!found)
  60.             obj_class = obj_class->cl_Super;
  61.     }
  62.     return(found);
  63. }
  64.