Added visitor pattern test case

This commit is contained in:
Bartek Kryza
2021-07-25 11:26:12 +02:00
parent b06335f2f8
commit 11d56768db
32 changed files with 359 additions and 64 deletions

View File

@@ -17,6 +17,36 @@ diagrams:
```
## Source code
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';
}
}
}
}
```
File t00018_impl.h
```cpp
#pragma once
@@ -101,36 +131,6 @@ 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")