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_view 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 dagheight (size_t p_myheight) const override
 DAG Height.
 
auto begin () const
 Returns an iterator to the first SOp.
 
auto end () const
 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.
 
int findSubArray (const SOA *p_sub)
 Searches for p_sub within this.
 
void substSubArray (size_t p_idx, size_t p_oldSize, const SOA *p_sub)
 Substitute at index p_idx p_oldsize elements by p_sub.
 
- Public Member Functions inherited from SOshptr
std::string opequal () const override
 String representation of object for operators '=', 'cvs' and 'stack'.
 
bool equal (const SO *p_other) const override
 Checks if this SO is equal to another SO.
 
 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 ()=default
 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

void * shptr () const override
 Pointer to the shared object.
 
bool invariant () const noexcept override
 Checks class invariants.
 
- Protected Member Functions inherited from SOshptr
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 SOcomposite
static bool otcodeIsComposite (OTCode p_code)
 Checks if an OTCode represents a composite type (A, Ax, D, K).
 
- 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
inherited from SOcomposite
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.

◆ dagheight()

size_t SOA::dagheight ( size_t  p_myheigth) const
overridevirtual

DAG Height.

The composite semantic objects can contain other composite semantic objects.
This creates a directed acyclic graph (DAG) of objects.
dagheight() calculates the height of this DAG starting at this.

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

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

Implements SOcomposite.

◆ 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<>.

Precondition
parameter != nullptr
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.

◆ findSubArray()

int SOA::findSubArray ( const SOA *  p_sub)

Searches for p_sub within this.

Uses equal for comparison of elements.

Precondition
p_sub != nullptr
p_sub->getSize() > 0
Parameters
[in]p_subThe array to look for.
Returns
int ...
- -1 if not found
- 0 to size-1 the index of the match

◆ 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 object).

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.

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

◆ shptr()

void * SOA::shptr ( ) const
inlineoverrideprotectedvirtual

Pointer to the shared object.

Returns
void * ... The naked pointer.

Implements SOshptr.

◆ substSubArray()

void SOA::substSubArray ( size_t  p_idx,
size_t  p_oldSize,
const SOA *  p_sub 
)

Substitute at index p_idx p_oldsize elements by p_sub.

The size of this->vec_ grows/shrinks/stay the same by (p_new->getSize()-p_oldsize). The replaced elements will be deleted. The member function setSO() is a special case. The new elements from p_sub are cloned.

Precondition
p_idx < getSize()
p_idx+p_oldsize <= getSize()
p_new != nullptr
Parameters
[in]p_idxThe index starting with 0 of the old subarray.
[in]p_oldSizeThe size of the subarray which will be replaced.
[in]p_subThe array with the new elements.

◆ type()

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

Returns a type name.

Returns
std::string_view ... 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: