mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:42:43 +00:00 
			
		
		
		
	 1b3599fbbc
			
		
	
	
		1b3599fbbc
		
	
	
	
	
		
			
			The Inspector app quickly exposes crappy flat object hiearchies without parent/child relationships. This is one of many commits that improves the situation by making parent/child CObject relationships explicit.
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			776 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			776 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include <LibCore/CEvent.h>
 | |
| #include <LibCore/CEventLoop.h>
 | |
| #include <LibCore/CNotifier.h>
 | |
| 
 | |
| CNotifier::CNotifier(int fd, unsigned event_mask, CObject* parent)
 | |
|     : CObject(parent)
 | |
|     , m_fd(fd)
 | |
|     , m_event_mask(event_mask)
 | |
| {
 | |
|     set_enabled(true);
 | |
| }
 | |
| 
 | |
| CNotifier::~CNotifier()
 | |
| {
 | |
|     set_enabled(false);
 | |
| }
 | |
| 
 | |
| void CNotifier::set_enabled(bool enabled)
 | |
| {
 | |
|     if (enabled)
 | |
|         CEventLoop::register_notifier({}, *this);
 | |
|     else
 | |
|         CEventLoop::unregister_notifier({}, *this);
 | |
| }
 | |
| 
 | |
| void CNotifier::event(CEvent& event)
 | |
| {
 | |
|     if (event.type() == CEvent::NotifierRead && on_ready_to_read) {
 | |
|         on_ready_to_read();
 | |
|     } else if (event.type() == CEvent::NotifierWrite && on_ready_to_write) {
 | |
|         on_ready_to_write();
 | |
|     } else {
 | |
|         CObject::event(event);
 | |
|     }
 | |
| }
 |