This is a library created to simplify communication between components inside of single application. It is thread safe and could be used for creating components that works in different threads.
To integrate this library in your project you just need in CMake add: add_subdirectory(<path_to_library>)
Here is simple example of WeatherStationService
and DisplayService
that works in different threads:
#include <icc/Component.hpp>
class WeatherStationService : public icc::Component {
public:
icc::Event<void(const double &)> temperature_;
private:
void handleTemperature() {
...
temperature_(28.3);
...
}
};
class DisplayService : public icc::Component {
public:
explicit DisplayService(WeatherStationService& station) {
station.temperature_.connect(&DisplayService::onTemperature, this);
}
void onTemperature(const double & _temperature) {
std::cout << "DisplayService::Temperature is " << _temperature << std::endl;
}
};
int main() {
auto observer = std::make_shared<WeatherObserver>();
auto station = std::make_shared<WeatherStation>(*observer);
auto observerThread = std::thread([&observer] {
observer->exec();
});
auto stationThread = std::thread([&station] {
station->exec();
});
observerThread.join();
stationThread.join();
}
Documentation will be updated in: Tutorial
-
Some compilers that supports C++17 at the same time does not support Feature Macros __cpp_lib_optional If you want to use automatic conversion from icc::_private::containers::Optional to C++17 std::optional you should set this macros by hand like this:
add_definitions(-D__cpp_lib_optional=201606)
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT License