Skip to content

Commit

Permalink
Add placeholders for documentation of new modules
Browse files Browse the repository at this point in the history
  • Loading branch information
arximboldi committed May 12, 2020
1 parent 88d33a0 commit 46755ba
Show file tree
Hide file tree
Showing 23 changed files with 196 additions and 51 deletions.
22 changes: 10 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ via pure functions. And you get time-travel for free!

* **Documentation** (Contents_)
* **Code** (GitHub_)
* **CppRussia-Piter 2019 Talk**: *Squaring the circle* (`YouTube
<https://www.youtube.com/watch?v=e2-FRFEx8CA>`_, `Slides
<https://sinusoid.es/talks/cpprussia19-piter>`_)
* **CppCon 2018 Talk**: *The most valuable values* (`YouTube
<https://www.youtube.com/watch?v=_oBx_NbLghY>`_, `Slides
<https://public.sinusoid.es/talks/cppcon18>`_)
<https://sinusoid.es/talks/cppcon18>`_)
* **C++ on Sea 2019 Talk**: *Postmodern immutable data-structures*
(`YouTube <https://www.youtube.com/watch?v=y_m0ce1rzRI>`_, `Slides
<https://sinusoid.es/talks/cpponsea19>`_)
Expand Down Expand Up @@ -116,29 +119,24 @@ This library is written in **C++17** and a compliant compiler and
standard library necessary. It is `continuously tested`_ with GCC 7,
but it might work with other compilers and versions.

It also depends on `Boost Hana`_. Some optional extensions and modules
It also depends on `Zug`_ and `Boost Hana`_. Some optional extensions and modules
may have other dependencies documented in their respective sections.

.. _Zug: https://github.com/arximboldi/zug/
.. _Boost Hana: https://boostorg.github.io/hana
.. _continuously tested: https://travis-ci.org/arximboldi/immer

Usage
-----

This is a **header only** library but to be configured correctly you need
to run `CMake`_ first::

mkdir -p build && cd build
cmake .. -D lager_BUILD_DEBUGGER=OFF -D lager_BUILD_TESTS=OFF -D lager_BUILD_EXAMPLES=OFF -D lager_BUILD_DOCS=OFF

Now you can just copy the ``lager``
subfolder somewhere in your *include path*.
This is a **header only** you can just copy the ``lager`` subfolder
somewhere in your *include path*.

Some components, like the time-travelling debugger, also require the
installation of extra files.

You can use `CMake`_ to install the library in your
system once you have manually cloned the repository::
You can use `CMake`_ to install the library in your system once you
have manually cloned the repository::

mkdir -p build && cd build
cmake .. && sudo make install
Expand Down
7 changes: 7 additions & 0 deletions doc/cursor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

cursor
======

.. doxygengroup:: cursors
:project: lager
:content-only:
12 changes: 10 additions & 2 deletions doc/cursors.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@

.. _cursors:

Cursors
=======

.. admonition:: TODO
.. admonition:: Work in progress
:class: danger

This section of the documentation has not been written yet.

Meanwhile, you can watch the **C++ Russia 2019 Talk**: `Squaring
the circle: value oriented design in an object oriented system
<https://www.youtube.com/watch?v=e2-FRFEx8CA>`_ (`slides`_).

.. _slides: https://sinusoid.es/talks/cpprussia19-piter

.. image:: http://orvex.org.p11.hostingprod.com/images/under_construction.gif
:align: center
1 change: 1 addition & 0 deletions doc/doxygen.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GENERATE_XML = YES
INPUT = \
../lager \
../lager/event_loop \
../lager/lenses \
../lager/debug
INCLUDE_PATH = ..
QUIET = YES
Expand Down
11 changes: 11 additions & 0 deletions doc/event_loop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ sdl

.. doxygenstruct:: lager::sdl_event_loop
.. doxygenstruct:: lager::with_sdl_event_loop

qt
----

.. doxygenstruct:: lager::with_qt_event_loop

qml
----

.. doxygenclass:: lager::event_loop_quick_item
.. doxygenstruct:: lager::with_qml_event_loop
4 changes: 4 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ Contents
effects
views
modularity
cursors
lenses
time-travel

.. toctree::
:caption: Reference
:maxdepth: 3

context
cursor
debug
deps
event_loop
lens
store
util

Expand Down
11 changes: 11 additions & 0 deletions doc/lens.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

lens
====

.. doxygengroup:: lenses-api
:project: lager
:content-only:

.. doxygengroup:: lenses
:project: lager
:content-only:
18 changes: 18 additions & 0 deletions doc/lenses.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. _lenses:

Lenses
======

.. admonition:: Work in progress
:class: danger

This section of the documentation has not been written yet.

Meanwhile, you can watch the **C++ Russia 2019 Talk**: `Squaring
the circle: value oriented design in an object oriented system
<https://www.youtube.com/watch?v=e2-FRFEx8CA>`_ (`slides`_).

.. _slides: https://sinusoid.es/talks/cpprussia19-piter

.. image:: http://orvex.org.p11.hostingprod.com/images/under_construction.gif
:align: center
10 changes: 4 additions & 6 deletions doc/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,10 @@ with a widget tree UI, by breaking the circle as follows:
.. admonition:: Library support

This diffing mechanism can be a bit cumbersome, and sometimes error
prone. At `Sinusoidal Engineering`_ we are developing a new library
to aid this particular use-case. It will be first presented at the
`C++ Russia Piter`_ and `Meeting C++`_ conferences in Autumn 2019.

.. _C++ Russia Piter: https://cppconf-piter.ru/en/
.. _Meeting C++: http://meetingcpp.com/
prone. :ref:`cursors` can do it for you automatically. They can
also do much more, and are an invaluable tool when `interfacing a
value-oriented data model with an object-oriented
UI<https://www.youtube.com/watch?v=e2-FRFEx8CA>`.

Observables
-----------
Expand Down
5 changes: 5 additions & 0 deletions lager/constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ auto make_constant_node(T&& v)

} // namespace detail

//! @defgroup cursors
//! @{

template <typename T>
class constant : public reader_base<detail::constant_node<T>>
{
Expand All @@ -61,4 +64,6 @@ auto make_constant(T&& v) -> constant<std::decay_t<T>>
return std::forward<T>(v);
}

//! @}

} // namespace lager
7 changes: 5 additions & 2 deletions lager/cursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

namespace lager {

//! @defgroup cursors
//! @{

template <typename DerivT>
struct cursor_mixin
: writer_mixin<DerivT>
Expand Down Expand Up @@ -64,8 +67,6 @@ class cursor_base

/*!
* Provides access to reading and writing values of type `T`.
* Model of `cursor_value`.
* @see `cursor_value`
*/
template <typename T>
class cursor : public cursor_base<detail::cursor_node<T>>
Expand All @@ -76,4 +77,6 @@ class cursor : public cursor_base<detail::cursor_node<T>>
using base_t::base_t;
};

//! @}

} // namespace lager
29 changes: 21 additions & 8 deletions lager/lens.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,38 @@ namespace lager {
namespace detail {

template <typename Whole, typename Part>
struct lens_i {
struct lens_i
{
virtual Part view(Whole const&) const = 0;
virtual Whole set(Whole const&, Part const&) const = 0;
};

template <typename Lens, typename Whole, typename Part>
struct lens_holder : public lens_i<Whole, Part> {
struct lens_holder : public lens_i<Whole, Part>
{
Lens value;

template <typename T>
lens_holder(T&& other) : value{std::forward<T>(other)} {}
lens_holder(T&& other)
: value{std::forward<T>(other)}
{}

Part view(Whole const& w) const override { return ::lager::view(value, w); }

Whole set(Whole const& w, Part const& p) const override {
Whole set(Whole const& w, Part const& p) const override
{
return ::lager::set(value, w, p);
}
};

} // namespace detail

//! @defgroup lenses-api
//! @{

template <typename Whole, typename Part>
class lens : zug::detail::pipeable {
class lens : zug::detail::pipeable
{
std::shared_ptr<detail::lens_i<Whole, Part> const> holder_;

public:
Expand All @@ -41,18 +50,22 @@ class lens : zug::detail::pipeable {
int>::type = 0>
lens(Lens&& lens)
: holder_{new detail::lens_holder<std::decay_t<Lens>, Whole, Part>{
std::forward<Lens>(lens)}} {}
std::forward<Lens>(lens)}}
{}

template <typename F>
auto operator()(F &&f) const {
auto operator()(F&& f) const
{
return [this, f = std::forward<F>(f)](auto&& p) {
return f(holder_->view(std::forward<decltype(p)>(p)))(
[&](auto&& x) {
return holder_->set(std::forward<decltype(p)>(p),
std::forward<decltype(x)>(x));
std::forward<decltype(x)>(x));
});
};
}
};

//! @}

} // namespace lager
30 changes: 23 additions & 7 deletions lager/lenses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#pragma once

#include <zug/compose.hpp>
#include <lager/util.hpp>
#include <zug/compose.hpp>

#include <type_traits>
#include <utility>
Expand All @@ -25,16 +25,19 @@ template <typename T>
struct const_functor;

template <typename T>
auto make_const_functor(T&& x) -> const_functor<T> {
auto make_const_functor(T&& x) -> const_functor<T>
{
return {std::forward<T>(x)};
}

template <typename T>
struct const_functor {
struct const_functor
{
T value;

template <typename Fn>
const_functor operator()(Fn&&) && {
const_functor operator()(Fn&&) &&
{
return std::move(*this);
}
};
Expand All @@ -43,22 +46,28 @@ template <typename T>
struct identity_functor;

template <typename T>
auto make_identity_functor(T&& x) -> identity_functor<T> {
auto make_identity_functor(T&& x) -> identity_functor<T>
{
return {std::forward<T>(x)};
}

template <typename T>
struct identity_functor {
struct identity_functor
{
T value;

template <typename Fn>
auto operator()(Fn&& f) && {
auto operator()(Fn&& f) &&
{
return make_identity_functor(
std::forward<Fn>(f)(std::forward<T>(value)));
}
};
} // namespace detail

//! @defgroup lenses-api
//! @{

template <typename LensT, typename T>
decltype(auto) view(LensT&& lens, T&& x)
{
Expand Down Expand Up @@ -86,8 +95,13 @@ decltype(auto) over(LensT&& lens, T&& x, Fn&& fn)
.value;
}

//! @}

namespace lenses {

//! @defgroup lenses
//! @{

template <typename Getter, typename Setter>
auto getset(Getter&& getter, Setter&& setter)
{
Expand All @@ -103,4 +117,6 @@ auto getset(Getter&& getter, Setter&& setter)

} // namespace lenses

//! @}

} // namespace lager
5 changes: 5 additions & 0 deletions lager/lenses/at.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ std::decay_t<Whole> at_setter_impl(Whole&& whole, Part&& part, Key&& key)

} // namespace detail

//! @defgroup lenses
//! @{

/*!
* `Key -> Lens<{X}, [X]>`
*/
Expand All @@ -78,5 +81,7 @@ auto at(Key key)
});
}

//! @}

} // namespace lenses
} // namespace lager
Loading

0 comments on commit 46755ba

Please sign in to comment.