|
Brunot
|
An object that represents where a GameObject or a range of GameObjects exists in the Engine. More...
#include <Path.h>
Classes | |
| class | iterator |
| iterator member class for Path. More... | |
Public Member Functions | |
| Path (std::string pathString) | |
| constructs a Path by parsing a string | |
| Path (std::string pathString, GameObject &rootObject) | |
| constructs a Path by parsing a string | |
| operator Gobj & () | |
| implicitly converts a path to a reference to the GameObject it refers to | |
| operator Gobj * () | |
| implicitly converts a path to a pointer to the Gobj it refers to | |
| operator const Gobj & () | |
| implicitly converts a path to a const reference to the GameObject it refers to | |
| auto | begin () const -> iterator |
| auto | end () const -> iterator |
| auto | get () const -> Gobj * |
| auto | operator-> () const -> Gobj * |
Private Member Functions | |
| auto | parsePath (const std::string &pathString) -> void |
| parses a Path, constructing the linked list of PathNodes, which calculate the range that a Path refers to | |
Static Private Member Functions | |
| static auto | splitString (const std::string &fullString, const std::string &delimiter) -> std::vector< std::string > |
| splits a string into many smaller strings. | |
Private Attributes | |
| std::shared_ptr< PathNode > | path |
| a pointer to the linked list of PathNodes that handles the logic for Path deduction | |
An object that represents where a GameObject or a range of GameObjects exists in the Engine.
Paths can refer to one or many GameObjects. The path will directly convert into a reference to the GameObject it represents, or the first GameObject in its range, if that the Path refers to multiple GameObjects. Access to multiple GameObjects is done via begin() and end() iterators, referring to the first GameObject in the range, and a "past the end" iterator pointing to NULL, respectively. In the case where the Path refers to a single GameObject, then the range will be of length one. The path name has the following syntax:
One or zero of the following:
The Path may represent a non-existing path.
| Gobj | The type of GameObject you are searching for. Automatically casts to the proper type, and filters out other types at the end. Defaults to GameObject, with no casts or filters |
A Path behaves much like a file path. A "full path" will start at the Root of the engine, and refer to GameObjects by Name or Nickname. See Path s description for a full explanation and breakdown
This Path get's the System SceneManager. the leading / indicates to start at the Root, and get it's children (remember, Root's children are all the Systems in the Engine)
Outputs:
Here's a reminder of the structure of the Engine for the example. Remember, formatted names (when printed to the Log) are in the form TypeName::Nickname::UUID This example doesn't include every System, Entity, or Component in the Engine or Scene loaded right now, but it lists the things we grab here in this example
find a different system, but use the template parameter to get it as a specific System, which lets us to call non-virtual member functions
Outputs:
We don't have to start from Root however, we can start at the scene root too
Output:
Using ~ is the same as getting the root Scene
Output:
A very common usage for paths is getting components here, background refers to the Entities nickname, and Background refers to the Background Component
Output:
Just like with systems, if we use Path's template parameter, we can get our GameObject as the class it actually is, and call member functions on it
Output:
Paths can also start at arbitrary locations, just start with a . and pass in a GameObject to start from. Pass in *this to start from yourself
Output:
Paths can also go "Up" to get somethings parent: The first .. gets the player Entity, and the second .. gets the board Entity. From there, the / get's the Entities Children, and Board selects the Board Component from among those children
Output:
Path can also get a range of objects instead of just one, if you end in a /
Output:
Careful though, getting all of a Entities children gets both it's child Components, and child Entities.
Output:
Wow, Aidan that's annoying! Is there any way that I can get Just the Components, or just the Entities?
Why yes, yes there is! If you set the template to a type, it will automatically filter the final range to only GameObjects of that type!
Here it is with Components
Output:
Here it is with Entities
Output:
If a path can't find an GameObject, or you give it GameObjects of the wrong type, It will throw an exception. You can catch the exception, but be careful, it's this means you won't get notified of when the exception happens, unless you check the log. So if you want to catch the exception, I recommend asserting afterwards. Otherwise, if you don't catch the exception, the Debugger should break on it's own when an exception happens.
|
inlineexplicit |
constructs a Path by parsing a string
| Gobj | The type of GameObject you are searching for. Automatically casts to the proper type, and filters out other types at the end. Defaults to GameObject, with no casts or filters |
| pathString | a string to construct the path from |
|
inline |
constructs a Path by parsing a string
| Gobj | The type of GameObject you are searching for. Automatically casts to the proper type, and filters out other types at the end. Defaults to GameObject, with no casts or filters |
| pathString | a string to construct the path from. The string should start with a dot . |
| rootObject | a reference to the object to start the Path from |
|
inline |
| PathException | If the path is invalid, and can't find anything (usually throws, but not always) |
|
inline |
|
inline |
|
inline |
implicitly converts a path to a const reference to the GameObject it refers to
|
inline |
implicitly converts a path to a reference to the GameObject it refers to
|
inline |
implicitly converts a path to a pointer to the Gobj it refers to
|
inline |
|
inlineprivate |
|
inlinestaticprivate |
splits a string into many smaller strings.
Used to split path into individual section when parsing
| fullString | string with delimiters in it |
| delimiter | sequence of characters to divide fullString by |
|
private |
a pointer to the linked list of PathNodes that handles the logic for Path deduction