00001 00032 #ifndef LL_LLCALLBACKLIST_H 00033 #define LL_LLCALLBACKLIST_H 00034 00035 #include "llstl.h" 00036 00037 class LLCallbackList 00038 { 00039 public: 00040 typedef void (*callback_t)(void*); 00041 00042 LLCallbackList(); 00043 ~LLCallbackList(); 00044 00045 void addFunction( callback_t func, void *data = NULL ); // register a callback, which will be called as func(data) 00046 BOOL containsFunction( callback_t func, void *data = NULL ); // true if list already contains the function/data pair 00047 BOOL deleteFunction( callback_t func, void *data = NULL ); // removes the first instance of this function/data pair from the list, false if not found 00048 void callFunctions(); // calls all functions 00049 void deleteAllFunctions(); 00050 00051 static void test(); 00052 00053 protected: 00054 // Use a list so that the callbacks are ordered in case that matters 00055 typedef std::pair<callback_t,void*> callback_pair_t; 00056 typedef std::list<callback_pair_t > callback_list_t; 00057 callback_list_t mCallbackList; 00058 }; 00059 00060 extern LLCallbackList gIdleCallbacks; 00061 00062 #endif