Visitable Adapters - GerdHirsch/Cpp-VisitorFrameworkCyclicAcyclic GitHub Wiki
Types that don't inherit from your Repository::VisitableImpl<..>, like
NonVisitable,
can be adapted by an Adapter.
There are three kinds of Adapters predefined in the
Repository
for convenience, but you can also specify your own
StoragePolicy.
But the most suitable way is to use a Factory.
#include "NonVisitable.h"
#include "MyRepository.h"
// example for userdefined StoragePolicy
template<class Adaptee> 
using MyAdapter = 
    Repository::VisitableAdapter<Adaptee, VisitorFramework::StorageByWeakpointer<Adaptee>>;
// example for convenience Adapters
template<class Adaptee>
using AdapterWeak = Repository::AdapterByWeakpointer<Adaptee>;
template<class Adaptee>
using AdapterReference = Repository::AdapterByReference<Adaptee>;
...
NonVisitable nv;
auto pNV = std::make_shared<NonVisitable>();
...
visitables.push_back(Visitable(new AdapterReference<NonVisitable>(nv)));
visitables.push_back(Visitable(new AdapterWeak<NonVisitable>(pNV)));
...
demoRunVisitor(visitor, visitables);
see also: Application,
demoSwitchCyclicAcyclic.cpp
and
demoRunVisitors