Panda3D
 All Classes Functions Variables Enumerations
clientBase.h
1 // Filename: clientBase.h
2 // Created by: jason (04Aug00)
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 CLIENTBASE_H
16 #define CLIENTBASE_H
17 
18 #include "pandabase.h"
19 
20 #include "clientDevice.h"
21 
22 #include "typedReferenceCount.h"
23 #include "luse.h"
24 #include "vector_string.h"
25 #include "vector_int.h"
26 #include "clockObject.h"
27 #include "pointerTo.h"
28 #include "coordinateSystem.h"
29 
30 #ifdef OLD_HAVE_IPC
31 #include "ipc_thread.h"
32 #endif
33 
34 #include "pmap.h"
35 
36 ////////////////////////////////////////////////////////////////////
37 // Class : ClientBase
38 // Description : An abstract base class for a family of client
39 // device interfaces--including trackers, buttons,
40 // dials, and other analog inputs.
41 //
42 // This provides a common interface to connect to such
43 // devices and extract their data; it is used by
44 // TrackerNode etc. to put these devices in the data
45 // graph.
46 ////////////////////////////////////////////////////////////////////
47 class EXPCL_PANDA_DEVICE ClientBase : public TypedReferenceCount {
48 protected:
49  ClientBase();
50 
51 PUBLISHED:
52  ~ClientBase();
53 
54  bool fork_asynchronous_thread(double poll_time);
55  INLINE bool is_forked() const;
56  INLINE bool poll();
57  INLINE double get_last_poll_time() const;
58 
59  INLINE void set_coordinate_system(CoordinateSystem cs);
60  INLINE CoordinateSystem get_coordinate_system() const;
61 
62 public:
63  PT(ClientDevice) get_device(TypeHandle device_type,
64  const string &device_name);
65 
66 protected:
67  virtual PT(ClientDevice) make_device(TypeHandle device_type,
68  const string &device_name)=0;
69 
70  virtual bool disconnect_device(TypeHandle device_type,
71  const string &device_name,
72  ClientDevice *device);
73 
74  virtual void do_poll();
75 
76 private:
79  Devices _devices;
80 
81  bool _forked;
82  double _last_poll_time;
83  int _last_poll_frame;
84  CoordinateSystem _cs;
85 
86 #ifdef OLD_HAVE_IPC
87  int _sleep_time;
88  thread *_client_thread;
89  bool _shutdown;
90 
91  static void* st_callback(void *arg);
92  void callback();
93 #endif
94 
95 
96 public:
97  static TypeHandle get_class_type() {
98  return _type_handle;
99  }
100  static void init_type() {
101  TypedReferenceCount::init_type();
102  register_type(_type_handle, "ClientBase",
103  TypedReferenceCount::get_class_type());
104  }
105  virtual TypeHandle get_type() const {
106  return get_class_type();
107  }
108  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
109 
110 private:
111  static TypeHandle _type_handle;
112 
113  friend class ClientDevice;
114 };
115 
116 #include "clientBase.I"
117 
118 #endif
This is our own Panda specialization on the default STL map.
Definition: pmap.h:52
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