From ba066c34dde204aa192d03a23a81356374d93731 Mon Sep 17 00:00:00 2001 From: chatty Date: Wed, 7 Apr 1993 11:50:31 +0000 Subject: Initial revision --- comm/OLD/ReqMgr.cc | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 comm/OLD/ReqMgr.cc (limited to 'comm/OLD/ReqMgr.cc') 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 +#include +#include + +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 \n\n"; + + CcuListIterOf 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 req (Requests); + while (++req) { + (*req)->DumpSource (f); + } +} + + +void +RequestType :: DumpHeader (ofstream& f) +{ + f << "class " << Name << " : public UchMessage {\nprotected:\n"; + + CcuListIterOf fields (Fields); + while (++fields) { + RequestField* field = *fields; + f << "\t" << field->GetImpl () << "\t" << field->GetName () << ";\n"; + } + + f << "public:\n\t\t" << Name << " ();\n"; + + CcuListIterOf constr (Constructors); + while (++constr) { + f << "\t\t" << Name << " ("; + CcuListIterOf 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 getter (Getters); + while (++getter) { + RequestField* field = *getter; + f << "inline\t" << field->GetType () << "\tGet" << field->GetName () + << " () const { return (" << field->GetType () << ") " << field->GetName () << "; }\n"; + } + + CcuListIterOf 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 constr (Constructors); + while (++constr) { + f << Name << " :: " << Name << " ("; + CcuListIterOf 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 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"; +} + -- cgit v1.1