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

C:/temp/src/j2k/QNX4/Test/Reader.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__QNX__Reader_HPP__
00002 #define __J2K__QNX__Reader_HPP__
00003 
00004 #include <j2k/Fred/QNX/Project.hpp>
00005 
00006 class Reader
00007  : public MsgThread {
00008 
00009 // : public Thread {
00010 
00011 public:
00012 // Reader() { }
00013 // virtual void Run();
00014 
00015   Reader( int i = 0 ) : count( 0 ), idx( i ) { }
00016   virtual ~Reader() { }
00017 
00018   // The only thing that should be implemented in MsgThreadChild
00019   virtual void* MsgDispatcher( void* m, pid_t replyPid ) {
00020     void ( *Table[3] )( void ) = { 
00021       function1, 
00022       function2, 
00023       function3
00024     };
00025 
00026     serial_t id = *((serial_t*)m);
00027     printf("\nEntering MsgDispatcher,");
00028 
00029     if ( id & _IS_MSG_DATA ) {
00030       MsgData* msg = (MsgData*)m;
00031       printf("\tMsgDataType [%d],", msg->valid );
00032       
00033       if ( msg->valid == 0 ) {
00034         printf("\tExpired MsgData,");
00035         return m;
00036       }
00037 
00038       if ( msg->task < MSG_VALID ) {
00039         printf("\tInvalid Task,");
00040         return m;
00041       }
00042    
00043       if ( ( msg->task == MSG_KILL_THREAD ) || count > 5 ) {
00044         Stop();
00045       } else if ( msg->task == MSG_FUNCTION_CALL ) {
00046         printf("\tReader(%d){%u}[%d][%d]/5 \n", idx, id, msg->index, count );
00047         ( *Table[1] )();
00048         count++;
00049       }
00050     } else {
00051       printf("I have no clue what I am ! [%u]\n\n", id );
00052     }
00053 
00054     return m;
00055   }
00056 
00057   static void function1() {
00058     printf("\nFn1");
00059   }
00060 
00061   static void function2() {
00062     printf("\nFn2");
00063   }
00064 
00065   static void function3() {
00066     printf("\nFn3");
00067   }
00068 
00069 private:
00070   int count;
00071   int idx;
00072 };
00073 
00074 #endif
00075 

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