Panda3D
 All Classes Functions Variables Enumerations
clientDevice.h
1 // Filename: clientDevice.h
2 // Created by: drose (25Jan01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CLIENTDEVICE_H
16 #define CLIENTDEVICE_H
17 
18 #include "pandabase.h"
19 
20 #include "typedReferenceCount.h"
21 
22 #ifdef OLD_HAVE_IPC
23 #include <ipc_mutex.h>
24 #endif
25 
26 class ClientBase;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : ClientDevice
30 // Description : Any of a number of different devices that might be
31 // attached to a ClientBase, including trackers, etc.
32 // This is an abstract interface; the actual
33 // implementations are in ClientTrackerDevice, etc.
34 ////////////////////////////////////////////////////////////////////
35 class EXPCL_PANDA_DEVICE ClientDevice : public TypedReferenceCount {
36 protected:
37  ClientDevice(ClientBase *client, TypeHandle device_type,
38  const string &device_name);
39 
40 public:
41  virtual ~ClientDevice();
42 
43  INLINE ClientBase *get_client() const;
44  INLINE TypeHandle get_device_type() const;
45  INLINE const string &get_device_name() const;
46 
47  INLINE bool is_connected() const;
48  void disconnect();
49 
50  void poll();
51  INLINE void acquire();
52  INLINE void unlock();
53 
54  virtual void output(ostream &out) const;
55  virtual void write(ostream &out, int indent_level = 0) const;
56 
57 private:
58  ClientBase *_client;
59  TypeHandle _device_type;
60  string _device_name;
61  bool _is_connected;
62 
63 #ifdef OLD_HAVE_IPC
64  mutex _lock;
65 #endif
66 
67 public:
68  static TypeHandle get_class_type() {
69  return _type_handle;
70  }
71  static void init_type() {
72  TypedReferenceCount::init_type();
73  register_type(_type_handle, "ClientDevice",
74  TypedReferenceCount::get_class_type());
75  }
76  virtual TypeHandle get_type() const {
77  return get_class_type();
78  }
79  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
80 
81 private:
82  static TypeHandle _type_handle;
83 
84  friend class ClientBase;
85 };
86 
87 INLINE ostream &operator <<(ostream &out, const ClientDevice &device) {
88  device.output(out);
89  return out;
90 }
91 
92 #include "clientDevice.I"
93 
94 #endif
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
An abstract base class for a family of client device interfaces–including trackers, buttons, dials, and other analog inputs.
Definition: clientBase.h:47
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Any of a number of different devices that might be attached to a ClientBase, including trackers...
Definition: clientDevice.h:35