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  FunctorEqual
 Equality functor for SO* keys in SOD's unordered_map. More...
 
struct  FunctorHash
 Hash functor for SO* keys in SOD's unordered_map. More...
 
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_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.
 
auto begin () const
 Returns an iterator to the begin of the map of two SOps.
 
auto end () const
 Returns an iterator to the marker at end of the map of two SOps.
 
void insert (SOp p_key, SOp p_value)
 Insert with the red book definition of equal.
 
SOp find (SO *p_key) const
 Searches for p_key in the dictionary.
 
auto any_pop ()
 Returns a pair from the dictionary.
 
void undef (SO *p_key)
 Removes both p_key and its value from the dictionary.
 
- 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< SODMap > map_
 The shared dictionary.
 

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

Invariant
inherited from SOcomposite
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.

◆ dagheight()

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

SOD * SOD::dup ( ) const
inlineoverridevirtual

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

Returns
SO * ... A copy.

Implements SO.

◆ find()

SOp SOD::find ( SO *  p_key) const

Searches for p_key in the dictionary.

Equality is defined by SO::equal().

Precondition
p_key != nullptr
Parameters
[in]p_keyThe 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 object).

Reimplemented from SO.

◆ insert()

void SOD::insert ( SOp  p_key,
SOp  p_value 
)

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.

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

◆ shptr()

void * SOD::shptr ( ) const
inlineoverrideprotectedvirtual

Pointer to the shared object.

Returns
void * ... The naked pointer.

Implements SOshptr.

◆ type()

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

Returns a type name.

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

Implements SO.

◆ undef()

void SOD::undef ( 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_keyThe key.

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