diff options
author | couriersud <couriersud@arcor.de> | 2015-03-04 01:39:52 +0100 |
---|---|---|
committer | couriersud <couriersud@arcor.de> | 2015-03-04 01:39:52 +0100 |
commit | 98a6781c271b004174052bbd1750351149bf91ce (patch) | |
tree | aea69d555669dfacd6eb94ff0dd84d02a9443fd8 /src/osd/osdcore.h | |
parent | c5deacfe57571bdcfdfb7bec9a3033be1f78fda7 (diff) |
First step to move osd_printf_* into osd again. Callbacks are now
implemented using an interface and use a push/pop approach where the pop
can happen out of order of pushes. [Couriersud]
Diffstat (limited to 'src/osd/osdcore.h')
-rw-r--r-- | src/osd/osdcore.h | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h index 8659592fc5c..ceb0cb45dbc 100644 --- a/src/osd/osdcore.h +++ b/src/osd/osdcore.h @@ -20,7 +20,6 @@ #define __OSDCORE_H__ #include "osdcomm.h" -#include "delegate.h" #include <stdarg.h> /*************************************************************************** @@ -926,7 +925,7 @@ const char *osd_get_volume_name(int idx); /* ----- output management ----- */ // output channels -enum output_channel +enum osd_output_channel { OSD_OUTPUT_CHANNEL_ERROR, OSD_OUTPUT_CHANNEL_WARNING, @@ -937,11 +936,26 @@ enum output_channel OSD_OUTPUT_CHANNEL_COUNT }; -// output channel callback -typedef delegate<void (const char *, va_list)> output_delegate; - -/* set the output handler for a channel, returns the current one */ -output_delegate osd_set_output_channel(output_channel channel, output_delegate callback); +class osd_output +{ +public: + osd_output() : m_chain(NULL) { } + virtual ~osd_output() { } + + virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) = 0; + + static void push(osd_output *delegate); + static void pop(osd_output *delegate); +protected: + + void chain_output(osd_output_channel channel, const char *msg, va_list args) + { + if (m_chain != NULL) + m_chain->output_callback(channel, msg, args); + } +private: + osd_output *m_chain; +}; /* calls to be used by the code */ void CLIB_DECL osd_printf_error(const char *format, ...) ATTR_PRINTF(1,2); |