From 1336b976f6ae02de59ae45ec7d2c5eab16ab4ae8 Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 28 Nov 2000 17:07:43 +0000 Subject: Added events --- comm/BusAccess.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/comm/BusAccess.h b/comm/BusAccess.h index e0bcdf1..7a4abed 100644 --- a/comm/BusAccess.h +++ b/comm/BusAccess.h @@ -18,9 +18,15 @@ #include "Datagram.h" #include "Stream.h" +#include "BufStream.h" #include "SignalHandler.h" #include "ccu/List.h" #include "ccu/IdTable.h" +#include "ccu/String.h" +#include "ccu/HashTable.h" +#include "dnn/Event.h" +#include "dnn/Trigger.h" + class UchBusSubscription; class UchBusTrigger; @@ -31,6 +37,7 @@ friend class UchBusAgent; protected: static int Version; + CcuString Name; sword ListenPort; sword BroadcastPort; UchStream* Server; @@ -39,14 +46,90 @@ static int Version; CcuIdTableOf IdToSubscription; void HandleRead (); + void Clear (); void DeferredHandle (int); void HandleEvent (int, const char*); + bool CheckUnicity (UchBusAgent*, sword); public: - UchBusAccess (sword); + DnnTrigger NewAgents; + + UchBusAccess (const char*, sword); ~UchBusAccess (); - void Subscribe (DnnBaseReaction&, const char*); + void Subscribe (DnnBaseReaction&, const char*, ...); void Emit (const char*, ...); }; + +class UchBusAgent : public UchBufStream { +friend class UchBusAccess; +friend class UchBusServer; + +protected: + CcuListOf RemoteSubscriptions; + sword RemoteId; + UchBusAccess* MyBus; + CcuString Name; + + void WriteString (const char*); + void ProcessLine (const char*); + + UchBusAgent (int, UchBusAccess*); + UchBusAgent (const char*, sword, UchBusAccess*); + ~UchBusAgent (); + + void HandleRead (); + void SendLocalSubscription (const UchBusTrigger*); + void SayHello (); + void SayBye (); + void EmitEvent (const char*); + +public: + DnnTrigger Bye; + CcuHashedArrayOf DirectMsg; + + void Emit (int, const char*, ...); +inline const char* GetName () const { return Name; } +}; + +class UchAgentEvent : public DnnEvent { +public: +static DnnEventType* BusNewAgent, *BusAgentBye; + +protected: + UchBusAgent* Agent; + +public: + UchAgentEvent (UchBusAgent*, DnnEventType*); + ~UchAgentEvent (); + + +inline UchBusAgent* GetAgent () const { return Agent;} +}; + + +class UchDirectEvent : public DnnEvent { +public: + UchBusAgent* Agent; + CcuString Msg; + +public: + UchDirectEvent (UchBusAgent*, const char*); + ~UchDirectEvent (); +}; + + + +class UchBusEvent : public DnnEvent { +public: + CcuString Regexp; + int NbMatches; + CcuListOf MatchList; + CcuString Matches; + + UchBusEvent (const char*, const char*); + ~UchBusEvent (); +}; + + #endif /* BusAccess_H_ */ -- cgit v1.1