Back to index

im-sdk  12.3.91
IMProtocol.hh
Go to the documentation of this file.
00001 #ifndef IMPROTOCOL_HH_
00002 #define IMPROTOCOL_HH_
00003 #include <config.h>
00004 #include <map>
00005 #include <IMProtocolStruct.h>
00006 #include "basictype.hh"
00007 #include "IMAccept.hh"
00008 #include "IMState.hh"
00009 
00010 class ICState;
00011 
00012 class IMProtocol
00013 {
00014   protected:
00015     IMAccept *pimaccept;
00016 
00017     typedef map<CARD16BIT, IMState*> IMStateMap;
00018     IMStateMap immap;
00019 
00020     void add_imstate(IMState *pims);
00021     void remove_imstate(IMState *pims);
00022 
00023   protected:
00024     IMState* get_imstate(CARD16BIT im_id)
00025     {
00026        IMStateMap::iterator it;
00027        it = immap.find(im_id);
00028        if (it == immap.end()) return NULL;
00029        return it->second;
00030     }
00031     ICState* get_icstate(CARD16BIT im_id, CARD16BIT ic_id)
00032     {
00033        IMState *pims;
00034        pims = get_imstate(im_id);
00035        if (!pims) return NULL;
00036        return pims->get_icstate(ic_id);
00037     }
00038 
00039   public:
00040     enum CONTEXT_ID_SPECIAL {
00041            INVALID_CONTEXT_ID = 0xFFFF
00042     };
00043     bool dispatch(
00044        CARD16BIT im_id,
00045        CARD16BIT ic_id,
00046        void *message
00047     );
00048 
00049     // concurrency management interface.
00050     enum CONCURRENCY_FLAGS {
00051            SYNC,
00052            ASYNC
00053     };
00054     virtual bool receive_and_dispatch(IMState *pims, int flags = SYNC) = 0;
00055     virtual IMState* accept(int flags = SYNC) = 0;
00056 
00057     IMProtocol(IMAccept *pima);
00058     virtual ~IMProtocol();
00059 
00060   friend class IMState;
00061 };
00062 
00063 #endif /* not IMPROTOCOL_HH_ */
00064 
00065 /* Local Variables: */
00066 /* c-file-style: "iiim-project" */
00067 /* End: */