CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
AnyPath.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "AnyGenerator.hpp"
11#include "Edge.hpp"
12#include "PathVertex.hpp"
13
15
17
19 class AnyPath {
20 public:
21 template<typename Path> AnyPath(Path path) : mBase{new Derived<Path>{std::move(path)}} {}
22
25
26 AnyPath(AnyPath&&) = default;
27 AnyPath& operator=(AnyPath&&) = default;
28
31
32 private:
34 public:
35 virtual ~Base();
36 [[nodiscard]] virtual UPtr<Base> clone() const = 0;
37 [[nodiscard]] virtual AnyGenerator<Edge> edges() const = 0;
39 };
40
41 template<typename Path> class Derived : public Base {
42 public:
43 Derived(Path path) : mPath(std::move(path)) {}
44
45 [[nodiscard]] virtual UPtr<Base> clone() const override { return UPtr<Base>{new Derived{mPath}}; }
46 [[nodiscard]] virtual AnyGenerator<Edge> edges() const override { return mPath.edges(); }
47 [[nodiscard]] virtual AnyGenerator<PathVertex> vertices() const override { return mPath.vertices(); }
48
49 Path mPath;
50 };
51
53 };
54
55} // namespace CeresEngine::MeshGenerator
A type erasing container that can store any generator that generates type T.
Definition AnyGenerator.hpp:16
virtual UPtr< Base > clone() const =0
virtual AnyGenerator< PathVertex > vertices() const =0
virtual AnyGenerator< Edge > edges() const =0
virtual UPtr< Base > clone() const override
Definition AnyPath.hpp:45
Path mPath
Definition AnyPath.hpp:49
virtual AnyGenerator< Edge > edges() const override
Definition AnyPath.hpp:46
virtual AnyGenerator< PathVertex > vertices() const override
Definition AnyPath.hpp:47
Derived(Path path)
Definition AnyPath.hpp:43
A type erasing container that can store any path.
Definition AnyPath.hpp:19
AnyPath & operator=(AnyPath &&)=default
UPtr< Base > mBase
Definition AnyPath.hpp:52
AnyPath & operator=(const AnyPath &that)
AnyPath(Path path)
Definition AnyPath.hpp:21
AnyGenerator< Edge > edges() const noexcept
Definition PathVertex.hpp:14
Definition AnyGenerator.hpp:12
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668