/* * The Unix Channel * * by Michel Beaudouin-Lafon * * Copyright 1990-1993 * Laboratoire de Recherche en Informatique (LRI) * * Agents, by Stephane Chatty * * $Id$ * $CurLog$ */ #ifndef Agent_H_ #define Agent_H_ #include "ccu/List.h" #include "MsgStream.h" #include "Multiplexer.h" #include "error.h" class UchRemoteAgent; class UchAgent : public UchStream { friend class UchRemoteAgent; protected: #ifndef CPLUS_BUG19 CcuListOf RemoteAgents; #else CcuList RemoteAgents; #endif pUchBaseMultiplexer Mpx; void HandleRead (); public: UchAgent (); UchAgent (const UchAgent&); UchAgent (UchAddress*); ~UchAgent (); UchChannel* Copy () const; bool Setup (UchBaseMultiplexer* cs = 0); inline UchBaseMultiplexer* GetMultiplexer () { return Mpx; } UchRemoteAgent* Contact (UchAddress*); void RemoveRemoteAgent (UchRemoteAgent*); MPX_RES Run (); void Unlisten (); void Broadcast (UchMessage&, bool = false); void Broadcast (UchMessage&, UchRemoteAgent*, bool = false); void Broadcast (UchMsgBuffer&, bool = false); void Broadcast (UchMsgBuffer&, UchRemoteAgent*, bool = false); virtual UchRemoteAgent* CreateRemote (int); virtual void HandleRemove (UchRemoteAgent*); virtual bool SysError (errtype, const char*, int = 0, int = 0); virtual void Error (errtype, const char*, const char*); }; class UchRemoteAgent : public UchMsgStream { friend class UchAgent; protected: UchAgent *MyLocalAgent; public: UchRemoteAgent (UchAgent*); UchRemoteAgent (const UchRemoteAgent& cl); UchRemoteAgent (UchAgent*, UchAddress*); UchRemoteAgent (UchAgent*, int); ~UchRemoteAgent (); UchChannel* Copy () const; void Delete (); inline UchAgent* GetLocalContact () { return MyLocalAgent; } }; #endif /* Agent_H_ */