0% found this document useful (0 votes)
42 views12 pages

Meetingcpp Jelkins

Antons Jel̦kins presents Bosce, a tool for visualizing boost::statechart state machines. Bosce extracts information about statecharts from a binary and generates diagrams like UML. This helps understand complex state machines by providing an overview rather than reading verbose C++ code. The example shows running Bosce on a demo program, listing available state machines, extracting one to a PlantUML file, and opening the generated image file. Bosce addresses common problems of modifying, reviewing or debugging state machines by visualizing their structure and transitions.

Uploaded by

number246
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views12 pages

Meetingcpp Jelkins

Antons Jel̦kins presents Bosce, a tool for visualizing boost::statechart state machines. Bosce extracts information about statecharts from a binary and generates diagrams like UML. This helps understand complex state machines by providing an overview rather than reading verbose C++ code. The example shows running Bosce on a demo program, listing available state machines, extracting one to a PlantUML file, and opening the generated image file. Bosce addresses common problems of modifying, reviewing or debugging state machines by visualizing their structure and transitions.

Uploaded by

number246
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

boost::statechart visualisation

Antons Jel̦kins

Meeting C++ 2019

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 1/7


About me

Hello!
My name is Anton.
I work at BMW.
I do software which runs in cars.
I mostly code in C++.
antons.jelkins@bmw.de

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 2/7


What is boost::statechart?

‘The Boost Statechart library is a framework that allows you to quickly


transform a UML statechart into executable C++ code.’
https://www.boost.org/doc/libs/1_71_0/libs/statechart/doc/tutorial.html

Example
struct StopWatch : sc::state_machine< StopWatch, Active > {};
struct EvStartStop : sc::event< EvStartStop > {};

struct Active : sc::simple_state< Active, StopWatch, Stopped > {


using reactions = mpl::list<
sc::transition< EvReset, Active >,
sc::custom_reaction< EvPlayMusic >,
sc::deferral< EvTerminate > >;

sc::result react(const EvPlayMusic &ev);


};

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 3/7


Problem statement

Let’s have a look at these common use cases:


New feature. State machine must be modi ied.
Code review. Someone modi ied a state machine.
Bug analysis. State machine misbehave.
Learning. You are new to the code base.

These tasks require you to have an overview of the state machines.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 4/7


Problem statement

Let’s have a look at these common use cases:


New feature. State machine must be modi ied.
Code review. Someone modi ied a state machine.
Bug analysis. State machine misbehave.
Learning. You are new to the code base.

These tasks require you to have an overview of the state machines.

It is relatively hard to get an overview of boost::statecharts by just


looking at C++ code:
No explicit transition table.
Notation is quite verbose.
Implementation can span multiple iles.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 4/7


Solution
What to do?

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 5/7


Solution
What to do? Look at a picture instead of C++ code!

How to get a picture?

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 5/7


Solution
What to do? Look at a picture instead of C++ code!

How to get a picture?

Bosce, or boost::statechart extractor, is a command line tool to extract


information about boost::statecharts from an arbitrary binary with
debug symbols and transform it to a user-friendly form, e.g. UML
diagrams.
https://github.com/kanje/bosce

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 5/7


Solution
What to do? Look at a picture instead of C++ code!

How to get a picture?

Bosce, or boost::statechart extractor, is a command line tool to extract


information about boost::statecharts from an arbitrary binary with
debug symbols and transform it to a user-friendly form, e.g. UML
diagrams.
https://github.com/kanje/bosce

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 5/7


Example

Shell
$ g++ demo.cpp -o demo
$ bosce demo -l
Available state-machines:
StopWatch

$ bosce demo -s StopWatch > uml.pu


$ plantuml uml.pu
$ xdg-open uml.png

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 6/7


Example

Shell
$ g++ demo.cpp -o demo
$ bosce demo -l
Available state-machines:
StopWatch

$ bosce demo -s StopWatch > uml.pu


$ plantuml uml.pu
$ xdg-open uml.png

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 6/7


Thank you!

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Antons Jel̦kins boost::statechart visualisation Meeting C++ 2019 7/7

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy