source: filezilla/trunk/fuentes/src/include/option_change_event_handler.h @ 130

Last change on this file since 130 was 130, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 946 bytes
Line 
1#ifndef __OPTION_CHANGE_EVENT_HANDLER_H__
2#define __OPTION_CHANGE_EVENT_HANDLER_H__
3
4#include <bitset>
5#include <set>
6#include <vector>
7
8class COptions;
9
10enum {
11        changed_options_size = 64*3
12};
13
14typedef std::bitset<changed_options_size> changed_options_t;
15
16class COptionChangeEventHandler
17{
18        friend class COptions;
19
20public:
21        COptionChangeEventHandler();
22        virtual ~COptionChangeEventHandler();
23
24        void RegisterOption(int option);
25        void UnregisterOption(int option);
26        void UnregisterAllOptions();
27
28protected:
29        virtual void OnOptionsChanged(changed_options_t const& options) = 0;
30
31private:
32        changed_options_t m_handled_options;
33
34        // Very important: Never ever call this if there's OnOptionsChanged on the stack.
35        static void DoNotify(changed_options_t const& options);
36        static std::size_t notify_index_;
37
38        static void UnregisterAllHandlers();
39
40        static std::vector<COptionChangeEventHandler*> m_handlers;
41};
42
43#endif //__OPTION_CHANGE_EVENT_HANDLER_H__
Note: See TracBrowser for help on using the repository browser.