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

Semantic Object Dictionary. More...

#include <sod.h>

+ Inheritance diagram for SOD:
+ Collaboration diagram for SOD:

Classes

struct  SODMap
 Semantic Object Dictionary - map member class. More...
 

Public Member Functions

 SOD ()
 Ctor.
 
 SOD (const SOcomposite &p_other)
 Ctor from parent class object.
 
 SOD (const SOD &p_other)
 Copy ctor.
 
 ~SOD () override
 Dtor.
 
 SOD (SOD &&)=delete
 
SOD & operator= (const SOD &)=delete
 
SOD & operator= (SOD &&)=delete
 
SOD * dup () const override
 Creates a new instance as copy following the red book definition.
 
SOD * 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 begin of the map of two SOps.
 
auto end ()
 Returns an iterator to the marker at end of the map of two SOps.
 
void insert (SOp p_key, SOp p_value, bool p_forcebegin=false)
 Insert with the red book definition of equal.
 
SOp find (const SO *p_key) const
 Searches for p_key in the dictionary.
 
auto any_pop ()
 Returns a pair from the dictionary.
 
void undef (const SO *p_key)
 Removes both p_key and its value from the dictionary.
 
- 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< SODMap > map_
 The shared dictionary.
 

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

Invariant
map_ never is null.
map_.stlmap_ elements are never null

Constructor & Destructor Documentation

◆ SOD()

SOD::SOD ( const SOcomposite &  p_other)
inlineexplicit

Ctor from parent class object.

Parameters
[in]p_otherWe construct as copy from this parent class object.

Member Function Documentation

◆ any_pop()

auto SOD::any_pop ( )
inline

Returns a pair from the dictionary.

The pair is removed from the dictionary.

Precondition
getSize() > 0
Returns
std::pair<const SOp, SOp> ... from the SOD

◆ clone()

SOD * SOD::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()

SOD * SOD::dup ( ) const
inlineoverridevirtual

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

Returns
SO * ... A copy.

Implements SO.

◆ equal()

bool SOD::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.

◆ find()

SOp SOD::find ( const SO *  p_key) const

Searches for p_key in the dictionary.

Equality is defined by SO::equal().

Precondition
p_key != nullptr
Parameters
[in]p_key
Returns
SOp ... a SOp to the value, the ownership stays within the dictionary; a nullptr if not found

◆ getSize()

size_t SOD::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.

◆ insert()

void SOD::insert ( SOp  p_key,
SOp  p_value,
bool  p_forcebegin = false 
)

Insert with the red book definition of equal.

The SOD takes ownership. If the key is found in the dictionary,
then this existing key and the corresponding value will be deleted.

Precondition
p_key != nullptr and p_value != nullptr.
Parameters
[in]p_keyKey.
[in]p_valueValue.
[in]p_forcebeginThis parameter forces the insertion of the key-value pair at the beginning of the dictionary.

◆ invariant()

bool SOD::invariant ( ) const
inlineoverrideprotectedvirtualnoexcept

Checks class invariants.

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

Reimplemented from DbC.

◆ opequalequal()

string SOD::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 SOD::ot ( ) const
inlineoverridevirtual

Returns an OTCode.

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

Returns
OTCode ... The OTCode of the instance.

Implements SO.

◆ treeheight()

size_t SOD::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 SOD::type ( ) const
inlineoverridevirtual

Returns a type name.

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

Implements SO.

◆ undef()

void SOD::undef ( const SO *  p_key)

Removes both p_key and its value from the dictionary.

Equality is defined by SO::equal(). Doesn't generate a error if p_key can not be found.

Precondition
p_key != nullptr
Parameters
[in]p_key

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