Main Page | Class Hierarchy | Class List | File List | Class Members

QAvatarManager.h

00001 
00002 //
00003 // $Id: QAvatarManager.h,v 1.9 2004/04/13 19:10:10 scharver Exp $
00004 //
00005 // Author: Chris Scharver
00006 // Email: scharver@evl.uic.edu
00007 // Copyright (c) 2003 Electronic Visualization Laboratory,
00008 //                    University of Illinois at Chicago
00009 //
00010 // Permission is hereby granted, free of charge, to any person
00011 // obtaining a copy of this software and associated documentation
00012 // files (the "Software"), to deal in the Software without
00013 // restriction, including without limitation the rights to use, copy,
00014 // modify, merge, publish, distribute, sublicense, and/or sell copies
00015 // of the Software, and to permit persons to whom the Software is
00016 // furnished to do so, subject to the following conditions:
00017 //
00018 // The above copyright notice and this permission notice shall be
00019 // included in all copies or substantial portions of the Software.
00020 //
00021 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00024 // NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00025 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00026 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00027 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00028 // DEALINGS IN THE SOFTWARE.
00029 //
00031 
00032 #ifndef _QAVATARMANAGER_H
00033 #define _QAVATARMANAGER_H
00034 
00035 #include <QUANTA/QUANTAmisc_hashDict.hxx>
00036 class QUANTAnet_tcpReflectorClient_c;
00037 class QUANTAnet_udp_c;
00038 
00039 #include <QAvatar.h>
00040 class QAvatarFactory;
00041 class QAvatarListener;
00042 
00043 #ifdef USE_STL_NAMESPACE
00044 #include <list>
00045 using std::list;
00046 #else /* USE_STL_NAMESPACE */
00047 #include <list.h>
00048 #endif /* USE_STL_NAMESPACE */
00049 
00057 class QAvatarManager
00058 {
00059 protected:
00060 
00061   static const char AUX_MSG;
00062   static const char BYE_MSG;
00063   static const char HELLO_MSG;
00064   static const char TRACKER_MSG;
00065 
00066 public:
00067 
00069   QAvatarManager(QAvatarFactory*);
00070 
00072   virtual ~QAvatarManager();
00073 
00075   void checkForTimeouts();
00076 
00078   virtual bool connect(const char*,
00079                        const unsigned short&, const unsigned short&);
00080 
00082   QAvatar* getSelfAvatar();
00083 
00085   void attach(QAvatarListener*);
00086 
00088   void detach(QAvatarListener*);
00089 
00091   virtual void process();
00092 
00094   virtual bool sendAux();
00095 
00097   virtual bool sendBye();
00098 
00100   virtual bool sendHello();
00101 
00103   virtual bool sendTracker();
00104 
00105   void setDataSizes(const size_t&, const size_t&, const size_t&);
00106 
00108   void setTrackerUpdateDelay(const double&);
00109 
00110 protected:
00111 
00113   virtual void handleHailingData(char*, const size_t&);
00114 
00116   virtual void handleTrackerData(char*, const size_t&);
00117 
00119 
00120 
00122   void notifyArrive(QAvatar*);
00123 
00125   void notifyAux(QAvatar*);
00126 
00128   void notifyBye(QAvatar*);
00129 
00131   void notifyHello(QAvatar*);
00132 
00134   void notifyTracker(QAvatar*);
00135 
00137 
00138 protected:
00139 
00141   QUANTAmisc_hashDict<QAvatar*, long>* m_avatarDB;
00142 
00144   QAvatar* m_selfAvatar;
00145 
00147   QAvatarFactory* m_avatarFactory;
00148 
00150   QUANTAnet_tcpReflectorClient_c* m_hailingTCP;
00151 
00153   QUANTAnet_udp_c* m_trackerUDP;
00154 
00156   bool m_noNetworking;
00157 
00158   char* m_hailingBuffer;
00159   size_t m_hailingBufSize;
00160   char* m_trackerBuffer;
00161   size_t m_trackerBufSize;
00162 
00163   double m_lastTimeTrackerSent;
00164   double m_trackerDelay;
00165 
00166   char* m_tempBuffer;
00167 
00168   typedef list<QAvatarListener*> ListenerList;
00169   ListenerList m_listeners;
00170 };
00171 
00172 #endif /* _QAVATARMANAGER_H */

Generated on Tue Apr 13 16:42:26 2004 for QAvatar by doxygen 1.3.6