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

QAvatarManager.h

00001 
00002 //
00003 // $Id: QAvatarManager.h,v 1.4 2004/01/14 22:09:05 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 <QAvatar.h>
00036 class QAvatarFactory;
00037 class QAvatarListener;
00038 
00039 #include <QUANTA/QUANTAmisc_hashDict.hxx>
00040 class QUANTAnet_tcpReflectorClient_c;
00041 class QUANTAnet_udp_c;
00042 
00043 #ifdef USE_STL_NAMESPACE
00044 #include <list>
00045 using std::list;
00046 #else
00047 #include <list.h>
00048 #endif /* USE_STL_NAMESPACE */
00049 
00056 class QAvatarManager
00057 {
00058 protected:
00059 
00060   static const char AUX_MSG;
00061   static const char BYE_MSG;
00062   static const char HELLO_MSG;
00063   static const char TRACKER_MSG;
00064 
00065 public:
00066 
00068   QAvatarManager(QAvatarFactory*);
00069 
00071   virtual ~QAvatarManager();
00072 
00074   void checkForTimeouts();
00075 
00077   virtual bool connect(const char*,
00078            const unsigned short&, const unsigned short&);
00079 
00081   QAvatar* getSelfAvatar();
00082 
00084   void attach(QAvatarListener*);
00085 
00087   void detach(QAvatarListener*);
00088 
00090   virtual void process();
00091 
00093   virtual bool sendAux();
00094 
00096   virtual bool sendBye();
00097 
00099   virtual bool sendHello();
00100 
00102   virtual bool sendTracker();
00103 
00104   void setDataSizes(const size_t&, const size_t&, const size_t&);
00105 
00107   void setTrackerUpdateDelay(const double&);
00108 
00109 protected:
00110 
00112   virtual void handleHailingData(char*, const size_t&);
00113 
00115   virtual void handleTrackerData(char*, const size_t&);
00116 
00118 
00119 
00121   void notifyArrive(QAvatar*);
00122 
00124   void notifyAux(QAvatar*);
00125 
00127   void notifyBye(QAvatar*);
00128 
00130   void notifyHello(QAvatar*);
00131 
00133   void notifyTracker(QAvatar*);
00134 
00136 
00137 protected:
00138 
00140   QUANTAmisc_hashDict<QAvatar*, long>* m_avatarDB;
00141 
00143   QAvatar* m_selfAvatar;
00144 
00146   QAvatarFactory* m_avatarFactory;
00147 
00149   QUANTAnet_tcpReflectorClient_c* m_hailingTCP;
00150 
00152   QUANTAnet_udp_c* m_trackerUDP;
00153 
00155   bool m_noNetworking;
00156 
00157   char* m_hailingBuffer;
00158   size_t m_hailingBufSize;
00159   char* m_trackerBuffer;
00160   size_t m_trackerBufSize;
00161 
00162   double m_lastTimeTrackerSent;
00163   double m_trackerDelay;
00164 
00165   char* m_tempBuffer;
00166 
00167   typedef list<QAvatarListener*> ListenerList;
00168   ListenerList m_listeners;
00169 };
00170 
00171 #endif /* _QAVATARMANAGER_H */

Generated on Sat Jan 17 18:00:19 2004 for QAvatar by doxygen 1.3.4