Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/device/clientDevice.h

Go to the documentation of this file.
00001 // Filename: clientDevice.h
00002 // Created by:  drose (25Jan01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef CLIENTDEVICE_H
00020 #define CLIENTDEVICE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include <typedReferenceCount.h>
00025 
00026 #ifdef OLD_HAVE_IPC
00027 #include <ipc_mutex.h>
00028 #endif
00029 
00030 class ClientBase;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : ClientDevice
00034 // Description : Any of a number of different devices that might be
00035 //               attached to a ClientBase, including trackers, etc.
00036 //               This is an abstract interface; the actual
00037 //               implementations are in ClientTrackerDevice, etc.
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDA ClientDevice : public TypedReferenceCount {
00040 protected:
00041   ClientDevice(ClientBase *client, TypeHandle device_type,
00042                const string &device_name);
00043 
00044 public:
00045   virtual ~ClientDevice();
00046 
00047   INLINE ClientBase *get_client() const;
00048   INLINE TypeHandle get_device_type() const;
00049   INLINE const string &get_device_name() const;
00050 
00051   INLINE bool is_connected() const;
00052   void disconnect();
00053 
00054   void poll();
00055   INLINE void lock();
00056   INLINE void unlock();
00057 
00058   virtual void output(ostream &out) const;
00059   virtual void write(ostream &out, int indent_level = 0) const;
00060 
00061 private:
00062   ClientBase *_client;
00063   TypeHandle _device_type;
00064   string _device_name;
00065   bool _is_connected;
00066 
00067 #ifdef OLD_HAVE_IPC
00068   mutex _lock;
00069 #endif
00070 
00071 public:
00072   static TypeHandle get_class_type() {
00073     return _type_handle;
00074   }
00075   static void init_type() {
00076     TypedReferenceCount::init_type();
00077     register_type(_type_handle, "ClientDevice",
00078                   TypedReferenceCount::get_class_type());
00079   }
00080   virtual TypeHandle get_type() const {
00081     return get_class_type();
00082   }
00083   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00084 
00085 private:
00086   static TypeHandle _type_handle;
00087 
00088   friend class ClientBase;
00089 };
00090 
00091 INLINE ostream &operator <<(ostream &out, const ClientDevice &device) {
00092   device.output(out);
00093   return out;
00094 }
00095 
00096 #include "clientDevice.I"
00097 
00098 #endif

Generated on Fri May 2 00:36:12 2003 for Panda by doxygen1.3