OSFEG-C++  1.4.6
OpenSF Error Generation Library
Composite Class Reference

#include <Composite.h>

Inheritance diagram for Composite:
Analytical Stochastic BinaryOperations Harmonic Polynomial Sampled Step

Public Member Functions

 Composite ()
 
 Composite (const Composite &)=delete
 
Compositeoperator= (const Composite &)=delete
 
 Composite (Composite &&)=default
 
Compositeoperator= (Composite &&)=default
 
virtual ~Composite ()
 
void add (Composite *node)
 
void remove (Composite *node)
 
CompositegetChild (int index)
 
bool hasChildNodes () const
 
virtual double getValue (double time)
 

Protected Attributes

std::vector< Composite * > children
 
Compositeparent
 

Detailed Description

Class Composite represents a node in the perturbations tree. Each node may have any number of children nodes, forming a directed acyclic graph (DAG).

Constructor & Destructor Documentation

◆ Composite() [1/3]

Composite::Composite ( )

Default class constructor, creates a node with no children and no parent.

◆ Composite() [2/3]

Composite::Composite ( const Composite )
delete

Disallow copying but allow moving

◆ Composite() [3/3]

Composite::Composite ( Composite &&  )
default

Disallow copying but allow moving

◆ ~Composite()

virtual Composite::~Composite ( )
virtual

Cleans up resources owned by this object, including its owned children nodes.

Member Function Documentation

◆ add()

void Composite::add ( Composite node)

Adds a new node to this Composite children vector. The node must not already be the child of another node (see remove()), and the current node takes ownership of the given child.

Parameters
nodePointer to the node

◆ getChild()

Composite* Composite::getChild ( int  index)

Returns the child pointed by index

Parameters
indexIndex of the desired child
Returns
Composite Pointer of the child

◆ getValue()

virtual double Composite::getValue ( double  time)
virtual

Returns the scalar value of this node at the given time. Implementations may check the number of children nodes and the value of some or all of them, either at the same or at a different time, for the evaluation of this function. If the number or value of those children are considered invalid for any reason, this function may throw.

The default implementation ignores all children nodes and simply returns zero.

Parameters
timeTime reference of the perturbation
Returns
Scalar real number representing the perturbation

Reimplemented in Stochastic, Step, Sampled, Polynomial, Harmonic, BinaryOperations, and Analytical.

◆ hasChildNodes()

bool Composite::hasChildNodes ( ) const

Checks whether the Composite object has children.

Returns
bool True if the object has children False in other case.

◆ operator=() [1/2]

Composite& Composite::operator= ( Composite &&  )
default

Disallow copying but allow moving

◆ operator=() [2/2]

Composite& Composite::operator= ( const Composite )
delete

Disallow copying but allow moving

◆ remove()

void Composite::remove ( Composite node)

Removes a node from the Composite children vector. The chosen child is left parentless, and is no longer owned by this node - the caller is now responsible of deleting the child (or assigning it to another parent, see add()).

Parameters
nodePointer to the node

Member Data Documentation

◆ children

std::vector<Composite *> Composite::children
protected

Children nodes of this composite. A node owns its children, and so they are destroyed when their parent is.

◆ parent

Composite* Composite::parent
protected

Pointer to the parent node, may be null.


The documentation for this class was generated from the following file: