playerclient.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef PLAYERCLIENT_H
00045 #define PLAYERCLIENT_H
00046
00047 #include "libplayerc++/playerc++config.h"
00048 #include "libplayerc++/utility.h"
00049
00050 #include <string>
00051 #include <list>
00052
00053 #ifdef HAVE_BOOST_SIGNALS
00054 #include <boost/signal.hpp>
00055 #endif
00056
00057 #ifdef HAVE_BOOST_THREAD
00058 #include <boost/thread/mutex.hpp>
00059 #include <boost/thread/thread.hpp>
00060 #include <boost/thread/xtime.hpp>
00061 #include <boost/bind.hpp>
00062 #else
00063
00064
00065
00066 namespace boost
00067 {
00068 class thread
00069 {
00070 public:
00071 thread() {};
00072 };
00073
00074 class mutex
00075 {
00076 public:
00077 mutex() {};
00078 class scoped_lock
00079 {
00080 public: scoped_lock(mutex ) {};
00081 };
00082 };
00083 }
00084
00085 #endif
00086
00087 namespace PlayerCc
00088 {
00089
00090 class ClientProxy;
00091
00103 class PlayerClient
00104 {
00105 friend class ClientProxy;
00106
00107
00108 typedef boost::thread thread_t;
00109
00110
00111 typedef boost::mutex mutex_t;
00112
00113 private:
00114
00115 std::list<PlayerCc::ClientProxy*> mProxyList;
00116
00117 std::list<playerc_device_info_t> mDeviceList;
00118
00119
00120
00121 void Connect(const std::string aHostname, uint32_t aPort);
00122
00123
00124 void Disconnect();
00125
00126
00127 playerc_client_t* mClient;
00128
00129
00130 std::string mHostname;
00131
00132
00133 uint32_t mPort;
00134
00135
00136 unsigned int mTransport;
00137
00138
00139 bool mIsStop;
00140
00141
00142 thread_t* mThread;
00143
00144
00145 void RunThread();
00146
00147 public:
00148
00150 PlayerClient(const std::string aHostname=PLAYER_HOSTNAME,
00151 uint32_t aPort=PLAYER_PORTNUM,
00152 int transport=PLAYERC_TRANSPORT_TCP);
00153
00155 ~PlayerClient();
00156
00158 mutex_t mMutex;
00159
00160
00161
00162
00163
00165 void StartThread();
00166
00168 void StopThread();
00169
00171 void Run(uint32_t aTimeout=10);
00172
00174 void Stop();
00175
00182 bool Peek(uint32_t timeout=0);
00183
00184
00186 void SetRequestTimeout(uint32_t seconds) { playerc_client_set_request_timeout(this->mClient,seconds); }
00187
00188
00192 void SetRetryLimit(int limit) { playerc_client_set_retry_limit(this->mClient,limit); }
00193
00196 int GetRetryLimit() { return(this->mClient->retry_limit); }
00197
00200 void SetRetryTime(double time) { playerc_client_set_retry_time(this->mClient,time); }
00201
00204 double GetRetryTime() { return(this->mClient->retry_time); }
00205
00213 void Read();
00214
00219 void ReadIfWaiting();
00220
00221
00222
00223
00224
00225
00226
00227
00228
00241 void SetDataMode(uint32_t aMode);
00242
00259 void SetReplaceRule(bool aReplace,
00260 int aType = -1,
00261 int aSubtype = -1,
00262 int aInterf = -1);
00263
00266 void RequestDeviceList();
00267
00268 std::list<playerc_device_info_t> GetDeviceList();
00269
00271 std::string GetHostname() const { return(mHostname); };
00272
00274 uint32_t GetPort() const { return(mPort); };
00275
00277 int LookupCode(std::string aName) const;
00278
00280 std::string LookupName(int aCode) const;
00281
00283 uint32_t GetOverflowCount();
00284 };
00285
00286
00287
00288 }
00289
00290 namespace std
00291 {
00292 std::ostream& operator << (std::ostream& os, const PlayerCc::PlayerClient& c);
00293 }
00294
00295 #endif
00296
Last updated 12 September 2005 21:38:45
|