mimic++ v4
Loading...
Searching...
No Matches
mimicpp::ExpectationCollection< Signature > Class Template Reference

Collects all expectations for a specific (decayed) signature. More...

#include <Expectation.hpp>

Public Types

using CallInfoT = call::info_for_signature_t<Signature>
 The expected call type.
 
using ExpectationT = Expectation<Signature>
 The interface type of the stored expectations.
 
using ReturnT = signature_return_type_t<Signature>
 The return type.
 

Public Member Functions

 ~ExpectationCollection ()=default
 Defaulted destructor.
 
 ExpectationCollection ()=default
 Defaulted default constructor.
 
 ExpectationCollection (const ExpectationCollection &)=delete
 Deleted copy-constructor.
 
ExpectationCollectionoperator= (const ExpectationCollection &)=delete
 Deleted copy-assignment-operator.
 
 ExpectationCollection (ExpectationCollection &&)=default
 Defaulted move-constructor.
 
ExpectationCollectionoperator= (ExpectationCollection &&)=default
 Defaulted move-assignment-operator.
 
void push (std::shared_ptr< ExpectationT > expectation)
 Inserts the given expectation into the internal storage.
 
void remove (std::shared_ptr< ExpectationT > expectation)
 Removes the given expectation from the internal storage.
 
ReturnT handle_call (const CallInfoT &call)
 Handles the incoming call.
 

Detailed Description

template<typename Signature>
requires std::same_as<Signature, signature_decay_t<Signature>>
class mimicpp::ExpectationCollection< Signature >

Collects all expectations for a specific (decayed) signature.

Template Parameters
SignatureThe decayed signature.

Member Typedef Documentation

◆ CallInfoT

template<typename Signature >
using mimicpp::ExpectationCollection< Signature >::CallInfoT = call::info_for_signature_t<Signature>

The expected call type.

◆ ExpectationT

template<typename Signature >
using mimicpp::ExpectationCollection< Signature >::ExpectationT = Expectation<Signature>

The interface type of the stored expectations.

◆ ReturnT

template<typename Signature >
using mimicpp::ExpectationCollection< Signature >::ReturnT = signature_return_type_t<Signature>

The return type.

Constructor & Destructor Documentation

◆ ~ExpectationCollection()

template<typename Signature >
mimicpp::ExpectationCollection< Signature >::~ExpectationCollection ( )
default

Defaulted destructor.

◆ ExpectationCollection() [1/3]

template<typename Signature >
mimicpp::ExpectationCollection< Signature >::ExpectationCollection ( )
nodiscarddefault

Defaulted default constructor.

◆ ExpectationCollection() [2/3]

template<typename Signature >
mimicpp::ExpectationCollection< Signature >::ExpectationCollection ( const ExpectationCollection< Signature > & )
delete

Deleted copy-constructor.

◆ ExpectationCollection() [3/3]

template<typename Signature >
mimicpp::ExpectationCollection< Signature >::ExpectationCollection ( ExpectationCollection< Signature > && )
nodiscarddefault

Defaulted move-constructor.

Member Function Documentation

◆ handle_call()

template<typename Signature >
ReturnT mimicpp::ExpectationCollection< Signature >::handle_call ( const CallInfoT & call)
inlinenodiscard

Handles the incoming call.

Parameters
callThe call to be handled.
Returns
Returns an appropriate result from the matched expectation.

This function queries all stored expectations, whether they accept the call. If multiple matches are possible, the best match is selected and a "matched"-report is emitted. If no matches are found, "no matched"-report is emitted and the call is aborted (e.g. by throwing an exception or terminating). If matches are possible, but all expectations are saturated, an "inapplicable match"-report is emitted.

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename Signature >
ExpectationCollection & mimicpp::ExpectationCollection< Signature >::operator= ( const ExpectationCollection< Signature > & )
delete

Deleted copy-assignment-operator.

◆ operator=() [2/2]

template<typename Signature >
ExpectationCollection & mimicpp::ExpectationCollection< Signature >::operator= ( ExpectationCollection< Signature > && )
default

Defaulted move-assignment-operator.

◆ push()

template<typename Signature >
void mimicpp::ExpectationCollection< Signature >::push ( std::shared_ptr< ExpectationT > expectation)
inline

Inserts the given expectation into the internal storage.

Parameters
expectationThe expectation to be inserted.
Attention
Inserting an expectation, which is already element of any ExpectationCollection (including the current one), is undefined behavior.

◆ remove()

template<typename Signature >
void mimicpp::ExpectationCollection< Signature >::remove ( std::shared_ptr< ExpectationT > expectation)
inline

Removes the given expectation from the internal storage.

Parameters
expectationThe expectation to be removed.

This function also checks, whether the removed expectation is satisfied. If not, an "unfulfilled expectation"- report is emitted.

Attention
Removing an expectation, which is not element of the current ExpectationCollection, is undefined behavior.

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