STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
Concurrency::ITarget< _Type > Class Template Referenceabstract

The ITarget class is the interface for all target blocks. Target blocks consume messages offered to them by ISource blocks. More...

#include <agents.h>

Public Types

typedef _Type type
 A type alias for _Type . More...
 
typedef std::function< bool(_Type const &)> filter_method
 The signature of any method used by the block that returns a bool value to determine whether an offered message should be accepted. More...
 

Public Member Functions

virtual ~ITarget ()
 Destroys the ITarget object. More...
 
virtual message_status propagate (_Inout_opt_ message< _Type > *_PMessage, _Inout_opt_ ISource< _Type > *_PSource)=0
 When overridden in a derived class, asynchronously passes a message from a source block to this target block. More...
 
virtual message_status send (_Inout_ message< _Type > *_PMessage, _Inout_ ISource< _Type > *_PSource)=0
 When overridden in a derived class, synchronously passes a message to the target block. More...
 
virtual bool supports_anonymous_source ()
 When overridden in a derived class, returns true or false depending on whether the message block accepts messages offered by a source that is not linked to it. If the overridden method returns true, the target cannot postpone an offered message, as consumption of a postponed message at a later time requires the source to be identified in its source link registry. More...
 

Protected Member Functions

virtual void link_source (_Inout_ ISource< _Type > *_PSource)=0
 When overridden in a derived class, links a specified source block to this ITarget block. More...
 
virtual void unlink_source (_Inout_ ISource< _Type > *_PSource)=0
 When overridden in a derived class, unlinks a specified source block from this ITarget block. More...
 
virtual void unlink_sources ()=0
 When overridden in a derived class, unlinks all source blocks from this ITarget block. More...
 

Friends

class ISource< _Type >
 

Detailed Description

template<class _Type>
class Concurrency::ITarget< _Type >

The ITarget class is the interface for all target blocks. Target blocks consume messages offered to them by ISource blocks.

Template Parameters
_TypeThe data type of the payload within the messages accepted by the target block.

For more information, see Asynchronous Message Blocks.

See also
ISource Class

Member Typedef Documentation

template<class _Type>
typedef std::function<bool(_Type const&)> Concurrency::ITarget< _Type >::filter_method

The signature of any method used by the block that returns a bool value to determine whether an offered message should be accepted.

template<class _Type>
typedef _Type Concurrency::ITarget< _Type >::type

A type alias for _Type .

Constructor & Destructor Documentation

template<class _Type>
virtual Concurrency::ITarget< _Type >::~ITarget ( )
inlinevirtual

Destroys the ITarget object.

2468 {}

Member Function Documentation

template<class _Type>
virtual void Concurrency::ITarget< _Type >::link_source ( _Inout_ ISource< _Type > *  _PSource)
protectedpure virtual

When overridden in a derived class, links a specified source block to this ITarget block.

Parameters
_PSourceThe ISource block being linked to this ITarget block.

This function should not be called directly on an ITarget block. Blocks should be connected together using the link_target method on ISource blocks, which will invoke the link_source method on the corresponding target.

Implemented in Concurrency::propagator_block< _TargetLinkRegistry, _SourceLinkRegistry, _MessageProcessorType >, and Concurrency::target_block< _SourceLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual message_status Concurrency::ITarget< _Type >::propagate ( _Inout_opt_ message< _Type > *  _PMessage,
_Inout_opt_ ISource< _Type > *  _PSource 
)
pure virtual

When overridden in a derived class, asynchronously passes a message from a source block to this target block.

Parameters
_PMessageA pointer to the message object.
_PSourceA pointer to the source block offering the message.
Returns
A message_status indication of what the target decided to do with the message.

The method throws an invalid_argument exception if either the _PMessage or _PSource parameter is NULL.

Implemented in Concurrency::propagator_block< _TargetLinkRegistry, _SourceLinkRegistry, _MessageProcessorType >, and Concurrency::target_block< _SourceLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual message_status Concurrency::ITarget< _Type >::send ( _Inout_ message< _Type > *  _PMessage,
_Inout_ ISource< _Type > *  _PSource 
)
pure virtual

When overridden in a derived class, synchronously passes a message to the target block.

Parameters
_PMessageA pointer to the message object.
_PSourceA pointer to the source block offering the message.
Returns
A message_status indication of what the target decided to do with the message.

The method throws an invalid_argument exception if either the _PMessage or _PSource parameter is NULL.

Using the send method outside of message initiation and to propagate messages within a network is dangerous and can lead to deadlock.

When send returns, the message has either already been accepted, and transferred into the target block, or it has been declined by the target.

Implemented in Concurrency::propagator_block< _TargetLinkRegistry, _SourceLinkRegistry, _MessageProcessorType >, and Concurrency::target_block< _SourceLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual bool Concurrency::ITarget< _Type >::supports_anonymous_source ( )
inlinevirtual

When overridden in a derived class, returns true or false depending on whether the message block accepts messages offered by a source that is not linked to it. If the overridden method returns true, the target cannot postpone an offered message, as consumption of a postponed message at a later time requires the source to be identified in its source link registry.

Returns
true if the block can accept message from a source that is not linked to it false otherwise.

Reimplemented in Concurrency::transformer< _Input, _Output >, Concurrency::call< _Type, _FunctorType >, Concurrency::overwrite_buffer< _Type >, Concurrency::overwrite_buffer< agent_status >, and Concurrency::unbounded_buffer< _Type >.

2531  {
2532  return false;
2533  }
template<class _Type>
virtual void Concurrency::ITarget< _Type >::unlink_source ( _Inout_ ISource< _Type > *  _PSource)
protectedpure virtual

When overridden in a derived class, unlinks a specified source block from this ITarget block.

Parameters
_PSourceThe ISource block being unlinked from this ITarget block.

This function should not be called directly on an ITarget block. Blocks should be disconnected using the unlink_target or unlink_targets methods on ISource blocks, which will invoke the unlink_source method on the corresponding target.

Implemented in Concurrency::propagator_block< _TargetLinkRegistry, _SourceLinkRegistry, _MessageProcessorType >, and Concurrency::target_block< _SourceLinkRegistry, _MessageProcessorType >.

template<class _Type>
virtual void Concurrency::ITarget< _Type >::unlink_sources ( )
protectedpure virtual

Friends And Related Function Documentation

template<class _Type>
friend class ISource< _Type >
friend

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