Panda3D
clientBase.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 clientBase.h
10  * @author jason
11  * @date 2000-08-04
12  */
13 
14 #ifndef CLIENTBASE_H
15 #define CLIENTBASE_H
16 
17 #include "pandabase.h"
18 
19 #include "clientDevice.h"
20 
21 #include "typedReferenceCount.h"
22 #include "luse.h"
23 #include "vector_string.h"
24 #include "vector_int.h"
25 #include "clockObject.h"
26 #include "pointerTo.h"
27 #include "coordinateSystem.h"
28 
29 #ifdef OLD_HAVE_IPC
30 #include <ipc_thread.h>
31 #endif
32 
33 #include "pmap.h"
34 
35 /**
36  * An abstract base class for a family of client device interfaces--including
37  * trackers, buttons, dials, and other analog inputs.
38  *
39  * This provides a common interface to connect to such devices and extract
40  * their data; it is used by TrackerNode etc. to put these devices in the
41  * data graph.
42  */
43 class EXPCL_PANDA_DEVICE ClientBase : public TypedReferenceCount {
44 protected:
45  ClientBase();
46 
47 PUBLISHED:
48  ~ClientBase();
49 
50  bool fork_asynchronous_thread(double poll_time);
51  INLINE bool is_forked() const;
52  INLINE bool poll();
53  INLINE double get_last_poll_time() const;
54 
55  INLINE void set_coordinate_system(CoordinateSystem cs);
56  INLINE CoordinateSystem get_coordinate_system() const;
57 
58 public:
59  PT(ClientDevice) get_device(TypeHandle device_type,
60  const std::string &device_name);
61 
62 protected:
63  virtual PT(ClientDevice) make_device(TypeHandle device_type,
64  const std::string &device_name)=0;
65 
66  virtual bool disconnect_device(TypeHandle device_type,
67  const std::string &device_name,
68  ClientDevice *device);
69 
70  virtual void do_poll();
71 
72 private:
75  Devices _devices;
76 
77  bool _forked;
78  double _last_poll_time;
79  int _last_poll_frame;
80  CoordinateSystem _cs;
81 
82 #ifdef OLD_HAVE_IPC
83  int _sleep_time;
84  thread *_client_thread;
85  bool _shutdown;
86 
87  static void* st_callback(void *arg);
88  void callback();
89 #endif
90 
91 
92 public:
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  TypedReferenceCount::init_type();
98  register_type(_type_handle, "ClientBase",
99  TypedReferenceCount::get_class_type());
100  }
101  virtual TypeHandle get_type() const {
102  return get_class_type();
103  }
104  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
105 
106 private:
107  static TypeHandle _type_handle;
108 
109  friend class ClientDevice;
110 };
111 
112 #include "clientBase.I"
113 
114 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL map.
Definition: pmap.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An abstract base class for a family of client device interfaces–including trackers,...
Definition: clientBase.h:43
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Any of a number of different devices that might be attached to a ClientBase, including trackers,...
Definition: clientDevice.h:27