Skip to content

Commit

Permalink
#125 Move graph_impl.hpp into a new folder <ureact/core/>
Browse files Browse the repository at this point in the history
* move all graph_impl.hpp content into a new public interface ureact::core
  • Loading branch information
YarikTH committed Sep 4, 2023
1 parent 3832ee9 commit edac01a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
13 changes: 7 additions & 6 deletions include/ureact/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#include <memory>

#include <ureact/core/graph_impl.hpp>
#include <ureact/detail/defines.hpp>
#include <ureact/detail/graph_impl.hpp>

UREACT_BEGIN_NAMESPACE

Expand All @@ -23,13 +23,14 @@ namespace detail
class UREACT_API context_internals
{
public:
explicit context_internals( std::shared_ptr<react_graph> graph = make_react_graph() );
explicit context_internals(
std::shared_ptr<core::react_graph> graph = core::make_react_graph() );

UREACT_WARN_UNUSED_RESULT react_graph& get_graph();
UREACT_WARN_UNUSED_RESULT const react_graph& get_graph() const;
UREACT_WARN_UNUSED_RESULT core::react_graph& get_graph();
UREACT_WARN_UNUSED_RESULT const core::react_graph& get_graph() const;

private:
std::shared_ptr<react_graph> m_graph_ptr;
std::shared_ptr<core::react_graph> m_graph_ptr;
};

} // namespace detail
Expand Down Expand Up @@ -102,7 +103,7 @@ class UREACT_API context final : protected detail::context_internals
/*!
* @brief Construct @ref context from given react_graph
*/
explicit context( std::shared_ptr<detail::react_graph> graph );
explicit context( std::shared_ptr<core::react_graph> graph );
};

UREACT_END_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef UREACT_DETAIL_GRAPH_IMPL_HPP
#define UREACT_DETAIL_GRAPH_IMPL_HPP
#ifndef UREACT_CORE_GRAPH_IMPL_HPP
#define UREACT_CORE_GRAPH_IMPL_HPP

#include <memory>

Expand All @@ -17,7 +17,7 @@

UREACT_BEGIN_NAMESPACE

namespace detail
namespace core
{

#if !defined( NDEBUG )
Expand Down Expand Up @@ -88,12 +88,12 @@ struct react_graph

UREACT_API std::shared_ptr<react_graph> make_react_graph();

} // namespace detail
} // namespace core

UREACT_END_NAMESPACE

#if UREACT_HEADER_ONLY
# include <ureact/detail/graph_impl.inl>
#endif

#endif // UREACT_DETAIL_GRAPH_IMPL_HPP
#endif // UREACT_CORE_GRAPH_IMPL_HPP
14 changes: 7 additions & 7 deletions include/ureact/detail/context.inl
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
#include <memory>

#include <ureact/context.hpp>
#include <ureact/core/graph_impl.hpp>
#include <ureact/detail/defines.hpp>
#include <ureact/detail/graph_impl.hpp>

UREACT_BEGIN_NAMESPACE

namespace detail
{

UREACT_FUNC context_internals::context_internals( std::shared_ptr<react_graph> graph )
UREACT_FUNC context_internals::context_internals( std::shared_ptr<core::react_graph> graph )
: m_graph_ptr( std::move( graph ) )
{}

UREACT_FUNC react_graph& context_internals::get_graph()
UREACT_FUNC core::react_graph& context_internals::get_graph()
{
return *m_graph_ptr;
}

UREACT_FUNC const react_graph& context_internals::get_graph() const
UREACT_FUNC const core::react_graph& context_internals::get_graph() const
{
return *m_graph_ptr;
}

} // namespace detail

UREACT_FUNC context::context( std::shared_ptr<detail::react_graph> graph )
UREACT_FUNC context::context( std::shared_ptr<core::react_graph> graph )
: detail::context_internals( std::move( graph ) )
{}

Expand All @@ -46,13 +46,13 @@ namespace default_context

UREACT_FUNC context get()
{
thread_local static std::weak_ptr<detail::react_graph> s_instance;
thread_local static std::weak_ptr<core::react_graph> s_instance;

auto graphPtr = s_instance.lock();

if( !graphPtr )
{
s_instance = graphPtr = detail::make_react_graph();
s_instance = graphPtr = core::make_react_graph();
}

return context{ std::move( graphPtr ) };
Expand Down
18 changes: 13 additions & 5 deletions include/ureact/detail/graph_impl.inl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include <memory>
#include <vector>

#include <ureact/core/graph_impl.hpp>
#include <ureact/core/graph_interface.hpp>
#include <ureact/detail/algorithm.hpp>
#include <ureact/detail/defines.hpp>
#include <ureact/detail/graph_impl.hpp>
#include <ureact/core/graph_interface.hpp>
#include <ureact/detail/node_id_vector.hpp>
#include <ureact/detail/slot_map.hpp>

Expand All @@ -27,7 +27,7 @@ UREACT_BEGIN_NAMESPACE
namespace detail
{

class react_graph_impl : public react_graph
class react_graph_impl : public core::react_graph
{
#if !defined( NDEBUG )
bool m_is_locked = false;
Expand All @@ -50,6 +50,9 @@ class react_graph_impl : public react_graph
}
#endif
public:
using node_id = core::node_id;
using reactive_node_interface = core::reactive_node_interface;

react_graph_impl() = default;
~react_graph_impl() override;

Expand Down Expand Up @@ -389,12 +392,17 @@ UREACT_FUNC bool react_graph_impl::topological_queue::fetch_next()
return !m_next_data.empty();
}

} // namespace detail

namespace core
{

UREACT_FUNC std::shared_ptr<react_graph> make_react_graph()
{
return std::make_shared<react_graph_impl>();
return std::make_shared<detail::react_graph_impl>();
}

} // namespace detail
} // namespace core

UREACT_END_NAMESPACE

Expand Down
2 changes: 1 addition & 1 deletion include/ureact/detail/node_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include <utility>

#include <ureact/context.hpp>
#include <ureact/core/graph_impl.hpp>
#include <ureact/core/graph_interface.hpp>
#include <ureact/detail/graph_impl.hpp>
#include <ureact/detail/node_id_vector.hpp>

UREACT_BEGIN_NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion include/ureact/detail/transaction.inl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include <cassert>

#include <ureact/context.hpp>
#include <ureact/core/graph_impl.hpp>
#include <ureact/detail/defines.hpp>
#include <ureact/detail/graph_impl.hpp>
#include <ureact/transaction.hpp>

UREACT_BEGIN_NAMESPACE
Expand Down

0 comments on commit edac01a

Please sign in to comment.