|
Leonardus
|
Semantic Object stacK. More...
#include <sok.h>
Inheritance diagram for SOK:
Collaboration diagram for SOK:Classes | |
| struct | SOKDeque |
| Semantic Object Stack - deque member class. More... | |
Public Member Functions | |
| SOK () | |
| Ctor. | |
| SOK (OTCode p_restr) | |
| Ctor. | |
| SOK (const SOcomposite &p_other) | |
| Ctor from parent class. | |
| SOK (const SOK &p_other) | |
| Copy ctor. | |
| ~SOK () override | |
| Dtor. | |
| SOK (SOK &&)=delete | |
| SOK & | operator= (const SOK &)=delete |
| SOK & | operator= (SOK &&)=delete |
| SOK * | dup () const override |
| Creates a new instance as copy following the red book definition. | |
| SOK * | 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. | |
| size_t | getSize () const override |
| Returns the size of the SO. | |
| size_t | dagheight (size_t p_myheight) const override |
| DAG Height. | |
| OTCode | getRestricted () const |
| Returns the restriction. | |
| size_t | getWatermark () const |
| Returns the maximum size the stack has reached. | |
| SOp | ncat (size_t p_pos) const |
| Returns a copy of the SOp at the given position. | |
| SOp | peek () const |
| Returns a copy of the SOp of the top most position. | |
| void | putSO (size_t p_index, SOp p_sop) |
| Put a single SO into a stack object. | |
| SOp | pop () |
| Returns a copy of the top SOp, removes the SOp from the SOK. | |
| void | pop_delete () |
| Removes the top most object from SOK, and the referenced SO will be deleted. | |
| void | push (SOp p_o1) |
| Pushes the object onto the SOK and transfers ownership to the SOK. | |
| void | push (std::initializer_list< SOp > p_list) |
| Pushes n objects onto the SOK and transfers ownership to the SOK. | |
| void | push_front (SOp p_obj) |
| Pushes the object onto the front side of the SOK and transfers ownership to the SOK. | |
| bool | underflowcheck (size_t p_size) const |
| Checks SOK against given size. | |
| bool | otchecker (std::initializer_list< OTCode > p_list) const |
| Checks SO classes on the operand stack against a list of given OTCodes. | |
| bool | otchecker (OTCode p_code) const |
| Checks SO classes on the operand stack against an OTCode. | |
| bool | otcheckerOr (OTCode p_code1, OTCode p_code2) const |
| Checks SO class on the operand stack against two possible OTCodes. | |
| bool | countto (size_t &p_retval, OTCode p_code) const |
| Count the objects on the SOK down to but excluding the object from the given type. | |
| SOp | findValue (SO *p_key) const |
| Finds the given key within the whole stack, assuming a stack with dictionaries only. | |
| SOp | findDict (SO *p_key) const |
| Finds the dictionary storing the given key within the whole stack, assuming a stack with dictionaries only. | |
| __int128 | getI () |
| I from SOK. | |
| __float128 | getR () |
| R from SOK. | |
| __float128 | getIorRasR () |
| I or R from SOK as R Deletes the top object after reading its value. | |
| size_t | getISize_t (OpError &p_ec) |
| I from SOK as size_t. | |
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< SOKDeque > | deque_ |
| The shared deque. | |
| OTCode | restricted_ { OTCode::X } |
| Restrict container entries to this type. | |
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. | |
Semantic Object stacK.
Our own container adapter to std::deque to build a stack. It's a stack of pointers to SO. The bottom object has position 0. The top most object has position size-1. It can be constructed to hold only a certain object type, which is used to guard the system dictionary stack.
|
inlineexplicit |
Ctor from parent class.
Only copies the SOcomposite part; the deque_ is initialized as empty.
| [in] | p_other | Parent class object. |
|
overridevirtual |
| bool SOK::countto | ( | size_t & | p_retval, |
| OTCode | p_code | ||
| ) | const |
Count the objects on the SOK down to but excluding the object from the given type.
Implemented without C++ polymorphisms.
| [out] | p_retval | Number of objects. |
| [in] | p_code | OTCode to find. |
|
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.
| [in] | p_myheigth | Call with 0. Used internally for recursion. |
Implements SOcomposite.
|
inlineoverridevirtual |
Finds the dictionary storing the given key within the whole stack, assuming a stack with dictionaries only.
Equality is determined by SO::equal().
The ownership of the returned SOP stays within the stack.
We return a SOp instead of a SOD * to reduce coupling.
| [in] | p_key | The key to search for. |
Finds the given key within the whole stack, assuming a stack with dictionaries only.
Equality is determined by SO::equal().
| [in] | p_key | The key to search for. |
| __int128 SOK::getI | ( | ) |
I from SOK.
Deletes the top object after reading its integer value.
Does not check for stack underflow. Does not check OTCode.
| __float128 SOK::getIorRasR | ( | ) |
I or R from SOK as R Deletes the top object after reading its value.
Does not check the type of the operand stack object.
Does not check for stack underflow.
| size_t SOK::getISize_t | ( | OpError & | p_ec | ) |
I from SOK as size_t.
Deletes the top object after reading its integer value.
Exits with rangecheck, if the integer from stack can not be converted to size_t.
Checks the type of the operand stack object.
Does not check for stack underflow.
| [out] | p_ec | Success or error code. |
| __float128 SOK::getR | ( | ) |
R from SOK.
Deletes the top object after reading its real value.
Does not check for stack underflow. Does not check OTCode.
|
inline |
Returns the restriction.
|
inlineoverridevirtual |
|
inline |
Returns the maximum size the stack has reached.
|
inlineoverrideprotectedvirtualnoexcept |
Checks class invariants.
Reimplemented from DbC.
|
inline |
|
overridevirtual |
String representation for operators '==' and 'pstack'.
This function attempts to produce a result that resembles the red book syntax
for creating the object.
Reimplemented from SO.
|
inlineoverridevirtual |
Returns an OTCode.
A "manual" implementation of polymorphism, where C++-polymorphisms fail
Implements SO.
|
inline |
| bool SOK::otchecker | ( | std::initializer_list< OTCode > | p_list | ) | const |
|
inline |
|
inline |
|
inline |
| void SOK::push | ( | SOp | p_o1 | ) |
| void SOK::push | ( | std::initializer_list< SOp > | p_list | ) |
| void SOK::push_front | ( | SOp | p_obj | ) |
Pushes the object onto the front side of the SOK and transfers ownership to the SOK.
This is a non-stack feature supporting the constructing of a SOK from the operand stack.
The SOK is now responsible for managing the object's lifetime.
| [in] | p_obj | ... Pointer to SO. |
|
inline |
|
inlineoverrideprotectedvirtual |
|
inlineoverridevirtual |
|
inline |
Checks SOK against given size.
| [in] | p_size | Check value. |
Restrict container entries to this type.
OTCode::X is the value indicating no restriction.