Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

DCDT_PostOffice.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 dEVICE cOMMUNITIES dEVELOPMENT tOOLKIT 
00003 
00004 DCDT_PostOffice.h
00005 
00006 COPYRIGHT (C) 2002  Paolo Meriggi (meriggi@ing.unibs.it)
00007                     Alessandro Mazzini (mazzini@airlab.elet.polimi.it)
00008                     Cristian Giussani (cgiussani@fastflow.it)
00009 
00010 
00011 This library is free software; you can redistribute it and/or
00012 modify it under the terms of the GNU Lesser General Public
00013 License as published by the Free Software Foundation; either
00014 version 2 of the License, or (at your option) any later version.
00015 
00016 This library is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 Lesser General Public License for more details.
00020 
00021 You should have received a copy of the GNU Lesser General Public
00022 License along with this library; if not, write to the Free Software
00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
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   // Time of the measure
00035   DCDT_TIME Data;
00036   
00037   // Type of the measure
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   // Local and Remote are referred to the msg, i.e. to the its publisher
00069 
00071   unsigned int SubscribersIfLocal[NUMINT_MEMBERS];
00072 
00074   unsigned int SubscribersIfRemote[NUMINT_MEMBERS];
00075 }
00076 SubsMsgTypeElem;
00077 
00078 // Postoffice types
00079 #define POSTOFFICE_SLWB   1
00080 #define POSTOFFICE_SLWDC  2
00081 #define POSTOFFICE_SLWSM  3
00082 
00083 // Receive types
00084 #define BLOCKING true
00085 #define NOBLOCKING false
00086 
00087 // Message types
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   //inline void UpdateSubscribersMask (int MemID);
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

Generated on Sun Jun 19 10:35:50 2005 for dcdt by  doxygen 1.3.9.1