playerclient.h
00001
00002
00003
00004
00005 #ifndef PLAYERCLIENT_H
00006 #define PLAYERCLIENT_H
00007
00008 #include "libplayerc++/playerc++config.h"
00009
00010 #include <string>
00011 #include <list>
00012
00013 #ifdef HAVE_BOOST_SIGNALS
00014 #include <boost/signal.hpp>
00015 #include <boost/bind.hpp>
00016 #endif
00017
00018 #ifdef HAVE_BOOST_THREAD
00019 #include <boost/thread/mutex.hpp>
00020 #include <boost/thread/thread.hpp>
00021 #include <boost/thread/xtime.hpp>
00022 #else
00023
00024
00025
00026 namespace boost
00027 {
00028 class thread
00029 {
00030 public:
00031 thread() {};
00032 };
00033
00034 class mutex
00035 {
00036 public:
00037 mutex() {};
00038 class scoped_lock
00039 {
00040 public: scoped_lock(mutex m) {};
00041 };
00042 };
00043 }
00044
00045 #endif
00046
00047 namespace PlayerCc
00048 {
00062 const int PLAYER_PORTNUM(6665);
00064 const std::string PLAYER_HOSTNAME("localhost");
00065
00066 class ClientProxy;
00067
00079 class PlayerClient
00080 {
00081 friend class ClientProxy;
00082
00083
00084 typedef boost::thread thread_t;
00085
00086
00087 typedef boost::mutex mutex_t;
00088
00089 private:
00090
00091 std::list<PlayerCc::ClientProxy*> mProxyList;
00092
00093 std::list<playerc_device_info_t> mDeviceList;
00094
00095
00096
00097 void Connect(const std::string aHostname, uint aPort);
00098
00099
00100 void Disconnect();
00101
00102
00103 playerc_client_t* mClient;
00104
00105
00106 std::string mHostname;
00107
00108
00109 uint mPort;
00110
00111
00112 bool mIsStop;
00113
00114
00115 thread_t* mThread;
00116
00117
00118 void RunThread();
00119
00120 public:
00121
00123 PlayerClient(const std::string aHostname=PLAYER_HOSTNAME,
00124 uint aPort=PLAYER_PORTNUM);
00125
00127 ~PlayerClient();
00128
00130 mutex_t mMutex;
00131
00132
00133
00134
00135
00137 void StartThread();
00138
00140 void StopThread();
00141
00143 void Run(uint aTimeout=10);
00144
00146 void Stop();
00147
00154 bool Peek(uint timeout=0);
00155
00163 void Read();
00164
00169 void ReadIfWaiting();
00170
00177
00178
00187 void SetDataMode(uint aMode);
00188
00207 void SetReplaceRule(int aInterf, int aIndex, int aType, int aSubtype, int aReplace);
00208
00211 void RequestDeviceList();
00212
00213 std::list<playerc_device_info_t> GetDeviceList();
00214
00216 std::string GetHostname() const { return(mHostname); };
00217
00219 uint GetPort() const { return(mPort); };
00220
00222 int LookupCode(std::string aName) const;
00223
00225 std::string LookupName(int aCode) const;
00226 };
00227
00231 }
00232
00233 namespace std
00234 {
00235 std::ostream& operator << (std::ostream& os, const PlayerCc::PlayerClient& c);
00236 }
00237
00238 #endif
00239
Last updated 12 September 2005 21:38:45
|