ROOT logo
// $Id: UdpPacketSource.h 2668 2012-02-25 02:32:44Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

#ifndef Net1_UdpPacketSource_H
#define Net1_UdpPacketSource_H

#include "Glasses/ZGlass.h"
#include "Gled/GQueue.h"

class ZLog;
class SUdpPacket;


/*

// Abstract base for consumers of UdpPacketSource.

class UdpPacketSink
{
protected:
  typedef GQueue<SUdpPacket> Queue_t;
  Queue_t mUdpPacketQueue;

public:
  virtual ~UdpPacketSink() {}

  // ??? Need this at all ???
  // UdpPacketSource would then be a ZHashList of zglasses,
  // making sure they can be dyn-casted to UdpPacketSink.
  // Then, the sink would get the packet and either do it in 
  // deliverer thread or pass it on to packet queue.
  // This means, we'd loop over list elements all the time.
  // But that's not too bad ... we have list-time stamp.
  //
  // Or ... just register the blody queue to sink. And have a thread, it's not
  // so hard.

  ClassDef(UdpPacketSink, 1);
};

class UdpPacketSinkWithQueue
{
protected:
  typedef GQueue<SUdpPacket> Queue_t;
  Queue_t mUdpPacketQueue;

public:
  virtual ~UdpPacketSinkWithQueue() {}

  // ??? Need this at all ???
  // UdpPacketSource would then be a ZHashList of zglasses,
  // making sure they can be dyn-casted to UdpPacketSink.
  // Then, the sink would get the packet and either do it in 
  // deliverer thread or pass it on to packet queue.

  ClassDef(UdpPacketSinkWithQueue, 1);
};

*/

class UdpPacketSource : public ZGlass
{
  MAC_RNR_FRIENDS(UdpPacketSource);

public:
  typedef GQueue<SUdpPacket>    Queue_t;
  typedef GQueueSet<SUdpPacket> QueueSet_t;

private:
  void _init();

protected:
  ZLink<ZLog>       mLog;          // X{GS} L{}

  QueueSet_t        mConsumerSet;

public:
  UdpPacketSource(const Text_t* n="UdpPacketSource", const Text_t* t=0);
  virtual ~UdpPacketSource();

  void RegisterConsumer  (Queue_t* q);
  void UnregisterConsumer(Queue_t* q);

#include "UdpPacketSource.h7"
  ClassDef(UdpPacketSource, 1);
}; // endclass UdpPacketSource

#endif
 UdpPacketSource.h:1
 UdpPacketSource.h:2
 UdpPacketSource.h:3
 UdpPacketSource.h:4
 UdpPacketSource.h:5
 UdpPacketSource.h:6
 UdpPacketSource.h:7
 UdpPacketSource.h:8
 UdpPacketSource.h:9
 UdpPacketSource.h:10
 UdpPacketSource.h:11
 UdpPacketSource.h:12
 UdpPacketSource.h:13
 UdpPacketSource.h:14
 UdpPacketSource.h:15
 UdpPacketSource.h:16
 UdpPacketSource.h:17
 UdpPacketSource.h:18
 UdpPacketSource.h:19
 UdpPacketSource.h:20
 UdpPacketSource.h:21
 UdpPacketSource.h:22
 UdpPacketSource.h:23
 UdpPacketSource.h:24
 UdpPacketSource.h:25
 UdpPacketSource.h:26
 UdpPacketSource.h:27
 UdpPacketSource.h:28
 UdpPacketSource.h:29
 UdpPacketSource.h:30
 UdpPacketSource.h:31
 UdpPacketSource.h:32
 UdpPacketSource.h:33
 UdpPacketSource.h:34
 UdpPacketSource.h:35
 UdpPacketSource.h:36
 UdpPacketSource.h:37
 UdpPacketSource.h:38
 UdpPacketSource.h:39
 UdpPacketSource.h:40
 UdpPacketSource.h:41
 UdpPacketSource.h:42
 UdpPacketSource.h:43
 UdpPacketSource.h:44
 UdpPacketSource.h:45
 UdpPacketSource.h:46
 UdpPacketSource.h:47
 UdpPacketSource.h:48
 UdpPacketSource.h:49
 UdpPacketSource.h:50
 UdpPacketSource.h:51
 UdpPacketSource.h:52
 UdpPacketSource.h:53
 UdpPacketSource.h:54
 UdpPacketSource.h:55
 UdpPacketSource.h:56
 UdpPacketSource.h:57
 UdpPacketSource.h:58
 UdpPacketSource.h:59
 UdpPacketSource.h:60
 UdpPacketSource.h:61
 UdpPacketSource.h:62
 UdpPacketSource.h:63
 UdpPacketSource.h:64
 UdpPacketSource.h:65
 UdpPacketSource.h:66
 UdpPacketSource.h:67
 UdpPacketSource.h:68
 UdpPacketSource.h:69
 UdpPacketSource.h:70
 UdpPacketSource.h:71
 UdpPacketSource.h:72
 UdpPacketSource.h:73
 UdpPacketSource.h:74
 UdpPacketSource.h:75
 UdpPacketSource.h:76
 UdpPacketSource.h:77
 UdpPacketSource.h:78
 UdpPacketSource.h:79
 UdpPacketSource.h:80
 UdpPacketSource.h:81
 UdpPacketSource.h:82
 UdpPacketSource.h:83
 UdpPacketSource.h:84
 UdpPacketSource.h:85
 UdpPacketSource.h:86
 UdpPacketSource.h:87
 UdpPacketSource.h:88
 UdpPacketSource.h:89
 UdpPacketSource.h:90
 UdpPacketSource.h:91