/* * The Unix Channel * * by Michel Beaudouin-Lafon * * Copyright 1990-1993 * Laboratoire de Recherche en Informatique (LRI) * * Client side: services * * $Id$ * $CurLog$ */ #ifndef Service_H_ #define Service_H_ #include "Message.h" #include "MsgStream.h" #include "error.h" #include "cplus_bugs.h" #include "ccu/List.h" class UchService; // class for storing and retrieving events // class UchMsgQueue : public CcuSmartData { protected: #ifndef CPLUS_BUG19 CcuListOf Queue; #else CcuList Queue; #endif public: UchMsgQueue (); ~UchMsgQueue (); inline void Put (UchMessage* m) { Queue.Append (m); } #ifndef CPLUS_BUG19 inline UchMessage* Peek () { return Queue.First (); } inline UchMessage* Get () { return Queue.RemoveFirst (); } #else inline UchMessage* Peek () { return (UchMessage*) Queue.First (); } inline UchMessage* Get () { return (UchMessage*) Queue.RemoveFirst (); } #endif inline void PutBack (UchMessage* m) { Queue.Prepend (m); } #ifndef CPLUS_BUG19 inline operator const CcuListOf & () const { return Queue; } #else inline operator const CcuList& () const { return Queue; } #endif }; PointerClass (pUchMsgQueue, UchMsgQueue) // UchService is the client's view of a server // we use smart pointers so that the event queue can be shared // class UchService : public UchMsgStream { protected: pUchMsgQueue EvQueue; public: UchService (); UchService (UchAddress*); UchService (const UchService&); ~UchService (); UchChannel* Copy () const; void SetEvQueue (UchMsgQueue*); UchMessage* PeekEvent (bool = true); UchMessage* GetEvent (bool = true); void PutEvent (UchMessage*); void PutBackEvent (UchMessage*); }; class UchEventMsg : public UchMessage { public: UchEventMsg (); ~UchEventMsg (); bool Activate (UchMsgStream&, bool); }; #endif /* Service_H_ */