Lightgraph
C++17 light-graph engine API reference
Loading...
Searching...
No Matches
object_factory.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5
8
10
14 Line,
15 Cross,
17};
18
19} // namespace lightgraph::integration
20
22
23inline constexpr uint16_t defaultPixelCount(integration::BuiltinObjectType type) {
24 switch (type) {
26 return HEPTAGON919_PIXEL_COUNT;
28 return HEPTAGON3024_PIXEL_COUNT;
30 return LINE_PIXEL_COUNT;
32 return CROSS_PIXEL_COUNT;
34 return TRIANGLE_PIXEL_COUNT;
35 }
36
37 return LINE_PIXEL_COUNT;
38}
39
56
57inline constexpr uint16_t resolvePixelCount(integration::BuiltinObjectType type, uint16_t pixelCount) {
58 return pixelCount > 0 ? pixelCount : defaultPixelCount(type);
59}
60
61inline std::unique_ptr<TopologyObject> makeBuiltinObject(integration::BuiltinObjectType type,
62 uint16_t pixelCount = 0) {
63 const uint16_t resolvedPixelCount = resolvePixelCount(type, pixelCount);
64 switch (type) {
66 return std::unique_ptr<TopologyObject>(new Heptagon919());
68 return std::unique_ptr<TopologyObject>(new Heptagon3024());
70 return std::unique_ptr<TopologyObject>(new Line(resolvedPixelCount));
72 return std::unique_ptr<TopologyObject>(new Cross(resolvedPixelCount));
74 return std::unique_ptr<TopologyObject>(new Triangle(resolvedPixelCount));
75 }
76
77 return std::unique_ptr<TopologyObject>(new Line(resolvedPixelCount));
78}
79
80inline std::unique_ptr<TopologyObject> makeBuiltinObject(ObjectType type, uint16_t pixelCount = 0) {
81 return makeBuiltinObject(toBuiltinObjectType(type), pixelCount);
82}
83
84} // namespace lightgraph::internal
::Heptagon3024 Heptagon3024
Definition objects.hpp:16
::Heptagon919 Heptagon919
Definition objects.hpp:15
constexpr integration::BuiltinObjectType toBuiltinObjectType(ObjectType type)
constexpr uint16_t resolvePixelCount(integration::BuiltinObjectType type, uint16_t pixelCount)
constexpr uint16_t defaultPixelCount(integration::BuiltinObjectType type)
std::unique_ptr< TopologyObject > makeBuiltinObject(integration::BuiltinObjectType type, uint16_t pixelCount=0)
ObjectType
Built-in object topologies supported by the high-level engine API.
Definition types.hpp:25
Public value types and commands for the stable Lightgraph API.