mcb.h

Go to the documentation of this file.
00001 /**
00002  * \file mcb.h <mi32/mcb.h>
00003  * \brief Include file for Mcb (MicroImages Callback) toolkit
00004  *
00005  * \if NODOC
00006  * $Id: mcb.h_v 1.22 2003/09/15 13:49:56 fileserver!dwilliss Exp $
00007  *
00008  * $Log: mcb.h_v $
00009  * Revision 1.22  2003/09/15 13:49:56  fileserver!dwilliss
00010  * Doxygen
00011  *
00012  * Revision 1.21  2000/08/17 22:34:19  scowan
00013  * *** empty log message ***
00014  *
00015  * Revision 1.20  2000/07/21 14:46:07  mju
00016  * Put prototypes before McbLIST defns so can inline McbLIST dtor.
00017  *
00018  * Revision 1.19  2000/07/21 14:15:13  mju
00019  * Add McbLIST dtor which removes all callbacks.
00020  * Exclude internal stuff from Genitor docs.
00021  *
00022  * Revision 1.18  2000/06/15 18:30:35  sparsons
00023  * Genitor revision.
00024  *
00025  * Revision 1.17  2000/06/13 20:30:39  sparsons
00026  * Genitor documentation.
00027  *
00028  * Revision 1.16  1999/10/25 13:17:54  mju
00029  * Add ctors for McbAnyCallbackStruct.
00030  *
00031  * Revision 1.15  1999/10/22  15:47:47  mju
00032  * Add default ctor for McbLIST.
00033  *
00034  * Revision 1.8  1998/06/15  20:37:17  mju
00035  * Add McbAddCallbackExt() and MCB_Priority... definitions.
00036  *
00037  * Revision 1.6  1996/12/12  22:20:31  mju
00038  * Add fields needed to handle callback remove while calling.
00039  *
00040  * \endif
00041 **/
00042 
00043 #ifndef  INC_MI32_MCB_H
00044 #define  INC_MI32_MCB_H
00045 
00046 #ifndef  INC_MI32_STDDEFNS_H
00047    #include <mi32/stddefns.h>
00048 #endif
00049 
00050 #ifdef MIODLL
00051    #define LIBEXPORT MI_DLLEXPORT
00052 #else
00053    #define LIBEXPORT MI_DLLIMPORT
00054 #endif
00055 
00056 #if defined(__cplusplus)
00057 
00058 //! Macros for defining class methods to add Mcb callbacks
00059 #define  MCB_ADD(_clsname)                inline void McbCallbackAdd (McbLIST *list, void (*f)(McbAnyCallbackStruct*,_clsname*), UINT32 flags) const { McbAddCallback(list,reinterpret_cast<McbCallbackFunc>(f),const_cast<_clsname*>(this),(flags)); }
00060 #define  MCB_ADDEX(_clsname,_strname)     inline void McbCallbackAdd (McbLIST *list, void (*f)(_strname*,_clsname*), UINT32 flags) const { McbAddCallback(list,reinterpret_cast<McbCallbackFunc>(f),const_cast<_clsname*>(this),(flags)); }
00061 #define  MCB_REMOVE(_clsname)             inline void McbCallbackRemove (McbLIST *list, void (*f)(McbAnyCallbackStruct*,_clsname*), UINT32 flags) const { McbRemoveCallback(list,reinterpret_cast<McbCallbackFunc>(f),const_cast<_clsname*>(this),(flags)); }
00062 #define  MCB_REMOVEEX(_clsname,_strname)  inline void McbCallbackRemove (McbLIST *list, void (*f)(_strname*,_clsname*), UINT32 flags) const { McbRemoveCallback(list,reinterpret_cast<McbCallbackFunc>(f),const_cast<_clsname*>(this),(flags)); }
00063 
00064 extern "C" {
00065 #endif
00066 
00067 struct McbAnyCallbackStruct {
00068    UINT32 reason;
00069    //! CONSTRUCTION
00070    McbAnyCallbackStruct () {}          //! Default constructor, performs no initialization
00071    McbAnyCallbackStruct (              //! Construct with specified reason value
00072       UINT32 ireason
00073       ):
00074       reason(ireason)
00075       { }
00076    };
00077 
00078 typedef void (*McbCallbackFunc)(McbAnyCallbackStruct*,void*);
00079 
00080 struct McbLIST;
00081 
00082 
00083 
00084 #define  MCB_PriorityHigh     -1
00085 #define  MCB_PriorityNormal   0
00086 #define  MCB_PriorityLow      1
00087 
00088 //! Add callback to callback list with position determined by priority.
00089 //!
00090 //! If reasonmask is 0 all reasons will be selected.
00091 LIBEXPORT int McbAddCallbackExt (
00092    McbLIST *cblist,                    //!< Callback list to add to
00093    McbCallbackFunc cbfunc,             //!< Callback function
00094    void *cbdata,                       //!< "Hook" data to pass to callback function
00095    UINT32 reasonmask,                  //!< Programmer-defined reasons for which callback will be called
00096    INT8 priority                       //!< (MCB_PriorityHigh, MCB_PriorityNormal, MCB_PriorityLow)
00097    );
00098 
00099 //!   Add callback to callback list.
00100 //!
00101 //! This is equivalent to McbAddCallbackExt(cblist, cbfunc, cbdata, reasonmask, MCB_PriorityNormal).
00102 LIBEXPORT int McbAddCallback (
00103    McbLIST *cblist,                    //!< Callback list to add to
00104    McbCallbackFunc cbfunc,             //!< Callback function
00105    void *cbdata,                       //!< "Hook" data to pass to callback function
00106    UINT32 reasonmask                   //!< Programmer-defined reasons for which callback will be called
00107    );
00108 
00109 //! Call callbacks in list selected by reason.
00110 //!
00111 //! The specified reason will be bitwise-anded with the reasonmask which was specified in
00112 //!   McbAddCallback() to determine if the callback function will actually be called.  You can
00113 //!   use McbAnyCallbackStruct for the structure type if you are only interested in specifying
00114 //!   a callback reason and no additional information.
00115 LIBEXPORT void McbCallCallbacks (
00116    McbLIST *cblist,                    //!< Callback list
00117    McbAnyCallbackStruct *cbstruct,     //!< Pointer to callback structure, first entry must be ULONG reason
00118    UINT32 reason                       //!< Reason, will be ANDed with callback reasonmask
00119    );
00120 
00121 //!   Check to see if callback list has a callback for a given reason.
00122 //!
00123 //! @return True if there is a callback in the callback list which matches the given reason.
00124 LIBEXPORT int McbHasCallbacks (
00125    McbLIST *cblist,                    //!< Callback list
00126    UINT32 reason                       //!< Reason, will be ANDed with callback reasonmask
00127    );
00128 
00129 //! Remove all callbacks from list.
00130 LIBEXPORT void McbRemoveAllCallbacks (
00131    McbLIST *cblist                     //!< Callback list to remove all callbacks from
00132    );
00133 
00134 //! Remove callback from list.
00135 //!
00136 //! If "cbfunc" or "cbdata" are NULL and/or the "reasonmask" is 0 they will not be used to "match"
00137 //!   the callbacks.  For example, McbRemoveCallback(&cblist,NULL,data,0) will remove all callbacks
00138 //!   that reference the specified "data".  This can be useful if that data is about to be freed.
00139 //!   Selected callback "reasons" can be removed without removing the entire callback as well.
00140 //! Callbacks can be removed from the list safely while being called.
00141 LIBEXPORT void McbRemoveCallback (
00142    McbLIST *cblist,                    //!< Callback list to remove to 
00143    McbCallbackFunc cbfunc,             //!< Callback function
00144    void *cbdata,                       //!< "Hook" data specified in McbAddCallback()
00145    UINT32 reasonmask                   //!< Programmer-defined reasons specified in McbAddCallback()
00146    );
00147 
00148 #if defined(__cplusplus)
00149 }
00150 #endif
00151 
00152 #ifndef GENERATING_DOXYGEN_OUTPUT
00153 //! This is internal, so don't documente in Genitor
00154 struct McbREC {
00155    McbCallbackFunc cbfunc;
00156    void *cbdata;
00157    UINT32 ReasonMask;
00158    INT8 Priority;
00159    McbREC *next;
00160    };
00161 #endif //!< GENERATING_DOXYGEN_OUTPUT
00162 
00163 //! Callback list.
00164 struct McbLIST {
00165    // MEMBERS
00166    #ifndef GENERATING_DOXYGEN_OUTPUT
00167    //! These members are really internal, so we don't need to document them
00168    McbREC *first;
00169    McbREC *last;
00170    UINT16 callcount;
00171    UINT16 didremove;
00172    #endif //!< GENERATING_DOXYGEN_OUTPUT
00173 
00174    // CONSTRUCTION / DESTRUCTION
00175 
00176    McbLIST (
00177       ):
00178       first(0),
00179       last(0),
00180       callcount(0),
00181       didremove(0)
00182       { }
00183 
00184    ~McbLIST (
00185       ) {
00186       McbRemoveAllCallbacks(this);
00187       }
00188    };
00189 
00190 #undef LIBEXPORT
00191 
00192 #endif //!<  INC_MI32_MCB_H 

Generated on Tue Dec 14 13:18:25 2004 for TNTsdk by  doxygen 1.3.8-20040913