summaryrefslogtreecommitdiff
path: root/comm/Message.cc
diff options
context:
space:
mode:
authorchatty1993-04-07 11:50:31 +0000
committerchatty1993-04-07 11:50:31 +0000
commitba066c34dde204aa192d03a23a81356374d93731 (patch)
tree39391f6235d2cf8a59a0634ac5ea430cdd21f5d4 /comm/Message.cc
parent05ab076e1c2a9ca16472f9a6b47b8d22914b3783 (diff)
downloadivy-league-ba066c34dde204aa192d03a23a81356374d93731.zip
ivy-league-ba066c34dde204aa192d03a23a81356374d93731.tar.gz
ivy-league-ba066c34dde204aa192d03a23a81356374d93731.tar.bz2
ivy-league-ba066c34dde204aa192d03a23a81356374d93731.tar.xz
Initial revision
Diffstat (limited to 'comm/Message.cc')
-rw-r--r--comm/Message.cc98
1 files changed, 98 insertions, 0 deletions
diff --git a/comm/Message.cc b/comm/Message.cc
new file mode 100644
index 0000000..54cd771
--- /dev/null
+++ b/comm/Message.cc
@@ -0,0 +1,98 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-1993
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * Messages
+ *
+ * $Id$
+ * $CurLog$
+ */
+
+#include "cplus_bugs.h"
+
+#include "Message.h"
+
+/*?class UchMessage
+\typ{UchMessage} is the virtual base class for messages.
+Each subclass must redefine the virtual functions \fun{WriteTo} and \fun{ReadFrom}.
+Messages can be added to buffers and can be retrieved from buffers.
+?*/
+
+/*?nodoc?*/
+UchMessage :: UchMessage ()
+{
+ // nothing
+}
+
+/*?nodoc?*/
+UchMessage :: ~UchMessage ()
+{
+}
+
+/*?
+This virtual function must write a message into a buffer.
+Usually, the implementation of this function in a derived class starts by calling
+the same function of its base class, because a derived class inherits the fields
+of its base class and adds its own fields.
+Data is usually appended to the buffer by the \fun{UchMsgBuffer::Append} functions or operator <<.
+In class \typ{UchMessage}, this function does nothing.
+?*/
+void
+UchMessage :: WriteTo (UchMsgBuffer&)
+{
+ // nothing
+}
+
+/*?
+This virtual function must extract data from the buffer to create the message.
+At most \var{len} bytes should be read from the buffer.
+Usually, the implementation of this function in a derived class starts by calling
+the same function of its base class, because a derived class inherits the fields
+of its base class and adds its own fields.
+Data is usually retrieved from the buffer by the \fun{UchMsgBuffer::Get} functions or operator >>.
+In class \typ{UchMessage}, this function does nothing.
+?*/
+void
+UchMessage :: ReadFrom (UchMsgBuffer&, lword)
+{
+}
+
+/*?
+This virtual function can be redefined in derived classes to support the handling of messages
+after they have been loaded from a buffer. The function \typ{MyClient}::\fun{NewMessage}
+may then look like:
+\begin{ccode}
+void
+MyClient :: NewMessage (UchMsgBuffer& buffer, bool ask)
+{
+ MyRequest* m = 0;
+ lword type;
+ buffer.MsgPeek (&type);
+ switch (type) {
+ case MyFirstReqType:
+ m = new MyFirstRequest;
+ break;
+ case ...
+ ...
+ }
+ if (m) {
+ buffer.Get (m);
+ m->Activate ();
+ return TRUE;
+ }
+ return FALSE;
+}
+\end{ccode}
+However, this virtual function is only provided as a facility and is not used
+by \uch. Redefining it is not mandatory.
+?*/
+void
+UchMessage :: Activate ()
+{
+}
+
+