framework/c/inc/le_eventLoop.h
Go to the documentation of this file.
00001 
00613 //--------------------------------------------------------------------------------------------------
00621 #ifndef LEGATO_EVENTLOOP_INCLUDE_GUARD
00622 #define LEGATO_EVENTLOOP_INCLUDE_GUARD
00623 
00624 
00625 //--------------------------------------------------------------------------------------------------
00632 //--------------------------------------------------------------------------------------------------
00633 typedef struct le_event_Id* le_event_Id_t;
00634 
00635 
00636 //--------------------------------------------------------------------------------------------------
00652 //--------------------------------------------------------------------------------------------------
00653 
00654 // This macro is set by the build system.  However, if it hasn't been set, use a sensable default.
00655 #ifndef COMPONENT_INIT
00656     #define COMPONENT_INIT  void _le_event_InitializeComponent(void)
00657 #endif
00658 
00660 #define LE_EVENT_INIT_HANDLER COMPONENT_INIT
00661 
00662 
00663 //--------------------------------------------------------------------------------------------------
00671 //--------------------------------------------------------------------------------------------------
00672 typedef void (*le_event_HandlerFunc_t)
00673 (
00674     void* reportPtr
00675 );
00676 
00677 
00678 //--------------------------------------------------------------------------------------------------
00689 //--------------------------------------------------------------------------------------------------
00690 typedef void (*le_event_LayeredHandlerFunc_t)
00691 (
00692     void*   reportPtr,
00693     void*   secondLayerFunc
00694 );
00695 
00696 
00697 //--------------------------------------------------------------------------------------------------
00703 //--------------------------------------------------------------------------------------------------
00704 typedef void (*le_event_FdHandlerFunc_t)
00705 (
00706     int fd
00707 );
00708 
00709 
00710 //--------------------------------------------------------------------------------------------------
00718 //--------------------------------------------------------------------------------------------------
00719 typedef void (*le_event_DeferredFunc_t)
00720 (
00721     void* param1Ptr,
00722     void* param2Ptr
00723 );
00724 
00725 
00726 //--------------------------------------------------------------------------------------------------
00732 //--------------------------------------------------------------------------------------------------
00733 typedef struct le_event_FdMonitor* le_event_FdMonitorRef_t;
00734 
00735 
00736 //--------------------------------------------------------------------------------------------------
00743 //--------------------------------------------------------------------------------------------------
00744 typedef struct le_event_Handler* le_event_HandlerRef_t;
00745 
00746 
00747 //--------------------------------------------------------------------------------------------------
00754 //--------------------------------------------------------------------------------------------------
00755 typedef struct le_event_FdHandler* le_event_FdHandlerRef_t;
00756 
00757 
00758 //--------------------------------------------------------------------------------------------------
00762 //--------------------------------------------------------------------------------------------------
00763 typedef enum
00764 {
00765     LE_EVENT_FD_READABLE,           
00766     LE_EVENT_FD_READABLE_URGENT,    
00767     LE_EVENT_FD_WRITEABLE,          
00768     LE_EVENT_FD_WRITE_HANG_UP,      
00769     LE_EVENT_FD_READ_HANG_UP,       
00770     LE_EVENT_FD_ERROR,              
00771 }
00772 le_event_FdEventType_t;
00773 
00774 #define LE_EVENT_NUM_FD_EVENT_TYPES 6   ///< Number of members in the le_event_FdEventType_t enum.
00775 
00776 
00777 //--------------------------------------------------------------------------------------------------
00786 //--------------------------------------------------------------------------------------------------
00787 le_event_Id_t le_event_CreateId
00788 (
00789     const char* name,       
00790     size_t      payloadSize 
00791 );
00792 
00793 
00794 //--------------------------------------------------------------------------------------------------
00804 //--------------------------------------------------------------------------------------------------
00805 le_event_Id_t le_event_CreateIdWithRefCounting
00806 (
00807     const char* name        
00808 );
00809 
00810 
00811 //--------------------------------------------------------------------------------------------------
00824 //--------------------------------------------------------------------------------------------------
00825 le_event_HandlerRef_t le_event_AddHandler
00826 (
00827     const char*             name,           
00828     le_event_Id_t           eventId,        
00829     le_event_HandlerFunc_t  handlerFunc     
00830 );
00831 
00832 
00833 //--------------------------------------------------------------------------------------------------
00848 //--------------------------------------------------------------------------------------------------
00849 le_event_HandlerRef_t le_event_AddLayeredHandler
00850 (
00851     const char*                     name,           
00852     le_event_Id_t                   eventId,        
00853     le_event_LayeredHandlerFunc_t   firstLayerFunc, 
00854     void*                           secondLayerFunc 
00855 );
00856 
00857 
00858 //--------------------------------------------------------------------------------------------------
00864 //--------------------------------------------------------------------------------------------------
00865 void le_event_RemoveHandler
00866 (
00867     le_event_HandlerRef_t   handlerRef  
00868 );
00869 
00870 
00871 //--------------------------------------------------------------------------------------------------
00880 //--------------------------------------------------------------------------------------------------
00881 void le_event_Report
00882 (
00883     le_event_Id_t   eventId,    
00884     void*           payloadPtr, 
00885     size_t          payloadSize 
00886 );
00887 
00888 
00889 //--------------------------------------------------------------------------------------------------
00900 //--------------------------------------------------------------------------------------------------
00901 void le_event_ReportWithRefCounting
00902 (
00903     le_event_Id_t   eventId,    
00904     void*           objectPtr   
00905 
00906 );
00907 
00908 
00909 //--------------------------------------------------------------------------------------------------
00916 //--------------------------------------------------------------------------------------------------
00917 void le_event_SetContextPtr
00918 (
00919     le_event_HandlerRef_t   handlerRef, 
00920     void*                   contextPtr  
00921 );
00922 
00923 
00924 //--------------------------------------------------------------------------------------------------
00934 //--------------------------------------------------------------------------------------------------
00935 void* le_event_GetContextPtr
00936 (
00937     void
00938 );
00939 
00940 
00941 //--------------------------------------------------------------------------------------------------
00956 //--------------------------------------------------------------------------------------------------
00957 le_event_FdMonitorRef_t le_event_CreateFdMonitor
00958 (
00959     const char*             name,       
00960     int                     fd          
00961 );
00962 
00963 
00964 //--------------------------------------------------------------------------------------------------
00981 //--------------------------------------------------------------------------------------------------
00982 le_event_FdHandlerRef_t le_event_SetFdHandler
00983 (
00984     le_event_FdMonitorRef_t  monitorRef, 
00985     le_event_FdEventType_t   eventType,  
00986     le_event_FdHandlerFunc_t handlerFunc 
00987 );
00988 
00989 
00990 //--------------------------------------------------------------------------------------------------
00995 //--------------------------------------------------------------------------------------------------
00996 void le_event_SetFdHandlerContextPtr
00997 (
00998     le_event_FdHandlerRef_t handlerRef, 
00999     void*                   contextPtr  
01000 );
01001 
01002 
01003 //--------------------------------------------------------------------------------------------------
01007 //--------------------------------------------------------------------------------------------------
01008 void le_event_ClearFdHandler
01009 (
01010     le_event_FdHandlerRef_t  handlerRef  
01011 );
01012 
01013 
01014 //--------------------------------------------------------------------------------------------------
01020 //--------------------------------------------------------------------------------------------------
01021 void le_event_DeleteFdMonitor
01022 (
01023     le_event_FdMonitorRef_t monitorRef  
01024 );
01025 
01026 
01027 //--------------------------------------------------------------------------------------------------
01032 //--------------------------------------------------------------------------------------------------
01033 void le_event_QueueFunction
01034 (
01035     le_event_DeferredFunc_t func,       
01036     void*                   param1Ptr,  
01037     void*                   param2Ptr   
01038 );
01039 
01040 
01041 //--------------------------------------------------------------------------------------------------
01046 //--------------------------------------------------------------------------------------------------
01047 void le_event_QueueFunctionToThread
01048 (
01049     le_thread_Ref_t         thread,     
01050     le_event_DeferredFunc_t func,       
01051     void*                   param1Ptr,  
01052     void*                   param2Ptr   
01053 );
01054 
01055 
01056 //--------------------------------------------------------------------------------------------------
01068 //--------------------------------------------------------------------------------------------------
01069 void le_event_RunLoop
01070 (
01071     void
01072 )
01073 __attribute__ ((noreturn));
01074 
01075 
01076 //--------------------------------------------------------------------------------------------------
01087 //--------------------------------------------------------------------------------------------------
01088 int le_event_GetFd
01089 (
01090     void
01091 );
01092 
01093 
01094 //--------------------------------------------------------------------------------------------------
01109 //--------------------------------------------------------------------------------------------------
01110 le_result_t le_event_ServiceLoop
01111 (
01112     void
01113 );
01114 
01115 
01116 #endif // LEGATO_EVENTLOOP_INCLUDE_GUARD
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines