summaryrefslogtreecommitdiff
path: root/comm/OLD/ReqMgr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'comm/OLD/ReqMgr.cc')
-rw-r--r--comm/OLD/ReqMgr.cc184
1 files changed, 184 insertions, 0 deletions
diff --git a/comm/OLD/ReqMgr.cc b/comm/OLD/ReqMgr.cc
new file mode 100644
index 0000000..3850723
--- /dev/null
+++ b/comm/OLD/ReqMgr.cc
@@ -0,0 +1,184 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1993
+ * Centre d'Etudes de la Navigation Aerienne (CENA)
+ *
+ * Request management, by Stephane Chatty
+ *
+ * $Id$
+ * $CurLog$
+ */
+
+#include "ReqMgr.h"
+#include <stdio.h>
+#include <fstream.h>
+#include <fcntl.h>
+
+UchReqMgr :: UchReqMgr ()
+: Name ()
+{
+}
+
+UchReqMgr :: ~UchReqMgr ()
+{
+}
+
+void
+UchReqMgr :: SetName (const char* n)
+{
+ if (Name)
+ fprintf (stderr, "client type already set to %s\n", (const char*) Name);
+ else
+ Name = n;
+}
+
+void
+UchReqMgr :: DumpHeader (const char* file)
+{
+ ofstream f (file, ios::out);
+ if (!f) {
+ extern int errno;
+ fprintf (stderr, "can't write to %s: %s\n", file, sys_errlist [errno]);
+ return;
+ }
+ f << "/*\n *\tRequests for clients " << Name << "\n";
+ f << " *\n *\tThis file was generated by reqgen - do not edit\n*/\n\n";
+ f << "#ifndef " << Name << "Req_H_\n";
+ f << "#define " << Name << "Req_H_\n\n";
+ f << "#include <uch.h>\n\n";
+
+ CcuListIterOf <RequestType> req (Requests);
+ while (++req) {
+ (*req)->DumpHeader (f);
+ }
+ f << "#endif\t/* " << Name << "Req_H_ */\n";
+}
+
+
+void
+UchReqMgr :: DumpSource (const char* file)
+{
+ ofstream f (file, ios::out);
+ if (!f) {
+ extern int errno;
+ fprintf (stderr, "can't write to %s: %s\n", file, sys_errlist [errno]);
+ return;
+ }
+
+ f << "/*\n *\tRequests for clients " << Name << "\n";
+ f << " *\n *\tThis file was generated by reqgen - do not edit\n*/\n\n";
+ f << "#include \"" << file << ".h\"\n\n";
+
+ CcuListIterOf <RequestType> req (Requests);
+ while (++req) {
+ (*req)->DumpSource (f);
+ }
+}
+
+
+void
+RequestType :: DumpHeader (ofstream& f)
+{
+ f << "class " << Name << " : public UchMessage {\nprotected:\n";
+
+ CcuListIterOf <RequestField> fields (Fields);
+ while (++fields) {
+ RequestField* field = *fields;
+ f << "\t" << field->GetImpl () << "\t" << field->GetName () << ";\n";
+ }
+
+ f << "public:\n\t\t" << Name << " ();\n";
+
+ CcuListIterOf <RequestConstructor> constr (Constructors);
+ while (++constr) {
+ f << "\t\t" << Name << " (";
+ CcuListIterOf <RequestField> fields ((*constr)->GetParameters ());
+ int first = 1;
+ while (++fields) {
+ if (first)
+ first = 0;
+ else
+ f << ", ";
+ f << (*fields)->GetType ();
+ }
+ f << ");\n";
+ }
+ f << "\t\t~" << Name << " ();\n";
+ f << "\tvoid\tWriteTo (UchMsgBuffer&);\n";
+ f << "\tvoid\tReadFrom (UchMsgBuffer&, lword);\n";
+ f << "\tvoid\tActivate ();\n";
+
+ CcuListIterOf <RequestField> getter (Getters);
+ while (++getter) {
+ RequestField* field = *getter;
+ f << "inline\t" << field->GetType () << "\tGet" << field->GetName ()
+ << " () const { return (" << field->GetType () << ") " << field->GetName () << "; }\n";
+ }
+
+ CcuListIterOf <RequestField> setter (Setters);
+ while (++setter) {
+ RequestField* field = *setter;
+ f << "inline\tvoid\tSet" << field->GetName () << " (" << field->GetType ()
+ << " f) { " << field->GetName () << " = (" << field->GetImpl () << ") f; }\n";
+ }
+
+ f << "};\n\n";
+}
+
+void
+RequestType :: DumpSource (ofstream& f)
+{
+ f << Name << " :: " << Name << " ()\n: UchMessage ()\n{\n}\n\n";
+
+ CcuListIterOf <RequestConstructor> constr (Constructors);
+ while (++constr) {
+ f << Name << " :: " << Name << " (";
+ CcuListIterOf <RequestField> fields ((*constr)->GetParameters ());
+ int i = 0;
+ while (++fields) {
+ if (i > 0)
+ f << ", ";
+ f << (*fields)->GetType () << " i" << i;
+ ++i;
+ }
+ f << ")\n: UchMessage ()";
+ fields.Reset ();
+ i = 0;
+ while (++fields) {
+ f << ",\n " << (*fields)->GetName () << " (i" << i << ")";
+ ++i;
+ }
+ f << "\n{\n}\n\n";
+ }
+
+ f << Name << " :: ~" << Name << " ()\n{\n}\n\n";
+
+ f << "#ifdef SERVER\n\n";
+
+ f << "void\n" << Name << " :: ReadFrom (UchMsgBuffer& b, lword l)\n{\n";
+ f << "\tb";
+ CcuListIterOf <RequestField> field (Fields);
+ while (++field) {
+ f << " >> " << (*field)->GetName ();
+ }
+ f << ";\n";
+ f << "}\n\n";
+
+ f << "#endif\t/* SERVER */\n\n";
+ f << "#ifdef CLIENT\n\n";
+
+ f << "void\n" << Name << " :: " << "WriteTo (UchMsgBuffer& b)\n{\n";
+ f << "\tb";
+ field.Reset ();
+ while (++field) {
+ f << " << " << (*field)->GetName ();
+ }
+ f << ";\n";
+ f << "}\n\n";
+
+ f << "#endif\t/* CLIENT */\n";
+}
+