00001 #ifndef EDDMSGLOOP_H
00002 #define EDDMSGLOOP_H
00003
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006
00007 #include <proto/EDDMsgHdr.h>
00008
00009 #ifndef EDD_EXPORT
00010 #define EDD_EXPORT
00011 #endif
00012
00013
00014 class tcEDDDataSource;
00015 class tcEDDDataPipe;
00016 class tcEDDThreadManager;
00017 class tcEDDLockManager;
00018
00029 class EDD_EXPORT tcEDDMsgLoop
00030 {
00031 public:
00032 static tcEDDMsgLoop* GetInstance(void);
00033
00034 int AddDataPipe(tcEDDDataPipe* apDataPipe);
00035 int RemoveDataPipe(int anPipeID);
00036 int AddDataSource(tcEDDDataSource* apDataSource);
00037 int RemoveDataSource(int anSourceID);
00038
00039 static const unsigned int gnMaxDataPipes = 10;
00040 static const unsigned int gnMaxDataSources = 128;
00041
00042 int SendMsg(tsEDDMsgHdr* apBuffer, bool BrdCast = false);
00043 int GetMaxMessageLen(int anSourceID);
00044
00045 static tcEDDMsgLoop* gpMsgLoop;
00046
00047 bool IsSubscribed(uint16_t anSourceId);
00048
00049 protected:
00050 virtual ~tcEDDMsgLoop(void);
00051 tcEDDMsgLoop(void);
00052 void InitOSDependencies(void);
00053 void HandleMessage(tsEDDMsgHdr* apMsg, int anPipeID);
00054
00059 typedef enum
00060 {
00061 eeWaitSync,
00062 eeGetHeader,
00063 eeGetBytes
00064 } teParseState;
00065
00066 static int DispatchReceiverThread(void* anPipeID, void* apFoo, void* apGoo);
00067 int ReceiverThread(int anPipeID);
00068
00069 tcEDDDataPipe* maDataPipes[gnMaxDataPipes];
00070 tcEDDDataSource* maDataSources[gnMaxDataSources];
00071 unsigned int maSubscriptionTable[gnMaxDataPipes][gnMaxDataSources];
00072 unsigned int maRcvThreadHandles[gnMaxDataPipes];
00073 tcEDDThreadManager* mpThreadManager;
00074 tcEDDLockManager* mpLockManager;
00075 int mhTableLock;
00076 volatile bool maShutdownThread[gnMaxDataPipes];
00077
00078 };
00079
00080 #endif
00081