324template <
typename Gobj = GameObject>
334 explicit Path(std::string pathString)
337 switch (pathString[0])
342 pathString = pathString.substr(1);
348 pathString = pathString.substr(1);
353 path = std::make_shared<PathRoot>();
359 assert(
false &&
"Cannot create a path that starts with . without passing a gameObject as base");
384 assert(pathString[0] ==
'.');
385 path = std::make_shared<PathBase>(rootObject);
388 pathString = pathString.substr(1);
413 operator const Gobj&()
426 std::shared_ptr<PathNode>
path;
463 auto result =
dynamic_cast<Gobj*
>(
itr.get());
466 throw PathException(
"Path iterator called get() on GameObject that isn't same type as iterator");
502 return itr == other.itr;
510 auto operator*() const -> std::add_lvalue_reference_t<Gobj>
512 auto result =
dynamic_cast<Gobj*
>(
itr.get());
515 throw PathException(
"Path iterator dereferenced GameObject that isn't same type as iterator");
536 static_assert(std::input_iterator<iterator>);
537 static_assert(std::sentinel_for<iterator, iterator>);
567 return begin().get();
587 static auto splitString(
const std::string& fullString,
const std::string& delimiter) -> std::vector<std::string>
590 auto end = delimiter.length();
591 auto delimiterLength = delimiter.length();
593 std::vector<std::string>
result;
595 while ((
end = fullString.find(delimiter, start)) != std::string::npos)
597 token = fullString.substr(start,
end - start);
598 start =
end + delimiterLength;
602 result.push_back(fullString.substr(start));
613 std::string dir =
"/";
617 for (
auto itr = nodes.begin(); itr != nodes.end(); ++itr)
620 if (itr != nodes.begin() && *itr !=
"..")
622 path->appendPathNode(std::make_shared<PathDir>());
627 path->appendPathNode(std::make_shared<PathUp>());
635 path->appendPathNode(std::make_shared<PathName>(*itr));
641 if (nodes.back().empty())
643 if (std::is_same_v<Gobj, Component>)
645 path->appendPathNode(std::make_shared<PathFilter>(
652 else if (std::is_same_v<Gobj, Entity>)
654 path->appendPathNode(std::make_shared<PathFilter>(
661 else if (!std::is_same_v<Gobj, GameObject> && !std::is_same_v<Gobj, System>)
663 path->appendPathNode(std::make_shared<PathFilter>(
666 return !!(
dynamic_cast<const Gobj*
>(&g));
static FMOD_RESULT result
Definition AudioObject.cpp:27
The class that holds the top node, and manages the main game loop, as well as startup and shutdown.
the base class for the engine, most things inherit from this.
One of the beginnings of a Path, where the Path starts at an arbitrary GameObject.
Given a range of GameObjects, generates a range of all of those GameObjects children.
excption emittited by Path s and their associated classes
Internal PathNode that takes a range of GameObjects on the left, and filters the range to only GameOb...
Internal PathNode that takes a range of GameObjects on the left, and filters the range to only GameOb...
Base class for a linked list of Path sections, which altogether represent the logic of a Path,...
Path Node that represents the Root object in the Engine, and provides a starting point for a Path.
Internal Path Node that takes a range of GameObjects on the left, and transforms the range into the p...
static auto getSystem() -> system *
A function to get a system.
Definition Engine.h:43
the base class for the engine, most things inherit from this.
Definition GameObject.h:77
auto isType(gobj::Type otherType) const -> bool
check whether the GameObject is the same as a given type.
Definition GameObject.cpp:260
Definition PathException.h:24
iterator type, refers to a GameObject, and holds onto a reference to a PathNode to determine its rang...
Definition PathNode.h:45
iterator member class for Path.
Definition Path.h:434
PathNode::path_iterator itr
Internal iterator type that is used by PathNode, and only refers to GameObjects as GameObjects.
Definition Path.h:531
auto operator*() const -> std::add_lvalue_reference_t< Gobj >
Gets a reference to the GameObject the iterator refers to, and casts it to Gobj as well.
Definition Path.h:510
iterator(PathNode::path_iterator itr)
constructs a Path::iterator from a PathNode::path_iterator, which is an internal type used for logic
Definition Path.h:440
auto get() const -> Gobj *
Definition Path.h:461
iterator()=default
defaults initializes iterator as a sentinel "Past the End" iterator
friend Path
Definition Path.h:446
auto operator++(int) -> iterator
post-increments the iterator, getting the next GameObject in the range
Definition Path.h:488
Gobj value_type
Definition Path.h:450
auto operator==(iterator other) const -> bool
compares if two iterators point to the same object.
Definition Path.h:500
std::ptrdiff_t difference_type
Definition Path.h:449
auto operator->() const -> Gobj *
allows for calling functions on the objects an iterator refers to.
Definition Path.h:524
auto operator++() -> iterator &
pre-increments the iterator, getting the next GameObject in the range.
Definition Path.h:477
Path(std::string pathString)
constructs a Path by parsing a string
Definition Path.h:334
auto begin() const -> iterator
Definition Path.h:545
auto end() const -> iterator
Definition Path.h:555
std::shared_ptr< PathNode > path
a pointer to the linked list of PathNodes that handles the logic for Path deduction
Definition Path.h:426
auto parsePath(const std::string &pathString) -> void
parses a Path, constructing the linked list of PathNodes, which calculate the range that a Path refer...
Definition Path.h:610
static auto splitString(const std::string &fullString, const std::string &delimiter) -> std::vector< std::string >
splits a string into many smaller strings.
Definition Path.h:587
Path(std::string pathString, GameObject &rootObject)
constructs a Path by parsing a string
Definition Path.h:382
auto operator->() const -> Gobj *
Definition Path.h:574
auto get() const -> Gobj *
Definition Path.h:565
namespace for things relating to GameObject, other than GameObject itself
Definition Entity.h:229
@ Entity
Definition GameObject.h:53
@ Component
Definition GameObject.h:54
Path Node that represents the Root object in the Engine, and provides a starting point for a Path.
Definition PathRoot.h:28