src/Network/Group.hh
changeset 431 c6d7272a164b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Network/Group.hh	Mon Jan 26 23:03:47 2009 +0200
@@ -0,0 +1,46 @@
+#ifndef NETWORK_GROUP_HH
+#define NETWORK_GROUP_HH
+
+#include "Target.hh"
+
+#include <list>
+
+// XXX: ugly forward-declare hack
+class NetworkNode;
+
+/**
+ * Implements group-multicast for groups of NetworkTargets, by having each target copy + send the packet
+ */
+class NetworkGroup : public NetworkTarget {
+    protected:
+        // XXX: only support NetworkNodes for now...
+        typedef std::list<NetworkNode*>::iterator iterator_type;
+           
+        /** List of targets to send to */
+        iterator_type targets_begin, targets_end;
+
+        /** Special-case for single target to exclude */
+        NetworkNode *exclude;
+    
+    public:
+        /**
+         * Construct a NetworkGroup with the given targets.
+         *
+         * This does not copy the iterated list contents - the list must remain valid for the lifetime of this object.
+         *
+         * @param targets the list of targets to send to
+         */
+        NetworkGroup (iterator_type targets_begin, iterator_type targets_end, NetworkNode *except = NULL) :
+            targets_begin(targets_begin), targets_end(targets_end), exclude(except)
+        {
+
+        }
+
+    protected:
+        /**
+         * Implement NetworkTarget
+         */
+        virtual void send_pkt (const NetworkPacketBuffer &pkt, bool reliable = true); 
+};
+
+#endif