00001 // mutableserverresult.h: interface for the MutableServerResult class. 00002 // 00004 00005 #if !defined(MUTABLESERVERRESULT_H) 00006 #define MUTABLESERVERRESULT_H 00007 00008 #if _MSC_VER > 1000 00009 #pragma once 00010 #endif // _MSC_VER > 1000 00011 00012 #include "mutableservermessage.h" 00013 #include "result_status.h" 00014 00015 class MutableServerResult : public MutableServerMessage 00016 { 00017 protected: 00018 00019 // ---------------------------------------------------------- 00020 // virtual methods from MutableServerMessage 00021 // to be implemented for a complete derivative classes 00022 // ---------------------------------------------------------- 00023 00024 // BufferInitAlloc -- when preparing to format a message 00025 // using FormatBuffer()], this is 00026 // first called. The result is, 00027 // for the first call, MessageBuffer 00028 // will be assured to be at least this 00029 // long. 00030 // Overriding this method allows 00031 // derivative classes to minimize 00032 // reallocations as bits are appended 00033 // to the message buffer; 00034 // 00035 // NOTE: In each derivative implementation, 00036 // call <super_class>::BufferInitAlloc() to get the 00037 // space needed by that super class (and all baser 00038 // classes), then add the size needed by the 00039 // derivative to arrive at the total size needed. 00040 // The 10 specified here is for the message- 00041 // terminating '\n' and a slight overrun space. 00042 // 00043 long BufferInitAlloc(); 00044 00045 00046 // FormatDerivativeData 00047 // 00048 // Method by which derivative classes append 00049 // their content to MessageBuffer. 00050 // 00051 // 00052 // NOTE: ALWAYS CALL <super_class>::FormatDerivativeData() 00053 // at the start of each implementation to allow 00054 // base classes to append their stuff (if any) 00055 // to the buffer. 00056 // Thus the buffer is built up from the base-most class. 00057 // 00058 // THROW worm_exception for errors 00059 // 00060 void FormatDerivativeData(); 00061 00062 00063 // ParseDerivativeData 00064 // 00065 // Method by which derivative classes extract 00066 // their content to MessageBuffer. 00067 // 00068 // NOTE: Always call <super_class>::ParseDerivativeData() 00069 // at the top of each implementation to allow 00070 // base classes to get their data out of the 00071 // buffer first. 00072 // 00073 // USAGE: 00074 // 00075 // If parsing a multi-line message ('\n'-terminated lines), 00076 // use a loop consisting of: 00077 // 00078 // i = MessageBuffer.find("\n") to find the first line end, 00079 // MessageBuffer.substr(0, i) to extract the string 00080 // (excluding the '\n') 00081 // MessageBuffer.erase(0, i+1) to remove that portion 00082 // 00083 // Since the message should be terminated by an additional 00084 // '\n', when the string returned in the second step 00085 // is of zero length, that is the end of the message. 00086 // 00087 // (If find() does not, it returns MessageBuffer.npos) 00088 // 00089 // THROW worm_exception for errors 00090 // 00091 void ParseDerivativeData(); 00092 00093 00094 // ---------------------------------------------------------- 00095 // for MutableServerResult 00096 // ---------------------------------------------------------- 00097 00098 short Status; 00099 00100 public: 00101 00102 MutableServerResult(); 00103 00104 // THROWs worm_exception if p_status is not one of following: 00105 // 00106 // MSB_RESULT_GOOD 00107 // MSB_RESULT_BUSY 00108 // MSB_RESULT_FAIL 00109 // MSB_RESULT_ERROR 00110 // 00111 void SetStatus( short p_status ); 00112 00113 short GetStatus(); 00114 00115 }; 00116 00117 #endif // !defined(MUTABLESERVERRESULT_H)