summaryrefslogtreecommitdiff
path: root/comm
diff options
context:
space:
mode:
authorchatty2000-11-28 17:07:43 +0000
committerchatty2000-11-28 17:07:43 +0000
commit1336b976f6ae02de59ae45ec7d2c5eab16ab4ae8 (patch)
treecdd214c79a594e86000596bf35a3c9f83227958f /comm
parent6cea474b7fbf7606d0ab92b24e7ab9f3a7f7d460 (diff)
downloadivy-league-1336b976f6ae02de59ae45ec7d2c5eab16ab4ae8.zip
ivy-league-1336b976f6ae02de59ae45ec7d2c5eab16ab4ae8.tar.gz
ivy-league-1336b976f6ae02de59ae45ec7d2c5eab16ab4ae8.tar.bz2
ivy-league-1336b976f6ae02de59ae45ec7d2c5eab16ab4ae8.tar.xz
Added events
Diffstat (limited to 'comm')
-rw-r--r--comm/BusAccess.h87
1 files 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<UchBusTrigger> 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<UchBusSubscription> 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<DnnTrigger> 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<CcuString> MatchList;
+ CcuString Matches;
+
+ UchBusEvent (const char*, const char*);
+ ~UchBusEvent ();
+};
+
+
#endif /* BusAccess_H_ */