00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Mark Elendt 00008 * Side Effects 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: UT library (C++) 00015 * 00016 * COMMENTS: Message based IPC 00017 * 00018 */ 00019 00020 #ifndef __UT_Message_h__ 00021 #define __UT_Message_h__ 00022 00023 #include "UT_API.h" 00024 class UT_String; 00025 class UT_SharedMem; 00026 00027 class UT_API UT_MessagePort 00028 { 00029 public: 00030 // 00031 // This port will only receive messages tagged with it's receive tag. 00032 // Every message it sends will have a tag of it's sendTag. 00033 // The tag numbers must be greater than 0 00034 UT_MessagePort(int receiveTag, int sendTag); 00035 ~UT_MessagePort(); 00036 00037 // 00038 // Open a message port. If create is 1, the port will be created if it 00039 // doesn't exist. Return codes: 0 = failure, > 0 success, 2 = created 00040 int open(int port_number, int create = 1); 00041 00042 // This method will attempt to destroy a message port (even if we didn't 00043 // create it). Returns 1 if removed, 0 if not. 00044 static int destroy(int port_number); 00045 00046 // Destructing will automatically close the port... 00047 void close(); 00048 00049 int isAlive() { return myPort >= 0; } 00050 00051 // 00052 // Send returns 0 on error, 1 on success 00053 int send(const char *message, int tag = -1); 00054 00055 // 00056 // Receive returns 0 on error, 1 on success. The wait callback is 00057 // only used on windows. It is there so the help browser can keep 00058 // pumping messages while it blocks on a response from Houdini. 00059 // Otherwise, if Houdini implicitly sends a message to the help browser 00060 // (by moving it's window, etc.) that needs a response, deadlock will 00061 // occur. 00062 int get(UT_String &str, int waitForMsg = 1, 00063 void (*wait_callback)() = 0); 00064 00065 // TODO: Write binary routines... 00066 00067 private: 00068 int myReceiveTag; 00069 int mySendTag; 00070 int myPort; 00071 int myCreatedMemory; 00072 #ifdef WIN32 00073 UT_SharedMem *myPortMem; 00074 #endif 00075 }; 00076 00077 #endif
1.5.9