Skip to main content

Scramjet Framework C++

last commit Build status Known Vulnerabilities Discord Donate

⭐ Star us on GitHub — it motivates us a lot! 🚀

Framework Logo

We are open to your feedback! We encourage you to report issues with any ideas, suggestions and features you would like to see in this version. You can also upvote (+1) existing ones to show us the direction we should take in developing Scramjet Framework.

Table of contents

Installation

To use Ifca interface library just clone framework-cpp repository and add include directory to your project then simply include headers of your need.

Usage

Write and read chunks:

std::shared_future<void> write(Chunk chunk)
  • writes chunk of type Chunk to ifca algorithm (must be the same type as input type of first transform). Returns drain state- if we've surpressed [maxParallel] chunk processed, it will return shared_future to wait for draining stream, otherwise returns already set shared_future.
std::future<OutputType> read()
  • Returns future of processed chunk of type OutputType- type returned by last transform in chain. Future is set after transformations are finished.

Transform chunks:

To add Transform to processing chain use:

 addTransform(Transform)

Transforms accept any callable object having operator(ChunkType value) overloaded- functions, member functions, lambdas, std::function, functional objects.

Possible values are:

 each(Callable function)
  • Calls Callable(chunk) and passes result of callable further.
 map(Callable function)
  • Calls Callable(chunk) and passes same chunk further without taking result of callable.
 filter(Predicate function)
  • Calls Predicate(chunk)- must return bool value. If predicate is true passes chunk further, otherwise filters out chunk from flow.

Example usage:

  // for readability only
using namespace ifca;

auto incrementByOne = [](int chunk) {
return chunk + 1;
};
auto showChunk = [](int chunk) {
std::cout << chunk << "\n";
return chunk;
};
auto filterOddChunk = [](int chunk){
return (chunk % 2 == 0);
}

const unsigned int maxParallel = 8;

auto ifca = Ifca().addTransform(map(incrementByOne)).addTransform(each(showChunk)).addTransform(filter(filterOddChunk));

auto inputReader = std::async(std::launch::async, [&]() {
int c;
while (std::cin >> c) {
ifca.write(c).wait();
}
ifca.end();
});

auto outputReader = std::async(std::launch::async, [&]() {
while (true)
std::cout << ifca.read().get();
});
outputReader.wait();

Requesting Features

Anything missing? Or maybe there is something which would make using Scramjet Framework much easier or efficient? Don't hesitate to fill up a new feature request! We really appreciate all feedback.

Reporting bugs

If you have found a bug, inconsistent or confusing behavior please fill up a new bug report.

Contributing

You can contribute to this project by giving us feedback (reporting bugs and requesting features) and also by writing code yourself!

The easiest way is to create a fork of this repository and then create a pull request with all your changes. In most cases, you should branch from and target main branch.

Please refer to Development Setup section on how to setup this project.

Development Setup

1. Clone this repo:

[email protected]:scramjetorg/framework-cpp.git

2. List presets available on your OS:

cmake --list-presets=all .

It will result with a similar list:

Available configure presets:

"linux-debug" - Linux Debug
"linux-test-coverage" - Linux Test Coverage
"linux-release" - Linux Release

3. Build make according to specific preset:

cmake --preset linux-debug

4. Build project using make file from previous step:

cd out/build/linux-debug/
cmake --build .

5. Run tests (only debug presets)

./tests/IFCA_tests

Was it helpful?

Didn't find information needed?

Join our Scramjet Community on Discord, where you can get help from our engineers directly.