Commit 1df31891 authored by neverlord's avatar neverlord

moved invoke_rules implementation to own .cpp file

parent 0bccb735
...@@ -28,6 +28,7 @@ libcppa_la_SOURCES = \ ...@@ -28,6 +28,7 @@ libcppa_la_SOURCES = \
src/group.cpp \ src/group.cpp \
src/intermediate.cpp \ src/intermediate.cpp \
src/invokable.cpp \ src/invokable.cpp \
src/invoke_rules.cpp \
src/mailman.cpp \ src/mailman.cpp \
src/matcher_arguments.cpp \ src/matcher_arguments.cpp \
src/message.cpp \ src/message.cpp \
......
...@@ -210,3 +210,4 @@ cppa/detail/boxed.hpp ...@@ -210,3 +210,4 @@ cppa/detail/boxed.hpp
cppa/detail/unboxed.hpp cppa/detail/unboxed.hpp
cppa/detail/matcher_arguments.hpp cppa/detail/matcher_arguments.hpp
src/matcher_arguments.cpp src/matcher_arguments.cpp
src/invoke_rules.cpp
...@@ -50,57 +50,25 @@ struct invoke_rules ...@@ -50,57 +50,25 @@ struct invoke_rules
invoke_rules(const invoke_rules&) = delete; invoke_rules(const invoke_rules&) = delete;
invoke_rules& operator=(const invoke_rules&) = delete; invoke_rules& operator=(const invoke_rules&) = delete;
invoke_rules(list_type&& ll) : m_list(std::move(ll)) { } invoke_rules(list_type&& ll);
public: public:
invoke_rules() { } invoke_rules() = default;
invoke_rules(invoke_rules&& other) : m_list(std::move(other.m_list)) invoke_rules(invoke_rules&& other);
{
} invoke_rules(detail::invokable* arg);
invoke_rules(detail::invokable* arg) invoke_rules(std::unique_ptr<detail::invokable>&& arg);
{
if (arg) m_list.push_back(std::unique_ptr<detail::invokable>(arg)); bool operator()(const any_tuple& t) const;
}
detail::intermediate* get_intermediate(const any_tuple& t) const;
invoke_rules(std::unique_ptr<detail::invokable>&& arg)
{ invoke_rules& splice(invoke_rules&& other);
if (arg) m_list.push_back(std::move(arg));
} invoke_rules operator,(invoke_rules&& other);
bool operator()(const any_tuple& t) const
{
for (auto i = m_list.begin(); i != m_list.end(); ++i)
{
if ((*i)->invoke(t)) return true;
}
return false;
}
detail::intermediate* get_intermediate(const any_tuple& t) const
{
detail::intermediate* result;
for (auto i = m_list.begin(); i != m_list.end(); ++i)
{
result = (*i)->get_intermediate(t);
if (result != nullptr) return result;
}
return nullptr;
}
invoke_rules& splice(invoke_rules&& other)
{
m_list.splice(m_list.end(), other.m_list);
return *this;
}
invoke_rules operator,(invoke_rules&& other)
{
m_list.splice(m_list.end(), other.m_list);
return std::move(m_list);
}
}; };
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation, either version 3 of the License *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#include "cppa/invoke_rules.hpp"
namespace cppa {
invoke_rules::invoke_rules(list_type&& ll) : m_list(std::move(ll))
{
}
invoke_rules::invoke_rules(invoke_rules&& other)
: m_list(std::move(other.m_list))
{
}
invoke_rules::invoke_rules(detail::invokable* arg)
{
if (arg) m_list.push_back(std::unique_ptr<detail::invokable>(arg));
}
invoke_rules::invoke_rules(std::unique_ptr<detail::invokable>&& arg)
{
if (arg) m_list.push_back(std::move(arg));
}
bool invoke_rules::operator()(const any_tuple& t) const
{
for (auto i = m_list.begin(); i != m_list.end(); ++i)
{
if ((*i)->invoke(t)) return true;
}
return false;
}
detail::intermediate* invoke_rules::get_intermediate(const any_tuple& t) const
{
detail::intermediate* result;
for (auto i = m_list.begin(); i != m_list.end(); ++i)
{
result = (*i)->get_intermediate(t);
if (result != nullptr) return result;
}
return nullptr;
}
invoke_rules& invoke_rules::splice(invoke_rules&& other)
{
m_list.splice(m_list.end(), other.m_list);
return *this;
}
invoke_rules invoke_rules::operator,(invoke_rules&& other)
{
m_list.splice(m_list.end(), other.m_list);
return std::move(m_list);
}
} // namespace cppa
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment