00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef DCDT_POSTOFFICE_H
00028 #define DCDT_POSTOFFICE_H
00029
00030 #ifdef TEST_PART
00031
00032 typedef struct _TimeTesterElem
00033 {
00034
00035 DCDT_TIME Data;
00036
00037
00038 int Type_Op;
00039
00040 _TimeTesterElem *prev;
00041 }
00042 TimeTesterElem;
00043
00044 #endif
00045
00046 #include <string.h>
00047 #include <math.h>
00048 #include <stdio.h>
00049 #include <stdlib.h>
00050 #include <pthread.h>
00051 #include <iostream>
00052 #include <DCDT_Agora.h>
00053 #include <DCDT_Defs.h>
00054 #include <sys/time.h>
00055 #include <DCDT_Time.h>
00056 #include <DCDT_Msg.h>
00057 #include <DCDT_ctrace.h>
00058
00059 class DCDT_Member;
00060 class DCDT_PostOffice_SLWBU;
00061 class DCDT_PostOffice_SLWDC;
00062 class DCDT_PostOffice_SLWSM;
00063
00065 typedef struct _SubsMsgElem
00066 {
00067 DCDT_Mutex mtx;
00068
00069
00071 unsigned int SubscribersIfLocal[NUMINT_MEMBERS];
00072
00074 unsigned int SubscribersIfRemote[NUMINT_MEMBERS];
00075 }
00076 SubsMsgTypeElem;
00077
00078
00079 #define POSTOFFICE_SLWB 1
00080 #define POSTOFFICE_SLWDC 2
00081 #define POSTOFFICE_SLWSM 3
00082
00083
00084 #define BLOCKING true
00085 #define NOBLOCKING false
00086
00087
00088 #define MSG_ALL_TYPES 0
00089
00094 class DCDT_PostOffice
00095 {
00096 friend class DCDT_MsgManager;
00097 friend class DCDT_Agora;
00098
00099 public:
00100 DCDT_PostOffice (DCDT_Agora * agora, int type);
00101 ~DCDT_PostOffice();
00102
00103 void AddMember(int Mem_ID);
00104 void AddSysMember(int Mem_ID);
00105 void DeleteMemberTableEntry(int Mem_ID );
00106 void AddMsg (DCDT_Msg * MP, int Mem_ID, DCDT_RequestType Type);
00107 const DCDT_Msg * ReadNextMsg ( int MemID, bool wait );
00108 const DCDT_Msg * ReadNextMsg ( int MemID, int type, bool wait );
00109 const DCDT_Msg * ReadLastMsg ( int MemID, int type, bool wait );
00110 void CleanupList ();
00111 void SubscribeMsgTypeID (int Member_ID, int MsgType, DCDT_RequestType ReqType=DCDT_ALL_MSG );
00112 void UnSubscribeMsgTypeID (int Member_ID, int MsgType, DCDT_RequestType ReqType=DCDT_ALL_MSG);
00113 void UnSubscribeAll( int Member_ID );
00114
00115
00116 bool ReadSubscribedMsgMask(unsigned int *mask, int MemID);
00117 bool UpdateSubs(int MemID);
00118 void SetActMsgDeletable (int Member_ID);
00119
00120 private:
00121 void LogMsg( DCDT_Msg *msg );
00122
00123 DCDT_Agora *myAgora;
00124 int PO_Type;
00125
00126 DCDT_PostOffice_SLWBU *PostOffice_SLWB;
00127 DCDT_PostOffice_SLWDC *PostOffice_SLWDC;
00128 DCDT_PostOffice_SLWSM *PostOffice_SLWSM;
00129 };
00130
00131 #endif