2 // Open Service Platform
3 // Copyright (c) 2012 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://floralicense.org/license/
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 FIoSerialPort.cpp
20 * @brief This is the implementation file for SerialPort class.
25 #include <FBaseSysLog.h>
26 #include <FIoSerialPort.h>
27 #include <FIoISerialPortEventListener.h>
29 #include <FBase_NativeError.h>
31 #include "FIo_SerialPortImpl.h"
33 using namespace Tizen::Base;
35 namespace Tizen { namespace Io
38 SerialPort::SerialPort(void)
39 : __pSerialPortImpl(null)
43 SerialPort::~SerialPort(void)
48 SerialPort::Construct(ISerialPortEventListener& listener)
50 SysAssertf(__pSerialPortImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class\n");
52 __pSerialPortImpl = new (std::nothrow) _SerialPortImpl(listener);
53 SysTryReturnResult(NID_IO, __pSerialPortImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
59 SerialPort::Write(const ByteBuffer& byteBuffer)
61 SysAssertf(__pSerialPortImpl != null, "Not yet constructed. Construct() should be called before use.\n");
63 return __pSerialPortImpl->Write(byteBuffer);
67 SerialPort::GetWriteBufferSize(void) const
69 SysAssertf(__pSerialPortImpl != null, "Not yet constructed. Construct() should be called before use.\n");
71 return __pSerialPortImpl->GetWriteBufferSize();