Added missing test case docs

This commit is contained in:
Bartek Kryza
2021-07-24 20:57:20 +02:00
parent 69f7c88114
commit b99a82554a
3 changed files with 137 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
![linux build](https://github.com/bkryza/clang-uml/actions/workflows/build.yml/badge.svg) ![linux build](https://github.com/bkryza/clang-uml/actions/workflows/build.yml/badge.svg)
`clang-uml` is an automatic !(PlantUML)[https://plantuml.com/] class and sequence `clang-uml` is an automatic ![PlantUML](https://plantuml.com/) class and sequence
diagram generator, driven by YAML configuration files. The main idea behind the diagram generator, driven by YAML configuration files. The main idea behind the
project is to easily maintain up-to-date diagrams within a code-base or document project is to easily maintain up-to-date diagrams within a code-base or document
existing project code. The configuration file or files for `clang-uml` define the existing project code. The configuration file or files for `clang-uml` define the

136
docs/test_cases/t00018.md Normal file
View File

@@ -0,0 +1,136 @@
# t00018 - Pimpl pattern
## Config
```yaml
compilation_database_dir: ..
output_directory: puml
diagrams:
t00018_class:
type: class
glob:
- ../../tests/t00018/**.h
- ../../tests/t00018/**.cc
using_namespace:
- clanguml::t00018
include:
namespaces:
- clanguml::t00018
```
## Source code
File t00018_impl.h
```cpp
#pragma once
#include "t00018.h"
namespace clanguml {
namespace t00018 {
namespace impl {
class widget {
int n;
public:
void draw(const clanguml::t00018::widget &w) const;
void draw(const clanguml::t00018::widget &w);
widget(int n);
};
}
}
}
```
File t00018.h
```cpp
#pragma once
#include <experimental/propagate_const>
#include <iostream>
#include <memory>
namespace clanguml {
namespace t00018 {
namespace impl {
class widget;
}
// Pimpl example based on https://en.cppreference.com/w/cpp/language/pimpl
class widget {
std::unique_ptr<impl::widget> pImpl;
public:
void draw() const;
void draw();
bool shown() const { return true; }
widget(int);
~widget();
widget(widget &&);
widget(const widget &) = delete;
widget &operator=(widget &&);
widget &operator=(const widget &) = delete;
};
}
}
```
File t00018.cc
```cpp
#include "t00018.h"
#include "t00018_impl.h"
namespace clanguml {
namespace t00018 {
void widget::draw() const { pImpl->draw(*this); }
void widget::draw() { pImpl->draw(*this); }
widget::widget(int n)
: pImpl{std::make_unique<impl::widget>(n)}
{
}
widget::widget(widget &&) = default;
widget::~widget() = default;
widget &widget::operator=(widget &&) = default;
}
}
```
File t00018_impl.cc
```cpp
#include "t00018_impl.h"
#include "t00018.h"
namespace clanguml {
namespace t00018 {
namespace impl {
widget::widget(int n)
: n(n)
{
}
void widget::draw(const clanguml::t00018::widget &w) const
{
if (w.shown())
std::cout << "drawing a const widget " << n << '\n';
}
void widget::draw(const clanguml::t00018::widget &w)
{
if (w.shown())
std::cout << "drawing a non-const widget " << n << '\n';
}
}
}
}
```
## Generated UML diagrams
![t00018_class](./t00018_class.png "Pimpl pattern")

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB