Panda3D
clientDevice.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file clientDevice.h
10  * @author drose
11  * @date 2001-01-25
12  */
13 
14 #ifndef CLIENTDEVICE_H
15 #define CLIENTDEVICE_H
16 
17 #include "pandabase.h"
18 #include "inputDevice.h"
19 
20 class ClientBase;
21 
22 /**
23  * Any of a number of different devices that might be attached to a
24  * ClientBase, including trackers, etc. This is an abstract interface; the
25  * actual implementations are in ClientTrackerDevice, etc.
26  */
27 class EXPCL_PANDA_DEVICE ClientDevice : public InputDevice {
28 protected:
29  ClientDevice(ClientBase *client, TypeHandle device_type,
30  const std::string &device_name);
31 
32 public:
33  virtual ~ClientDevice();
34 
35  INLINE ClientBase *get_client() const;
36  INLINE TypeHandle get_device_type() const;
37 
38  void disconnect();
39 
40  virtual void do_poll() final;
41 
42  virtual void output(std::ostream &out) const;
43  virtual void write(std::ostream &out, int indent_level = 0) const;
44 
45 private:
46  ClientBase *_client;
47  TypeHandle _device_type;
48 
49 public:
50  static TypeHandle get_class_type() {
51  return _type_handle;
52  }
53  static void init_type() {
54  InputDevice::init_type();
55  register_type(_type_handle, "ClientDevice",
56  InputDevice::get_class_type());
57  }
58  virtual TypeHandle get_type() const {
59  return get_class_type();
60  }
61  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
62 
63 private:
64  static TypeHandle _type_handle;
65 
66  friend class ClientBase;
67 };
68 
69 INLINE std::ostream &operator <<(std::ostream &out, const ClientDevice &device) {
70  device.output(out);
71  return out;
72 }
73 
74 #include "clientDevice.I"
75 
76 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a structure representing a single input device.
Definition: inputDevice.h:53
virtual void output(std::ostream &out) const
Writes a one-line string describing the device.
virtual void output(std::ostream &out) const
Writes a one-line string describing the device.
An abstract base class for a family of client device interfaces–including trackers,...
Definition: clientBase.h:43
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Any of a number of different devices that might be attached to a ClientBase, including trackers,...
Definition: clientDevice.h:27