Go to the documentation of this file.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 #ifndef BTAddressH
00033 #define BTAddressH
00034
00035 #include <zeusbase/Net/IPAddress.h>
00036 #include <zeusbase/Net/Bluetooth/BTDefines.hpp>
00037
00038
00039 BEGIN_NAMESPACE_Zeus
00040
00041
00044
00045 zeusbase_class TBTAddress : public TIPAddress
00046 {
00047 public:
00048 TBTAddress();
00049 TBTAddress(const TString& rName);
00050 TBTAddress(const Uint64& uldAddress, const TString& rName);
00051 TBTAddress(const TString& rAddress, const TString& rName);
00052 TBTAddress(SOCKADDR_BTH& rSocketAddr);
00053
00054
00055 virtual TIPAddress* createNewAddress();
00056 virtual TString getHostName() const;
00057 virtual bool getRawAddress(IList<Uint16>& rArray) const;
00058 virtual bool isValid() const;
00059 virtual const struct sockaddr& getSocketAddress() const;
00060 virtual Int getSocketAddressSize() const;
00061 virtual int getSocketFamily() const;
00062 inline virtual void reset() { }
00063
00064 TString formatAddress() const;
00065 static TString formatAddress(const Uint64& uldAddress);
00066 static TString formatAddress(const Uint8* aucAddress);
00067
00068 protected:
00070 SOCKADDR_BTH m_SocketAddress;
00071
00072 private:
00074 TString m_strName;
00075 };
00076
00077
00080
00081 inline TString TBTAddress::formatAddress() const
00082 {
00083 #if defined(ENABLE_WIN32_BLUETOOTH)
00084 return TBTAddress::formatAddress(m_SocketAddress.btAddr);
00085 #elif defined(ENABLE_BLUEZ_BLUETOOTH)
00086 return TBTAddress::formatAddress((Uint8*)m_SocketAddress.rc_bdaddr.b);
00087 #else
00088 return L"";
00089 #endif
00090 }
00091
00092
00093
00097
00098 inline TIPAddress* TBTAddress::createNewAddress()
00099 {
00100 return new TBTAddress();
00101 }
00102
00103
00106
00107 inline TString TBTAddress::getHostName() const
00108 {
00109 return m_strName;
00110 }
00111
00112
00115
00116 inline bool TBTAddress::getRawAddress(IList<Uint16>& ) const
00117 {
00118 return false;
00119 }
00120
00121
00124
00125 inline bool TBTAddress::isValid() const
00126 {
00127 #if defined(ENABLE_WIN32_BLUETOOTH)
00128 return (m_SocketAddress.addressFamily == AF_BTH);
00129 #elif defined(ENABLE_BLUEZ_BLUETOOTH)
00130 return (m_SocketAddress.rc_family == AF_BLUETOOTH);
00131 #else
00132 return false;
00133 #endif
00134 }
00135
00136
00139
00140 inline const struct sockaddr& TBTAddress::getSocketAddress() const
00141 {
00142 return (struct sockaddr&)m_SocketAddress;
00143 }
00144
00145
00148
00149 inline Int TBTAddress::getSocketAddressSize() const
00150 {
00151 return sizeof(m_SocketAddress);
00152 }
00153
00154
00157
00158 inline int TBTAddress::getSocketFamily() const
00159 {
00160 #if defined(ENABLE_WIN32_BLUETOOTH)
00161 return AF_BTH;
00162 #elif defined(ENABLE_BLUEZ_BLUETOOTH)
00163 return AF_BLUETOOTH;
00164 #else
00165 return 0;
00166 #endif
00167 }
00168
00169
00170
00171 END_NAMESPACE_Zeus
00172
00173 #endif