${PROJECT_SOURCE_DIR}/modules/core/src/lexical_cast.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/mutex.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/named_base_pipe.cpp
- ${PROJECT_SOURCE_DIR}/modules/core/src/named_input_pipe.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/named_output_pipe.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/noncopyable.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/once.cpp
#ifndef DPL_NAMED_PIPE_H
#define DPL_NAMED_PIPE_H
-#include <dpl/noncopyable.h>
#include <dpl/exception.h>
-#include <dpl/abstract_waitable_input.h>
#include <dpl/named_base_pipe.h>
+#include <dpl/file_input.h>
namespace DPL
{
class NamedInputPipe
- : private Noncopyable,
- public NamedBasePipe,
- public AbstractWaitableInput
-{
-public:
- class Exception
- {
- public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
- DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
- };
-
-protected:
- int m_fifo;
-
-public:
- NamedInputPipe();
- virtual ~NamedInputPipe();
-
- void Open(const std::string &fileName);
- void Close();
-
- // AbstractInput
- virtual BinaryQueueAutoPtr Read(size_t size);
-
- // AbstractWaitableInput
- virtual WaitableHandle WaitableReadHandle() const;
-};
+ : public NamedBasePipe,
+ public FileInput
+{};
} // namespace DPL
#endif // DPL_NAMED_PIPE_H
* limitations under the License.
*/
/*
- * @file named_input_pipe.cpp
+ * @file file_input.cpp
* @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
* @version 1.0
* @brief This file is the implementation file of named input pipe
namespace DPL
{
+
namespace // anonymous
{
const size_t DEFAULT_READ_BUFFER_SIZE = 4096;
// GLIB loop intergration workaround
int Main::EcoreSelectInterceptor(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
{
-#if 0
- // Check each descriptor to see if it is valid
- for (int i = 0; i < nfds; i++)
- {
- if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
- {
- // Try to get descriptor flags
- int result = fcntl(i, F_GETFL);
-
- if (result == -1)
- {
- if (errno == EBADF)
- {
- // This a bad descriptor. Remove all occurrences of it.
- if (FD_ISSET(i, readfds))
- {
- LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad read descriptor: " << i);
- FD_CLR(i, readfds);
- }
-
- if (FD_ISSET(i, writefds))
- {
- LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad write descriptor: " << i);
- FD_CLR(i, writefds);
- }
-
- if (FD_ISSET(i, exceptfds))
- {
- LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad exception descriptor: " << i);
- FD_CLR(i, exceptfds);
- }
- }
- else
- {
- // Unexpected error
- Assert(0);
- }
- }
- }
- }
-
- // Find out new maximum
- int newNfds = 0;
-
- for (int i = 0; i < nfds; i++)
- {
- if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
- newNfds = i;
- }
-
- return MainSingleton::Instance().m_oldEcoreSelect(newNfds + 1, readfds, writefds, exceptfds, timeout);
-
-#else
-
// We have to check error code here and make another try because of some glib error's.
fd_set rfds, wfds, efds;
memcpy(&rfds, readfds, sizeof(fd_set));
}
return ret;
-#endif
}
#endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
} // namespace DPL
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file named_input_pipe.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of named input pipe
- */
-#include <stddef.h>
-#include <dpl/named_input_pipe.h>
-#include <dpl/binary_queue.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-namespace DPL
-{
-namespace // anonymous
-{
-const size_t DEFAULT_READ_BUFFER_SIZE = 1024;
-} // namespace anonymous
-
-NamedInputPipe::NamedInputPipe()
- : m_fifo(-1)
-{
-}
-
-NamedInputPipe::~NamedInputPipe()
-{
- Close();
-}
-
-void NamedInputPipe::Open(const std::string& pipeName)
-{
- // Open pipe for reading
- int fifo = TEMP_FAILURE_RETRY(open(pipeName.c_str(), O_RDONLY | O_NONBLOCK));
-
- if (fifo == -1)
- ThrowMsg(Exception::OpenFailed, pipeName);
-
- m_fifo = fifo;
-}
-
-void NamedInputPipe::Close()
-{
- if (m_fifo == -1)
- return;
-
- if (TEMP_FAILURE_RETRY(close(m_fifo)) == -1)
- Throw(Exception::CloseFailed);
-
- m_fifo = -1;
-}
-
-BinaryQueueAutoPtr NamedInputPipe::Read(size_t size)
-{
- size_t bytesToRead = size > DEFAULT_READ_BUFFER_SIZE ? DEFAULT_READ_BUFFER_SIZE : size;
-
- // Malloc default read buffer size
- // It is unmanaged, so it can be then attached directly to binary queue
- void *buffer = malloc(bytesToRead);
-
- if (buffer == NULL)
- throw std::bad_alloc();
-
- ssize_t result = TEMP_FAILURE_RETRY(read(m_fifo, buffer, bytesToRead));
-
- if (result > 0)
- {
- // Succedded to read socket data
- BinaryQueueAutoPtr binaryQueue(new BinaryQueue());
-
- // Append unmanaged memory
- binaryQueue->AppendUnmanaged(buffer, result, &BinaryQueue::BufferDeleterFree, NULL);
-
- // Return buffer
- return binaryQueue;
- }
- else if (result == 0)
- {
- // Socket was gracefuly closed
- free(buffer);
-
- // Return empty buffer
- return BinaryQueueAutoPtr(new BinaryQueue());
- }
- else
- {
- // Must first save errno value, because it may be altered
- int lastErrno = errno;
-
- // Free buffer
- free(buffer);
-
- // Interpret error result
- (void)lastErrno;
-
- // FIXME: Handle specific errno
- Throw(AbstractInput::Exception::ReadFailed);
- }
-}
-
-int NamedInputPipe::WaitableReadHandle() const
-{
- return m_fifo;
-}
-} // namespace DPL
}
};
+namespace {
+class BindVisitor {
+private:
+ DataCommand *m_command;
+public:
+ ArgumentIndex m_bindArgumentIndex;
+
+ BindVisitor(DataCommand *command) :
+ m_command(command),
+ m_bindArgumentIndex(1)
+ {}
+
+ template<typename ColumnType>
+ void Visit(const char*, const ColumnType& value, bool isSet)
+ {
+ if ( isSet )
+ {
+ DataCommandUtils::BindArgument(m_command, m_bindArgumentIndex, value);
+ m_bindArgumentIndex++;
+ }
+ }
+};
+} //anonymous namespace
template<typename TableDefinition>
class __attribute__ ((visibility("hidden"))) Insert : public Query<TableDefinition>
{
}
}
- class BindVisitor {
- private:
- DataCommand *m_command;
- ArgumentIndex m_bindArgumentIndex;
- public:
- BindVisitor(DataCommand *command) :
- m_command(command),
- m_bindArgumentIndex(1)
- {}
-
- template<typename ColumnType>
- void Visit(const char*, const ColumnType& value, bool isSet)
- {
- if ( isSet )
- {
- DataCommandUtils::BindArgument(m_command, m_bindArgumentIndex, value);
- m_bindArgumentIndex++;
- }
- }
- };
-
void Bind()
{
BindVisitor visitor(this->m_command);
}
}
- class BindVisitor {
- private:
- DataCommand *m_command;
-
- public:
- ArgumentIndex m_bindArgumentIndex;
-
- BindVisitor(DataCommand *command) :
- m_command(command),
- m_bindArgumentIndex(1)
- {}
-
- template<typename ColumnType>
- void Visit(const char*, const ColumnType& value, bool isSet)
- {
- if ( isSet )
- {
- DataCommandUtils::BindArgument(m_command, m_bindArgumentIndex, value);
- m_bindArgumentIndex++;
- }
- }
- };
-
void Bind()
{
BindVisitor visitor(this->m_command);