home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / ViewKit_dev.idb / usr / include / Vk / VkCallbackObject.h.z / VkCallbackObject.h
Encoding:
C/C++ Source or Header  |  1996-09-20  |  4.7 KB  |  129 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. ///////   Copyright 1992, Silicon Graphics, Inc.  All Rights Reserved.   ///////
  3. //                                                                            //
  4. // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;     //
  5. // the contents of this file may not be disclosed to third parties, copied    //
  6. // or duplicated in any form, in whole or in part, without the prior written  //
  7. // permission of Silicon Graphics, Inc.                                       //
  8. //                                                                            //
  9. // RESTRICTED RIGHTS LEGEND:                                                  //
  10. // Use,duplication or disclosure by the Government is subject to restrictions //
  11. // as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data     //
  12. // and Computer Software clause at DFARS 252.227-7013, and/or in similar or   //
  13. // successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -    //
  14. // rights reserved under the Copyright Laws of the United States.             //
  15. //                                                                            //
  16. ////////////////////////////////////////////////////////////////////////////////
  17.  
  18.  
  19. #ifndef VKCALLBACKOBJECT_H
  20. #define VKCALLBACKOBJECT_H
  21.  
  22. class VkCallbackObject;
  23. class VkCallbackObjectList;
  24. class VkCallbackList;
  25. class VkNameList;
  26.  
  27. #define VkRNoArg    "NoArg"
  28. #define VkRFilename "Filename"
  29.  
  30.  
  31. typedef void (*VkCallbackFunction) (VkCallbackObject *caller,
  32.                     void *clientData,
  33.                     void *callData);
  34.  
  35. typedef void (VkCallbackObject::*VkCallbackMethod) (VkCallbackObject *caller,
  36.                             void *clientData,
  37.                             void *callData);
  38.  
  39. #define VkAddCallbackFunction(name, you, func, clientData) \
  40.                     ( (you)->addCallback(name, func, clientData))
  41. #define VkAddCallbackMethod(name, you, me, func, clientData) \
  42.                    ( (you)->addCallback(name, (me), (VkCallbackMethod) func, clientData))
  43.  
  44. #define VkRemoveCallbackFunction(name, you, func, clientData) \
  45.                   ( (you)->removeCallback(name, func, clientData))
  46. #define VkRemoveCallbackMethod(name, you, me, func, clientData) \
  47.                   ( (you)->removeCallback(name, (me), (VkCallbackMethod) func, clientData))
  48.  
  49. class VkCallbackObject {
  50.  
  51.  public:
  52.  
  53.     virtual ~VkCallbackObject();
  54.     virtual const char *className();
  55.  
  56.     void addCallback(const char *, 
  57.              VkCallbackFunction, 
  58.              void *clientData = 0);
  59.     void addCallback(const char *, 
  60.              VkCallbackObject *, 
  61.              VkCallbackMethod, 
  62.              void *clientData = 0);
  63.  
  64.     void removeCallback(const char *, 
  65.             VkCallbackFunction, 
  66.             void *clientData = 0);
  67.     void removeCallback(const char *, 
  68.             VkCallbackObject *, 
  69.             VkCallbackMethod,
  70.             void *clientData = 0);
  71.     void removeAllCallbacks();
  72.     void removeAllCallbacks(VkCallbackObject *);
  73.     int hasCallbacks(const char *) const;
  74.     void cloneCallbacks(VkCallbackObject *);
  75.     void cloneCallback(const char * const, VkCallbackObject *);
  76.     void cloneCallback(const char * const, const char * const,
  77.                VkCallbackObject *);
  78.  
  79.     // The following member function supports dynamic loading
  80.     // of objects, as supported by rapidapp. Objects must be
  81.     // set up properly for this to work. See man VkComponent
  82.     // and man VkCallbackObject or the rapidapp documentation for details.
  83.     
  84.     static VkCallbackObject *loadObject(const char *name,
  85.                     const char *className,
  86.                     const char *filename);
  87.  
  88.     const VkNameList* getMethods();
  89.     const char *getMethodArgType(const char *methodName);
  90.     void invokeMethod(const char *method, void *);
  91.     void invokeMethod(const char *method, int);
  92.     void invokeMethod(const char *method, float);    
  93.     void invokeMethod(const char *method, unsigned char);
  94.     void invokeMethod(const char *method, const char *);            
  95.     void invokeMethod(const char *method);
  96.     
  97.   protected:
  98.  
  99.     void callCallbacks(const char *const, void *);
  100.     VkCallbackObject( );     // Protected constructor forces subclasses to redefine
  101.  
  102.     static void registerLoadedObject(VkCallbackObject*, void *, void *); // Only to be called from VkComponent
  103.  
  104.     // Used by derived classes to describe methods for use in dynamic loading
  105.     // Largely used by RapidApp, but could be useful in programs
  106.     
  107.     struct  InterfaceMap {
  108.        char *resourceName;
  109.        char *methodName;
  110.        char *argType;
  111.        char *definingClass;    
  112.        void (VkCallbackObject::*method)(...);    
  113.     };
  114.  
  115.   private:
  116.  
  117.     VkCallbackList        *_callbacks;
  118.     VkCallbackObjectList  *_senders;
  119.  
  120.     void registerSender(VkCallbackObject *); 
  121.     void unregisterSender(VkCallbackObject *); 
  122.     void unregisterSenders(VkCallbackObject *);
  123.  
  124.     void findMethod(const char *);            
  125. };
  126.  
  127. #endif
  128.  
  129.