/* * The Unix Channel * * by Michel Beaudouin-Lafon * * Copyright 1993-1995 * Centre d'Etudes de la Navigation Aerienne (CENA) * * Request management, by Stephane Chatty * * $Id$ * $CurLog$ */ #ifndef ReqMgr_H_ #define ReqMgr_H_ #include "ccu/String.h" #include "ccu/List.h" #include "ccu/bool.h" class ofstream; class MsgField { protected: CcuString Name; CcuString Type; CcuString Impl; public: inline MsgField (const char* n, const char* t, const char* i) : Name (n), Type (t), Impl (i) {} inline const char* GetName () const { return Name; } inline const char* GetType () const { return Type; } inline const char* GetImpl () const { return Impl; } }; class MsgConstructor { friend int Uch_parse (); protected: CcuListOf Params; public: inline void AddParameter (MsgField& f) { Params.Append (&f); } inline const CcuListOf & GetParameters () const { return Params; } }; class MsgType { friend int Uch_parse (); public: enum msg_kind { isRequest, isAnswer, isEvent }; static const char* const ClassSuffix [3]; static const char* const EnumPrefix [3]; static const char* const EnumSuffix [3]; protected: CcuString Name; msg_kind Kind; CcuListOf Fields; CcuListOf Getters; CcuListOf Setters; CcuListOf Constructors; bool DefaultConstructor; public: inline MsgType (const char* n, msg_kind k) : Name (n), Kind (k), DefaultConstructor (false) {} inline void AddField (MsgField* f) { Fields.Append (f); } inline void AddConstructor (MsgConstructor* f) { Constructors.Append (f); } inline void UseDefaultConstructor () { DefaultConstructor = true; } inline const char* GetName () const { return Name; } void DumpDecl (ofstream&, int); void DumpCode (ofstream&, int); }; enum destination { isClient = 1<<0, isServer = 1<<1}; class UchMsgMgr { friend int Uch_parse (); protected: CcuString Name; CcuListOf Requests; CcuListOf Answers; CcuListOf Events; void SetName (const char*); inline void AddRequest (MsgType* t) { Requests.Append (t); } inline void AddAnswer (MsgType* t) { Answers.Append (t); } inline void AddEvent (MsgType* t) { Events.Append (t); } void DumpCode (const char*, int); void DumpDecl (const char*, int); void DumpEnum (ofstream&, MsgType::msg_kind, CcuListOf &); void DumpClientCode (ofstream&); void DumpServerCode (ofstream&); public: UchMsgMgr (); ~UchMsgMgr (); void Read (const char*); void DumpClientHeader (); void DumpServerHeader (); void DumpClientSource (const char*); void DumpServerSource (const char*); inline const char* GetName () const { return Name; } }; #endif /* ReqMgr_H_ */