src/Network/Group.hh
author Tero Marttila <terom@fixme.fi>
Tue, 27 Jan 2009 00:25:58 +0200
changeset 439 9823e6cd1086
parent 431 c6d7272a164b
permissions -rw-r--r--
some README text
#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