Panda3D
 All Classes Functions Variables Enumerations
datagramGeneratorNet.h
1 // Filename: datagramGeneratorNet.h
2 // Created by: drose (15Feb09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef DATAGRAMGENERATORNET_H
16 #define DATAGRAMGENERATORNET_H
17 
18 #include "pandabase.h"
19 
20 #include "datagramGenerator.h"
21 #include "connectionReader.h"
22 #include "queuedReturn.h"
23 #include "pmutex.h"
24 #include "conditionVar.h"
25 #include "netDatagram.h"
26 
27 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn<Datagram>);
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : DatagramGeneratorNet
31 // Description : This class provides datagrams one-at-a-time as read
32 // directly from the net, via a TCP connection. If a
33 // datagram is not available, get_datagram() will block
34 // until one is.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDA_NET DatagramGeneratorNet : public DatagramGenerator, public ConnectionReader, public QueuedReturn<Datagram> {
37 PUBLISHED:
38  DatagramGeneratorNet(ConnectionManager *manager, int num_threads);
39  virtual ~DatagramGeneratorNet();
40 
41  // Inherited from DatagramGenerator
42  virtual bool get_datagram(Datagram &data);
43  virtual bool is_eof();
44  virtual bool is_error();
45 
46 protected:
47  // Inherited from ConnectionReader
48  virtual void receive_datagram(const NetDatagram &datagram);
49 
50  Mutex _dg_lock;
51  ConditionVar _dg_received; // notified when a new datagram is received.
52  ConditionVar _dg_processed; // notified when a new datagram is processed.
53 };
54 
55 #include "datagramGeneratorNet.I"
56 
57 #endif
58 
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:43
This class provides datagrams one-at-a-time as read directly from the net, via a TCP connection...
The primary interface to the low-level networking layer in this package.
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:44
This is an abstract base class for a family of classes that listen for activity on a socket and respo...
A condition variable, usually used to communicate information about changing state to a thread that i...
Definition: conditionVar.h:47
This class defines the abstract interace to any source of datagrams, whether it be from a file or fro...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43