Repository Implementation - GerdHirsch/Cpp-VisitorFrameworkCyclicAcyclic GitHub Wiki

In the following, there is a brief overview of the Cyclic::Repository. The Acyclic::Repository is similar regarding the types and names defined in these templates.

Visitors

Visitor is the base class of all Visitors of a instantiated Repository. It delegates its usage to Cyclic::SwitchBaseKind<..>::template implementsVisitor<Visitables...>. A more detailed discussion can be found in Cyclic VisitorBase.

VisitorBase is the type to inherit from, if you want your Visitors to visit all Visitables in the list class ...Visitables.

visits<..> is the type to inherit from for acyclic Visitors, if you want your visitors to visit only the Visitables in the list class ...ToVisit.

The syntax MyVisitor : Repository::visits<typelist> for cyclic visitors just disposes the list and delegates to Visitor as it can be seen below. A more detailed description can be found in Typelist.

namespace Cyclic{
template<class LoggingPolicy, class BaseKind_, class ...Visitables>
struct Repository{
//=================================================================
// Visitors
//=================================================================
    using Visitor = 
        typename Cyclic::SwitchBaseKind<LoggingPolicy, BaseKind_>
            ::template implementsVisitor<Visitables...>;
    using VisitorBase = Visitor;
    /**
     * Interface compatibility with Acyclic Repository
     */
    template<class ...ToVisit>
    struct visits : VisitorBase{};

    template<class ...ToVisit>
    struct visits<VisitorFramework::Typelist<ToVisit...>>
    // delegates to primary DRY Principle
    : visits<ToVisit...>{};

Visitables

The Visitable delegates to Cyclic::Visitable<VisitorBase> see Visitor & Visitable. It can be used to define Pointers or Smartpointers to Visitables: std::shared_ptr<Repository::Visitable>.

The VisitableImpl<..>delegates to Cyclic::VisitableImpl<..>. A more detailed discussion can be found in VisitableImpl. It provides the infrastructure for the visitor pattern i.e. the implementation for the method accept(VisitorBase&).

//=================================================================
// Visitables
//=================================================================
    using Visitable = Cyclic::Visitable<VisitorBase>;

    template<class ConcreteVisitable>
    using VisitableImpl = 
        Cyclic::VisitableImpl<ConcreteVisitable, VisitorBase, LoggingPolicy>;

Adapters

The VisitableAdapter creates an Adapter for NonVisitable types. It is parameterized by the type to be adapted and a StoragePolicy to be used to store the Adaptee. For convenience, adapters with predefined storage policies are defined. A more detailed discussion can be found in Adpater Implementation.

//=================================================================
// VisitableAdapters
//=================================================================
    template<class Adaptee, class StoragePolicy>
    using VisitableAdapter = 
        Cyclic::VisitableAdapter<Adaptee, StoragePolicy, LoggingPolicy, VisitorBase>;

    // Convenience Interfaces
    template<class Adaptee>
    using AdapterByWeakpointer = VisitableAdapter<Adaptee, StorageByWeakpointer<Adaptee>>;

    template<class Adaptee>
    using AdapterByReference = VisitableAdapter<Adaptee, StorageByReference<Adaptee>>;
};
} // end namespace
⚠️ **GitHub.com Fallback** ⚠️