Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/nto/bakJuly/Message.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__Message_HPP__
00002 #define __J2K__Message_HPP__
00003 
00004 #include <j2k/Fred/Standard.hpp>
00005 #include <errno.h>
00006 #include <sys/neutrino.h>
00007 #include <sys/dispatch.h>
00008 
00009 #ifndef __FRED_MSG_DATA_T__
00010 #define __FRED_MSG_DATA_T__
00011 
00012 enum MsgQueryInfo_t
00013 {
00014 ///////////////////////////////////////////////////////////////////////////////////////////////////
00015 //   Query Request   __OR__   Status State                                                       //
00016 ///////////////////////////////////////////////////////////////////////////////////////////////////
00017   MQI_PING          = 0x0000,   // Ping the server:  Server exist ?!
00018   MQI_STATUS        = 0x0001,   // Retrieve status:  Get current server status. 
00019   MQI_GET           = 0x0002,   // Get an element:   Return some element from current storage
00020   MQI_PUT           = 0x0004,   // Put an element:   Store some element in current storage
00021   MQI_CLEAR         = 0x0008,   // Clear element:    Clear element from current storage
00022   MQI_QUIT          = 0x0010,   // Quit Request:     Caller should quit
00023   MQI_ADD_CONSUMER  = 0x0020,   // Add one consumer slot
00024   MQI_ADD_PRODUCER  = 0x0040,   // Add one producer slot
00025   MQI_IS_EXPIRED    = 0x0080,   // Does my request is expired ?  __OR__  You are expired
00026   MQI_IS_EMPTY      = 0x0100,   // Does the buffer is empty ?    __OR__  Buffer is empty
00027   MQI_IS_FULL       = 0x0200,   // Does the buffer is filled ?   __OR__  Buffer is full
00028   MQI_EXIST         = 0x0400,   // Do you exist ?                __OR__  Server exist
00029   MQI_SUICIDE       = 0x0800,   // Should I suicide ?            __OR__  Please suicide !
00030   MQI_TIMEOUT       = 0x0D90,   // MQI_IS_EXPIRED | MQI_EXIST | MQI_SUICIDE | MQI_QUIT;
00031   MQI_CONSUMER      = 0x0402,   // MQI_EXIST | MQI_GET
00032   MQI_PRODUCER      = 0x0404    // MQI_EXIST | MQI_PUT
00033 ///////////////////////////////////////////////////////////////////////////////////////////////////
00034 };
00035 
00036 /* We specify the header as being at least a pulse */
00037 typedef struct _pulse    msg_header_t;
00038 
00039 /* Our real data comes after the header */
00040 typedef struct _fred_msg_data_t
00041 {
00042   msg_header_t  hdr;
00043   int           request;
00044   int           status;
00045   int           index;
00046   int           number;
00047   void*         data;
00048 } fred_msg_data_t;
00049 
00050 #endif // __FRED_MSG_DATA_T__
00051 
00052 class Message 
00053 {
00054 protected:
00055   fred_msg_data_t  msg;
00056 
00057 public:
00058   Message( int number0 = 0, int request0 = 0, int status0 = 0, int index0 = 0, void* data0 = NULL );
00059 
00060   Message( const Message& src );
00061   const Message& operator= ( const Message& src );
00062 
00063   virtual ~Message();
00064 
00065   void handleHeader();
00066 
00067   int checkHeader( int rcvid );
00068 
00069   inline int isIO();
00070   inline int receive( int channel );
00071   inline int send( int fd, Message* rm );
00072   inline void reply( int rcvid, int number, int state = EOK );
00073 
00074   // Message functions:
00075   inline fred_msg_data_t  getMessage();
00076   inline void*            getMessageAddr();
00077   inline size_t           getMessageSize();
00078   inline int              getNumber();
00079   inline void             setNumber( int nb );
00080   inline int              getRequest();
00081   inline void             setRequest( int r );
00082   inline int              getStatus();
00083   inline void             setStatus( int s );
00084   inline int              getIndex();
00085   inline void             setIndex( int i );
00086   inline void*            getData();
00087   inline void             setData( void* ptr );
00088 
00089   // Header functions:
00090   inline msg_header_t     getHeader();
00091   inline int              getHeaderCode();
00092   inline int              getHeaderScoid();
00093 };
00094 
00095 #include <j2k/nto/Message.inl>
00096 
00097 #endif // End of Message.hpp

Generated on Sun Oct 14 18:46:35 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001