Panda3D

clientDevice.h

00001 // Filename: clientDevice.h
00002 // Created by:  drose (25Jan01)
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 CLIENTDEVICE_H
00016 #define CLIENTDEVICE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "typedReferenceCount.h"
00021 
00022 #ifdef OLD_HAVE_IPC
00023 #include <ipc_mutex.h>
00024 #endif
00025 
00026 class ClientBase;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : ClientDevice
00030 // Description : Any of a number of different devices that might be
00031 //               attached to a ClientBase, including trackers, etc.
00032 //               This is an abstract interface; the actual
00033 //               implementations are in ClientTrackerDevice, etc.
00034 ////////////////////////////////////////////////////////////////////
00035 class EXPCL_PANDA_DEVICE ClientDevice : public TypedReferenceCount {
00036 protected:
00037   ClientDevice(ClientBase *client, TypeHandle device_type,
00038                const string &device_name);
00039 
00040 public:
00041   virtual ~ClientDevice();
00042 
00043   INLINE ClientBase *get_client() const;
00044   INLINE TypeHandle get_device_type() const;
00045   INLINE const string &get_device_name() const;
00046 
00047   INLINE bool is_connected() const;
00048   void disconnect();
00049 
00050   void poll();
00051   INLINE void acquire();
00052   INLINE void unlock();
00053 
00054   virtual void output(ostream &out) const;
00055   virtual void write(ostream &out, int indent_level = 0) const;
00056 
00057 private:
00058   ClientBase *_client;
00059   TypeHandle _device_type;
00060   string _device_name;
00061   bool _is_connected;
00062 
00063 #ifdef OLD_HAVE_IPC
00064   mutex _lock;
00065 #endif
00066 
00067 public:
00068   static TypeHandle get_class_type() {
00069     return _type_handle;
00070   }
00071   static void init_type() {
00072     TypedReferenceCount::init_type();
00073     register_type(_type_handle, "ClientDevice",
00074                   TypedReferenceCount::get_class_type());
00075   }
00076   virtual TypeHandle get_type() const {
00077     return get_class_type();
00078   }
00079   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00080 
00081 private:
00082   static TypeHandle _type_handle;
00083 
00084   friend class ClientBase;
00085 };
00086 
00087 INLINE ostream &operator <<(ostream &out, const ClientDevice &device) {
00088   device.output(out);
00089   return out;
00090 }
00091 
00092 #include "clientDevice.I"
00093 
00094 #endif
 All Classes Functions Variables Enumerations