Leonardus
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SOA Class Reference

Semantic Object Array. More...

#include <soa.h>

+ Inheritance diagram for SOA:
+ Collaboration diagram for SOA:

Classes

struct  SOAArray
 Semantic Object Array - array member class. More...
 

Public Member Functions

 SOA (bool p_exec, size_t p_len=0)
 Ctor.
 
 SOA (const SOA &p_other)
 Copy ctor.
 
 ~SOA () override
 Dtor.
 
 SOA (SOA &&)=delete
 
SOA & operator= (const SOA &)=delete
 
SOA & operator= (SOA &&)=delete
 
void setSO (size_t p_index, SOp p_sop)
 Setter for an array object.
 
SOp ncat (size_t p_pos) const
 Returns a copy of the SOp at the given position.
 
SOA * dup () const override
 Creates a new instance as copy following the red book definition.
 
SOA * clone () const override
 Creates a new instance as copy with deep cloning.
 
std::string opequalequal () const override
 String representation for operators '==' and 'pstack'.
 
OTCode ot () const override
 Returns an OTCode.
 
std::string type () const override
 Returns a type name.
 
bool equal (const SO *p_other) const override
 Checks if this SO is equal to another SO.
 
size_t getSize () const override
 Returns the size of the SO.
 
size_t treeheight (size_t p_myheight) const override
 Tree Height.
 
auto begin ()
 Returns an iterator to the first SOp.
 
auto end ()
 Returns an iterator to the marker at end of the vector of SOps.
 
void reduce ()
 Reduces the array by one SO at the end.
 
void unfold2exec (Context &k) const
 Unfolds duplicates of the array-content to the execution stack.
 
SOp front_pop ()
 Returns a copy of the SOp at position 0 and removes this first position from the array.
 
void bind (Context &k)
 Replaces executable names with operator objects recursively into elements that are SOA.
 
- Public Member Functions inherited from SOcomposite
std::string opequal () const override
 String representation of object for operators '=', 'cvs' and 'stack'.
 
 SO ()
 Ctor.
 
 SO (bool p_exec)
 Ctor.
 
 SO (const SO &p_other)
 Copy ctor.
 
 SO (SO &&)=delete
 
- Public Member Functions inherited from SO
 SO ()
 Ctor.
 
 SO (bool p_exec)
 Ctor.
 
 SO (const SO &p_other)
 Copy ctor.
 
virtual ~SO ()
 Virtual dtor.
 
 SO (SO &&)=delete
 
SO & operator= (const SO &)=delete
 
SO & operator= (SO &&)=delete
 
bool getExec () const
 Getter for exec_.
 
void setExec (bool p_exec)
 Setter for exec_.
 
virtual bool gt (OpError &p_ec, const SO *) const
 Greater than.
 
virtual bool ge (OpError &p_ec, const SO *) const
 Greater or equal.
 
- Public Member Functions inherited from Counter< SO >
 Counter (Counter< SO > &&)=delete
 
Counter< SO > & operator= (const Counter< SO > &)=delete
 
Counter< SO > & operator= (Counter< SO > &&)=delete
 

Protected Member Functions

bool invariant () const noexcept override
 Checks class invariants.
 
- Protected Member Functions inherited from Counter< SO >
 Counter ()
 Ctor.
 
 Counter (const Counter< SO > &)
 Copy ctor.
 
 ~Counter ()
 Dtor.
 
- Protected Member Functions inherited from DbC
 ~DbC ()=default
 Protected dtor.
 

Private Attributes

std::shared_ptr< SOAArray > vec_
 The shared array.
 

Additional Inherited Members

- Static Public Member Functions inherited from Counter< SO >
static size_t getTotalCounter ()
 Static getter for totaly created objects.
 
static size_t getAliveCounter ()
 Static getter for objects alive.
 
static size_t getWatermarkCounter ()
 Static getter for the object counter watermark.
 

Detailed Description

Semantic Object Array.

SOA owns its objects.

Invariant
vec_ never is null
vec_.stlvec_ elements are never null

Constructor & Destructor Documentation

◆ SOA()

SOA::SOA ( bool  p_exec,
size_t  p_len = 0 
)
explicit

Ctor.

Parameters
[in]p_execExec attribute of the object.
[in]p_lenA value > 0 reserves SOL objects at the creation of the SOA.

Member Function Documentation

◆ bind()

void SOA::bind ( Context &  k)

Replaces executable names with operator objects recursively into elements that are SOA.

Parameters
[in,out]kThe Context to use.

◆ clone()

SOA * SOA::clone ( ) const
overridevirtual

Creates a new instance as copy with deep cloning.

Default implementation falls back to dup().
Subclasses must override this if deep cloning is required.

Returns
SO * ... A deep copy.
Postcondition
return value != nullptr
return value maintains invariants

Reimplemented from SO.

◆ dup()

SOA * SOA::dup ( ) const
inlineoverridevirtual

Creates a new instance as copy following the red book definition.

Returns
SO * ... A copy.

Implements SO.

◆ equal()

bool SOA::equal ( const SO *  p_other) const
inlineoverridevirtual

Checks if this SO is equal to another SO.

Equality means:
SOL und SOM are always equal.
For SOD, SOF and SOK, share_ptr<> points to the same object.
For SOA, share_ptr<> points to the same object, but empty arrays are equal nonetheless.
For SOO and SOo the function pointer must be the same.
Otherwise the value must be the same, even for SOS with shared_ptr<>.

Returns
bool ... true if the SO's are of the same type and equal
See also
Will be used directly and unchanged as operator eq
Parameters
[in]p_otherThe object to compare with.

Implements SO.

◆ front_pop()

SOp SOA::front_pop ( )
inline

Returns a copy of the SOp at position 0 and removes this first position from the array.

Has an undefined result if size of vector is 0.

Precondition
vectorsize > 0
Returns
SOp ... The object at position 0.

◆ getSize()

size_t SOA::getSize ( ) const
inlineoverridevirtual

Returns the size of the SO.

Default implementation returns 1 (for simple objects).
Override in subclasses to return the actual size (e.g., length of a string, number of elements in a composite).

Reimplemented from SO.

◆ invariant()

bool SOA::invariant ( ) const
inlineoverrideprotectedvirtualnoexcept

Checks class invariants.

Returns
bool ... Indicates whether the class invariants are maintained.

Reimplemented from DbC.

◆ ncat()

SOp SOA::ncat ( size_t  p_pos) const
inline

Returns a copy of the SOp at the given position.

The arrays keeps ownership of the element.

Note
ncat is short for 'Non Checking AT'.
Precondition
p_pos < vectorsize
Parameters
[in]p_posThe position, which is not checked.
Returns
SOp ... The object at position p_pos.

◆ opequalequal()

string SOA::opequalequal ( ) const
overridevirtual

String representation for operators '==' and 'pstack'.

This function attempts to produce a result that resembles the red book syntax
for creating the object.

Returns
std::string ... The representation.

Reimplemented from SO.

◆ ot()

OTCode SOA::ot ( ) const
inlineoverridevirtual

Returns an OTCode.

A "manual" implementation of polymorphism, where C++-polymorphisms fail

Returns
OTCode ... The OTCode of the instance.

Implements SO.

◆ reduce()

void SOA::reduce ( )

Reduces the array by one SO at the end.

The element will be deleted.
An empty array stays unchanged without an error condition.

◆ setSO()

void SOA::setSO ( size_t  p_index,
SOp  p_sop 
)
inline

Setter for an array object.

The existing SOx will be deleted.

Parameters
[in]p_indexindex from 0 to size-1. Attention: no range check.
[in]p_sopthe SOA takes ownership of this SO.
Precondition
p_index < arraysize
p_sop != nullptr

◆ treeheight()

size_t SOA::treeheight ( size_t  p_myheigth) const
overridevirtual

Tree Height.

The composite semantic objects can contain other composite semantic objects.
This creates a tree of objects. treeheigth() calculates the height of this tree
starting at this.

Loops will be dedected by an heuristics. We stop the recursion if the heigth
exceeds maxtreeheight, a global constant in Leonardus.

Parameters
[in]p_myheigthCall with 0. Used internally for recursion.
Returns
size_t ... The maximum height of the tree of SOcomposite -or- maxtreeheight if there is a loop.

Reimplemented from SOcomposite.

◆ type()

std::string SOA::type ( ) const
inlineoverridevirtual

Returns a type name.

Returns
std::string ... The type name of the instance.

Implements SO.

◆ unfold2exec()

void SOA::unfold2exec ( Context &  k) const

Unfolds duplicates of the array-content to the execution stack.

Parameters
[in,out]kThe Context to use.

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