00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CLIENTBASE_H
00016 #define CLIENTBASE_H
00017
00018 #include "pandabase.h"
00019
00020 #include "clientDevice.h"
00021
00022 #include "typedReferenceCount.h"
00023 #include "luse.h"
00024 #include "vector_string.h"
00025 #include "vector_int.h"
00026 #include "clockObject.h"
00027 #include "pointerTo.h"
00028 #include "coordinateSystem.h"
00029
00030 #ifdef OLD_HAVE_IPC
00031 #include "ipc_thread.h"
00032 #endif
00033
00034 #include "pmap.h"
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 class EXPCL_PANDA_DEVICE ClientBase : public TypedReferenceCount {
00048 protected:
00049 ClientBase();
00050
00051 PUBLISHED:
00052 ~ClientBase();
00053
00054 bool fork_asynchronous_thread(double poll_time);
00055 INLINE bool is_forked() const;
00056 INLINE bool poll();
00057 INLINE double get_last_poll_time() const;
00058
00059 INLINE void set_coordinate_system(CoordinateSystem cs);
00060 INLINE CoordinateSystem get_coordinate_system() const;
00061
00062 public:
00063 PT(ClientDevice) get_device(TypeHandle device_type,
00064 const string &device_name);
00065
00066 protected:
00067 virtual PT(ClientDevice) make_device(TypeHandle device_type,
00068 const string &device_name)=0;
00069
00070 virtual bool disconnect_device(TypeHandle device_type,
00071 const string &device_name,
00072 ClientDevice *device);
00073
00074 virtual void do_poll();
00075
00076 private:
00077 typedef pmap<string, ClientDevice *> DevicesByName;
00078 typedef pmap<TypeHandle, DevicesByName> Devices;
00079 Devices _devices;
00080
00081 bool _forked;
00082 double _last_poll_time;
00083 int _last_poll_frame;
00084 CoordinateSystem _cs;
00085
00086 #ifdef OLD_HAVE_IPC
00087 int _sleep_time;
00088 thread *_client_thread;
00089 bool _shutdown;
00090
00091 static void* st_callback(void *arg);
00092 void callback();
00093 #endif
00094
00095
00096 public:
00097 static TypeHandle get_class_type() {
00098 return _type_handle;
00099 }
00100 static void init_type() {
00101 TypedReferenceCount::init_type();
00102 register_type(_type_handle, "ClientBase",
00103 TypedReferenceCount::get_class_type());
00104 }
00105 virtual TypeHandle get_type() const {
00106 return get_class_type();
00107 }
00108 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00109
00110 private:
00111 static TypeHandle _type_handle;
00112
00113 friend class ClientDevice;
00114 };
00115
00116 #include "clientBase.I"
00117
00118 #endif