Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 108 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,43 @@ target_sources(
include/log/level.hpp
include/log/log.hpp)

add_library(cib_msg INTERFACE)
target_compile_features(cib_msg INTERFACE cxx_std_20)
target_link_libraries_system(
cib_msg
INTERFACE
async
cib_log
cib_lookup
cib_match
cib_sc
stdx)

target_sources(
cib_msg
INTERFACE FILE_SET
msg
TYPE
HEADERS
BASE_DIRS
include
FILES
include/msg/callback.hpp
include/msg/detail/indexed_builder_common.hpp
include/msg/detail/indexed_handler_common.hpp
include/msg/detail/separate_sum_terms.hpp
include/msg/field.hpp
include/msg/field_matchers.hpp
include/msg/handler_builder.hpp
include/msg/handler.hpp
include/msg/handler_interface.hpp
include/msg/indexed_builder.hpp
include/msg/indexed_handler.hpp
include/msg/indexed_service.hpp
include/msg/message.hpp
include/msg/send.hpp
include/msg/service.hpp)

add_library(cib_log_fmt INTERFACE)
target_compile_features(cib_log_fmt INTERFACE cxx_std_20)
target_link_libraries_system(cib_log_fmt INTERFACE cib_log fmt::fmt-header-only
Expand All @@ -149,24 +186,31 @@ target_sources(
FILES
include/log/fmt/logger.hpp)

add_library(cib INTERFACE)
target_compile_features(cib INTERFACE cxx_std_20)
target_link_libraries_system(
cib
INTERFACE
async
cib_interrupt
cib_lookup
cib_match
cib_sc
concurrency
fmt::fmt-header-only
stdx)
add_library(cib_log_mipi INTERFACE)
target_compile_features(cib_log_mipi INTERFACE cxx_std_20)
target_link_libraries_system(cib_log_mipi INTERFACE cib_log cib_msg concurrency
stdx)

target_sources(
cib
cib_log_mipi
INTERFACE FILE_SET
cib
log
TYPE
HEADERS
BASE_DIRS
include
FILES
include/log/catalog/catalog.hpp
include/log/catalog/mipi_encoder.hpp)

add_library(cib_nexus INTERFACE)
target_compile_features(cib_nexus INTERFACE cxx_std_20)
target_link_libraries_system(cib_nexus INTERFACE stdx)

target_sources(
cib_nexus
INTERFACE FILE_SET
nexus
TYPE
HEADERS
BASE_DIRS
Expand All @@ -175,7 +219,6 @@ target_sources(
include/cib/builder_meta.hpp
include/cib/built.hpp
include/cib/callback.hpp
include/cib/cib.hpp
include/cib/config.hpp
include/cib/detail/components.hpp
include/cib/detail/constexpr_conditional.hpp
Expand All @@ -186,11 +229,14 @@ target_sources(
include/cib/detail/extend.hpp
include/cib/detail/nexus_details.hpp
include/cib/func_decl.hpp
include/cib/nexus.hpp
include/cib/top.hpp)
include/cib/nexus.hpp)

add_library(cib_flow INTERFACE)
target_compile_features(cib_flow INTERFACE cxx_std_20)
target_link_libraries_system(cib_flow INTERFACE cib_log cib_nexus cib_sc stdx)

target_sources(
cib
cib_flow
INTERFACE FILE_SET
flow
TYPE
Expand All @@ -210,33 +256,19 @@ target_sources(
include/flow/run.hpp
include/flow/step.hpp)

target_sources(
cib
INTERFACE FILE_SET
msg
TYPE
HEADERS
BASE_DIRS
include
FILES
include/msg/callback.hpp
include/msg/detail/indexed_builder_common.hpp
include/msg/detail/indexed_handler_common.hpp
include/msg/detail/separate_sum_terms.hpp
include/msg/field.hpp
include/msg/field_matchers.hpp
include/msg/handler_builder.hpp
include/msg/handler.hpp
include/msg/handler_interface.hpp
include/msg/indexed_builder.hpp
include/msg/indexed_handler.hpp
include/msg/indexed_service.hpp
include/msg/message.hpp
include/msg/send.hpp
include/msg/service.hpp)
add_library(cib_seq INTERFACE)
target_compile_features(cib_seq INTERFACE cxx_std_20)
target_link_libraries_system(
cib_seq
INTERFACE
cib_flow
cib_log
cib_nexus
cib_sc
stdx)

target_sources(
cib
cib_seq
INTERFACE FILE_SET
seq
TYPE
Expand All @@ -248,29 +280,53 @@ target_sources(
include/seq/impl.hpp
include/seq/step.hpp)

add_library(cib_log_mipi INTERFACE)
target_compile_features(cib_log_mipi INTERFACE cxx_std_20)
target_link_libraries_system(cib_log_mipi INTERFACE cib cib_log concurrency
stdx)
add_library(cib INTERFACE)
target_compile_features(cib INTERFACE cxx_std_20)
target_link_libraries_system(
cib
INTERFACE
async
cib_flow
cib_interrupt
cib_log
cib_log_fmt
cib_log_mipi
cib_lookup
cib_match
cib_msg
cib_nexus
cib_sc
cib_seq
concurrency
fmt::fmt-header-only
stdx)

target_sources(
cib_log_mipi
cib
INTERFACE FILE_SET
log
cib
TYPE
HEADERS
BASE_DIRS
include
FILES
include/log/catalog/catalog.hpp
include/log/catalog/mipi_encoder.hpp)
include/cib/cib.hpp
include/cib/top.hpp)

if(PROJECT_IS_TOP_LEVEL)
add_docs(docs)
clang_tidy_interface(cib)
clang_tidy_interface(cib_flow)
clang_tidy_interface(cib_interrupt)
clang_tidy_interface(cib_lookup)
clang_tidy_interface(cib_log)
clang_tidy_interface(cib_log_fmt)
clang_tidy_interface(cib_log_mipi)
clang_tidy_interface(cib_match)
clang_tidy_interface(cib_msg)
clang_tidy_interface(cib_nexus)
clang_tidy_interface(cib_sc)
clang_tidy_interface(cib_seq)

# Enable functional and performance test suites.
add_subdirectory(test)
Expand Down
14 changes: 11 additions & 3 deletions docs/flows.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ namespace example_component {
==== `operator*`

Explicitly add an action to the flow. Actions used in flow extensions without
the `*` will be treated as references only and will not be added to the
the `\*` will be treated as references only and will not be added to the
flow at that location. It is a compilation error if an action is not added
with a `*` in exactly one location in the overall config.

Expand Down Expand Up @@ -388,8 +388,12 @@ what happens by default when we run the flow.
// the default flow builder and service
template <stdx::ct_string Name = "">
using builder = flow::graph<Name, flow::graph_builder<impl>>;

template <stdx::ct_string Name = "">
struct service : cib::builder_meta<builder<Name>, flow::FunctionPtr> {};
struct service {
using builder_t = builder<Name>;
using interface_t = flow::FunctionPtr;
};

// declare a flow service
struct MorningRoutine : public service<"MorningRoutine"> {};
Expand All @@ -410,8 +414,12 @@ But given a flow, other renderings are possible.
// a flow builder and service that produces a graphviz rendering
template <stdx::ct_string Name = "">
using viz_builder = flow::graph<Name, flow::graphviz_builder>;

template <stdx::ct_string Name = "">
struct viz_service : cib::builder_meta<builder<Name>, flow::VizFunctionPtr> {};
struct viz_service {
using builder_t = builder<Name>;
using interface_t = flow::VizFunctionPtr;
};
----

Here, `viz_service` will produce a graphviz rendering of a flow using the
Expand Down
37 changes: 34 additions & 3 deletions docs/intro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,47 @@ The library dependencies are:

- https://github.com/boostorg/mp11[Boost.MP11]
- https://github.com/intel/cpp-std-extensions[C++ std extensions (`stdx`)]
- https://github.com/intel/cpp-baremetal-concurrency[Baremetal Concurrency]
- https://github.com/intel/cpp-baremetal-concurrency[Baremetal Concurrency (`conc`)]
- https://github.com/intel/cpp-senders-and-receivers[Baremetal Senders and Receivers (`async`)]
- https://github.com/fmtlib/fmt[fmt]

=== Libraries
=== Functionality

_cib_ contains several libraries that work together:
_cib_ contains several parts that work together:

- xref:flow.adoc#_the_flow_library[`flow`]
- xref:logging.adoc#_the_logging_library[`logging`]
- xref:interrupt.adoc#_the_interrupt_library[`interrupt`]
- xref:match.adoc#_the_match_library[`match`]
- xref:message.adoc#_the_message_library[`message`]
- xref:sc.adoc#_the_sc_string_constant_library[`sc` (string constant)]

=== Sub-library DAG

Various sub-libraries within CIB form a dependency graph. `cib` is an omnibus
library that contains all the functionality.

[mermaid, format="svg"]
----
flowchart BT
sc(cib_sc)
nexus(cib_nexus)
lookup(cib_lookup)

flow(cib_flow) --> nexus
flow --> log

interrupt(cib_interrupt) --> sc
match(cib_match) --> sc
log(cib_log) --> sc


log_fmt(cib_log_fmt) --> log
msg(cib_msg) --> log & match
msg --> lookup

log_mipi(cib_log_mipi) --> msg
seq(cib_seq) --> flow

cib --> interrupt & seq & log_fmt & log_mipi
----
32 changes: 6 additions & 26 deletions include/cib/builder_meta.hpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
#pragma once

namespace cib {
/**
* Describe a builder to cib.
*
* @tparam Builder
* The initial builder type cib should use when creating a builder.
* This is only the initial type, the Builder::add(...) function
* may return a different type and cib will track that correctly.
*
* @tparam Interface
* The type-erased interface services built with this builder
* will implement. For example, cib::callback allows many other
* callables to get executed when its service gets invoked. The
* type-erased interface for cib::callback is a function pointer.
*
* @see cib::built
*
* @example callback::service
*/
template <typename Builder, typename Interface> struct builder_meta {
using builder_t = Builder;
using interface_t = Interface;
template <typename T>
concept builder_meta = requires {
typename T::builder_t;
typename T::interface_t;
};

template <typename BuilderMeta>
using builder_t = typename BuilderMeta::builder_t;

template <typename BuilderMeta>
using interface_t = typename BuilderMeta::interface_t;
template <builder_meta T> using builder_t = typename T::builder_t;
template <builder_meta T> using interface_t = typename T::interface_t;
} // namespace cib
10 changes: 1 addition & 9 deletions include/cib/built.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,5 @@
#include <cib/builder_meta.hpp>

namespace cib {
/**
* Pointer to a built service implementation.
*
* @tparam ServiceMeta
* Tag name of the service.
*
* @see cib::builder_meta
*/
template <typename ServiceMeta> interface_t<ServiceMeta> service;
template <builder_meta ServiceMeta> interface_t<ServiceMeta> service;
} // namespace cib
8 changes: 4 additions & 4 deletions include/cib/callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ template <int NumFuncs = 0, typename... ArgTypes> struct builder {
/**
* Extend this to create named callback services.
*
* Types that extend callback_meta can be used as unique names with
* Types that extend service can be used as unique names with
* cib::exports and cib::extend.
*
* @tparam ArgTypes
Expand All @@ -116,8 +116,8 @@ template <int NumFuncs = 0, typename... ArgTypes> struct builder {
* @see cib::exports
* @see cib::extend
*/
template <typename... ArgTypes>
struct service
: public cib::builder_meta<builder<0, ArgTypes...>, void (*)(ArgTypes...)> {
template <typename... ArgTypes> struct service {
using builder_t = builder<0, ArgTypes...>;
using interface_t = void (*)(ArgTypes...);
};
} // namespace callback
1 change: 0 additions & 1 deletion include/cib/config.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <cib/builder_meta.hpp>
#include <cib/detail/components.hpp>
#include <cib/detail/config_details.hpp>
#include <cib/detail/config_item.hpp>
Expand Down
Loading