Panda3D
|
00001 // Filename: datagramGeneratorNet.h 00002 // Created by: drose (15Feb09) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef DATAGRAMGENERATORNET_H 00016 #define DATAGRAMGENERATORNET_H 00017 00018 #include "pandabase.h" 00019 00020 #include "datagramGenerator.h" 00021 #include "connectionReader.h" 00022 #include "queuedReturn.h" 00023 #include "pmutex.h" 00024 #include "conditionVar.h" 00025 00026 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn<Datagram>); 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : DatagramGeneratorNet 00030 // Description : This class provides datagrams one-at-a-time as read 00031 // directly from the net, via a TCP connection. If a 00032 // datagram is not available, get_datagram() will block 00033 // until one is. 00034 //////////////////////////////////////////////////////////////////// 00035 class EXPCL_PANDA_NET DatagramGeneratorNet : public DatagramGenerator, public ConnectionReader, public QueuedReturn<Datagram> { 00036 PUBLISHED: 00037 DatagramGeneratorNet(ConnectionManager *manager, int num_threads); 00038 virtual ~DatagramGeneratorNet(); 00039 00040 // Inherited from DatagramGenerator 00041 virtual bool get_datagram(Datagram &data); 00042 virtual bool is_eof(); 00043 virtual bool is_error(); 00044 00045 protected: 00046 // Inherited from ConnectionReader 00047 virtual void receive_datagram(const NetDatagram &datagram); 00048 00049 Mutex _dg_lock; 00050 ConditionVar _dg_received; // notified when a new datagram is received. 00051 ConditionVar _dg_processed; // notified when a new datagram is processed. 00052 }; 00053 00054 #include "datagramGeneratorNet.I" 00055 00056 #endif 00057