This class represents grouping nodes in a hiearchy. More...
#include <FgGPNode.h>
Public Member Functions | |
GPNode () | |
Default constructor. More... | |
virtual | ~GPNode () |
Destructor. More... | |
int | GetNumChildren () const |
Gets the number of children of this item. More... | |
int | AttachChild (std::shared_ptr< GPNode< Scalar > > const &child) |
Attaches a child. More... | |
int | DetachChild (std::shared_ptr< GPNode< Scalar > > const &child) |
Detaches a child. More... | |
std::shared_ptr< GPNode< Scalar > > | DetachChildAt (int i) |
Detaches a child at index. More... | |
void | DetachAllChildren () |
Detach all children from this node. More... | |
std::shared_ptr< GPNode< Scalar > > | SetChild (int i, std::shared_ptr< GPNode< Scalar > > const &child) |
Sets a child. More... | |
std::shared_ptr< GPNode< Scalar > > | GetChild (int i) |
Gets a child at index. More... | |
GPNode< Scalar > * | GetParent () |
Access to the parent object, which is null for the root of the hierarchy. More... | |
void | SetParent (GPNode< Scalar > *parent) |
Access to the parent object. Node calls this during attach/detach of children. More... | |
Protected Attributes | |
std::vector< std::shared_ptr< GPNode< Scalar > > > | mChild |
GPNode< Scalar > * | mParent |
Private Member Functions | |
template<class Archive > | |
void | serialize (Archive &ar, unsigned int version) |
Friends | |
class | boost::serialization::access |
class | GPModels::AEP::SDGPLVM< Scalar > |
class | GPModels::AEP::SGPLVM< Scalar > |
This class represents grouping nodes in a hiearchy.
, 19.07.2018.
Definition at line 41 of file FgGPNode.h.
NeuralEngine::MachineLearning::GPNode< Scalar >::GPNode | ( | ) |
Default constructor.
Hmetal T, 03/04/2020.
|
virtual |
Destructor.
Hmetal T, 04/04/2020.
int NeuralEngine::MachineLearning::GPNode< Scalar >::GetNumChildren | ( | ) | const |
Gets the number of children of this item.
This is the current number of elements in the child array. These elements are not all guaranteed to be non-null. Thus, when you
iterate over the array and access children with GetChild(...), you should verify the child pointer is not null before dereferencing it.
, 19.07.2018.
int NeuralEngine::MachineLearning::GPNode< Scalar >::AttachChild | ( | std::shared_ptr< GPNode< Scalar > > const & | child | ) |
Attaches a child.
Attach a child to this node. If the function succeeds, the return value is the index i of the array where the child was stored, in which case 0 <= i < GetNumChildren(). The first available empty slot of the child array is used for storage. If all slots are filled, the child is appended to the array (potentially causing a reallocation of the array).
The function fails when 'child' is null or when 'child' already has a parent, in which case the return value is -1. The nodes form a tree, not a more general directed acyclic graph. A consequence is that a node cannot have more than one parent. For example, Node* node0 = <some node>; Spatial* child = <some child> int index = node0->AttachChild(child); Node* node1 = <some node>
// This asserts because 'child' already has a parent (node0). node1->AttachChild(child);
// The following is the correct way to give 'child' a new parent. node0->DetachChild(child); // or node0->DetachChildAt(index); node1->AttachChild(child);
// In the last example before the DetachChild call, if 'child' is // referenced only by node0, the detach will cause 'child' to be // deleted (Node internally reference counts its children). If // you want to keep 'child' around for later use, do the following. Spatial::SP saveChild = SPCreate(node0->GetChild(0)); node0->DetachChild(saveChild); node1->AttachChild(saveChild);
, 19.07.2018.
child | The child. |
int NeuralEngine::MachineLearning::GPNode< Scalar >::DetachChild | ( | std::shared_ptr< GPNode< Scalar > > const & | child | ) |
Detaches a child.
Detach a child from this node. If the 'child' is non-null and in the array, the return value is the index in the array that had stored the child. Otherwise, the function returns -1.
, 19.07.2018.
child | The child. |
std::shared_ptr< GPNode< Scalar > > NeuralEngine::MachineLearning::GPNode< Scalar >::DetachChildAt | ( | int | i | ) |
Detaches a child at index.
Detach a child from this node. If 0 <= i < GetNumChildren(), the return value is the child at index i; otherwise, the function returns null.
, 19.07.2018.
i | Zero-based index of the child. |
void NeuralEngine::MachineLearning::GPNode< Scalar >::DetachAllChildren | ( | ) |
Detach all children from this node.
, 19.07.2018.
std::shared_ptr< GPNode< Scalar > > NeuralEngine::MachineLearning::GPNode< Scalar >::SetChild | ( | int | i, |
std::shared_ptr< GPNode< Scalar > > const & | child | ||
) |
Sets a child.
The same comments for AttachChild apply here regarding the inability to have multiple parents. If 0 <= i < GetNumChildren(), the function succeeds and returns i. If i is out of range, the function still succeeds, appending the child to the end of the array. The return value is the previous child stored at index i.
, 19.07.2018.
i | Zero-based index of the. |
child | The child. |
std::shared_ptr< GPNode< Scalar > > NeuralEngine::MachineLearning::GPNode< Scalar >::GetChild | ( | int | i | ) |
Gets a child at index.
Get the child at the specified index. If 0 <= i < GetNumChildren(), the function succeeds and returns the child at that index. Keep in mind that child[i] could very well be null. If i is out of range, the function returns null.
, 19.07.2018.
i | Zero-based index of the. |
GPNode< Scalar > * NeuralEngine::MachineLearning::GPNode< Scalar >::GetParent | ( | ) |
Access to the parent object, which is null for the root of the hierarchy.
Hmetal T, 10.08.2016.
void NeuralEngine::MachineLearning::GPNode< Scalar >::SetParent | ( | GPNode< Scalar > * | parent | ) |
Access to the parent object. Node calls this during attach/detach of children.
Hmetal T, 04/04/2020.
parent | [in,out] If non-null, the parent. |
|
inlineprivate |
Definition at line 233 of file FgGPNode.h.
|
friend |
Definition at line 228 of file FgGPNode.h.
|
friend |
Definition at line 228 of file FgGPNode.h.
|
friend |
Definition at line 228 of file FgGPNode.h.
|
protected |
Definition at line 225 of file FgGPNode.h.
|
protected |
Definition at line 226 of file FgGPNode.h.