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

C:/temp/src/j2k/QNX4/Group5/Message.hpp

Go to the documentation of this file.
00001 /***
00002    NAME
00003      message
00004    PURPOSE
00005      Message stuff.  All we include is a thread that takes messages.
00006      b_goudre -- Feb 10, 2000: Created.
00007 ***/
00008 
00009 #ifndef __J2K__Train__Message_HPP__
00010 #define __J2K__Train__Message_HPP__
00011 
00012 #include "sthread.hh"
00013 
00014 #define MESSAGE_BUFFER_SIZE 30 // grow as needed
00015 
00016 class Message_thread : public Schedule_thread
00017 {
00018 private:
00019   char buffer_[MESSAGE_BUFFER_SIZE];
00020 
00021 public:
00022   Message_thread();
00023   virtual void run();
00024 
00025   // Note: you shouldn't have to call this directly
00026   void send(const void* buffer, int length, void* reply, int rlength);
00027 
00028   // This, however, can be called directly...
00029   int stop();
00030 
00031   typedef int (Message_thread::*method_type)(...);
00032 
00033 protected:
00034   struct message_table_entry {
00035     int (*marshal)(Message_thread*,
00036                    method_type,
00037                    int,
00038                    char*,
00039                    pid_type);
00040      method_type function;
00041   };
00042 
00043   virtual int message_filter(int m, char* data, pid_type pid) { return 0; }
00044   virtual const message_table_entry* find_entry(int msg) { return 0; };
00045 
00046   static int dispatch(Message_thread* self,
00047                       int msg,
00048                       char* buffer,
00049                       pid_type pid);
00050 };
00051 
00052 // All those do is define a static array in a function
00053 #define DECLARE_MESSAGE_TABLE \
00054   static const message_table_entry message_table_[]; \
00055   virtual const message_table_entry* find_entry(int msg) { \
00056     return &message_table_[msg - 1]; \
00057   }
00058 
00059 #define BEGIN_MESSAGE_TABLE(Cls) \
00060 const Message_thread::message_table_entry Cls::message_table_[] = {
00061 
00062 #define MESSAGE(Marshal, Function) \
00063  { Marshal, (Message_thread::method_type)Function }, //
00064 
00065 #define END_MESSAGE_TABLE \
00066 };
00067 
00068 #endif

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