2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FNetNetEndPoint.cpp
20 * @brief This is the implementation for the %NetEndPoint class.
23 #include <FBaseUtilUri.h>
24 #include <FBaseShort.h>
25 #include <FNetNetEndPoint.h>
26 #include <FNetIp4Address.h>
27 #include <FBaseSysLog.h>
28 #include "FNet_NetEndPointImpl.h"
30 using namespace Tizen::Base;
32 namespace Tizen { namespace Net
35 NetEndPoint::NetEndPoint(void)
36 : __pNetEndPointImpl(null)
40 NetEndPoint::NetEndPoint(const IpAddress& ipAddress, unsigned short port)
42 __pNetEndPointImpl = new (std::nothrow) _NetEndPointImpl(ipAddress, port);
43 SysTryReturnVoidResult(NID_NET, __pNetEndPointImpl != null, E_OUT_OF_MEMORY,
44 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
45 SysTryReturnVoidResult(NID_NET, GetLastResult() == E_SUCCESS, GetLastResult(),
46 "[%s] IP address is invalid.", GetErrorMessage(GetLastResult()));
49 NetEndPoint::NetEndPoint(const NetEndPoint& rhs)
51 __pNetEndPointImpl = new (std::nothrow) _NetEndPointImpl(*rhs.__pNetEndPointImpl);
52 SysTryReturnVoidResult(NID_NET, __pNetEndPointImpl != null, E_OUT_OF_MEMORY,
53 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
54 SysTryReturnVoidResult(NID_NET, GetLastResult() == E_SUCCESS, GetLastResult(),
55 "[%s] The instance is invalid.", GetErrorMessage(GetLastResult()));
58 NetEndPoint::~NetEndPoint()
60 delete __pNetEndPointImpl;
61 __pNetEndPointImpl = null;
65 NetEndPoint::GetNetAddressFamily(void) const
67 return __pNetEndPointImpl->GetNetAddressFamily();
71 NetEndPoint::GetPort(void) const
73 return __pNetEndPointImpl->GetPort();
77 NetEndPoint::GetAddress(void) const
80 return __pNetEndPointImpl->GetAddress();
84 NetEndPoint::GetNetEndPoint(void) const
86 return __pNetEndPointImpl->GetNetEndPoint();
90 NetEndPoint::operator =(const NetEndPoint& rhs)
97 __pNetEndPointImpl = rhs.__pNetEndPointImpl;
103 NetEndPoint::Equals(const Object& rhs) const
105 const NetEndPoint* pRhs = dynamic_cast<const NetEndPoint*>(&rhs);
111 const _NetEndPointImpl* pRhsImpl = _NetEndPointImpl::GetInstance(*pRhs);
112 if (pRhsImpl == null)
117 return __pNetEndPointImpl->Equals(*pRhsImpl);
121 NetEndPoint::GetHashCode(void) const
123 return __pNetEndPointImpl->GetHashCode();