STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Concurrency::single_link_registry< _Block > Class Template Reference

The single_link_registry object is a network_link_registry that manages only a single source or target block. More...

#include <agents.h>

Inheritance diagram for Concurrency::single_link_registry< _Block >:
Concurrency::network_link_registry< _Block >

Public Member Functions

 single_link_registry ()
 Constructs a single_link_registry object. More...
 
virtual ~single_link_registry ()
 Destroys the single_link_registry object. More...
 
virtual void add (typename network_link_registry< _Block >::_EType _Link)
 Adds a link to the single_link_registry object. More...
 
virtual bool remove (typename network_link_registry< _Block >::_EType _Link)
 Removes a link from the single_link_registry object. More...
 
virtual bool contains (typename network_link_registry< _Block >::_EType _Link)
 Searches the single_link_registry object for a specified block. More...
 
virtual size_t count ()
 Counts the number of items in the single_link_registry object. More...
 
virtual network_link_registry< _Block >::iterator begin ()
 Returns an iterator to the first element in the single_link_registry object. More...
 

Protected Member Functions

virtual void _Next_index (size_t &_Index)
 Skips empty slots and updates the index to the next non-empty slot. This is called by the iterator. More...
 
virtual network_link_registry< _Block >::_EType _Get_element (size_t _Index) const
 Retrieves the element at the given index. If the index is out of bounds, NULL is returned. Users need to use the iterator to access the links. More...
 

Private Attributes

network_link_registry< _Block >::_EType _M_connectedLink
 

Additional Inherited Members

Detailed Description

template<class _Block>
class Concurrency::single_link_registry< _Block >

The single_link_registry object is a network_link_registry that manages only a single source or target block.

Template Parameters
_BlockThe block data type being stored in the single_link_registry object.
See also
multi_link_registry Class

Constructor & Destructor Documentation

template<class _Block>
Concurrency::single_link_registry< _Block >::single_link_registry ( )
inline

Constructs a single_link_registry object.

743  {
744  }
#define NULL
Definition: vcruntime.h:236
template<class _Block>
virtual Concurrency::single_link_registry< _Block >::~single_link_registry ( )
inlinevirtual

Destroys the single_link_registry object.

The method throws an invalid_operation exception if it is called before the link is removed.

755  {
756  // It is an error to delete link registry with links
757  // still present
758  if (count() != 0)
759  {
760  throw invalid_operation("Deleting link registry before removing all the links");
761  }
762  }

Member Function Documentation

template<class _Block>
virtual network_link_registry<_Block>::_EType Concurrency::single_link_registry< _Block >::_Get_element ( size_t  _Index) const
inlineprotectedvirtual

Retrieves the element at the given index. If the index is out of bounds, NULL is returned. Users need to use the iterator to access the links.

Parameters
_IndexThe index of the link to be retrieved.
Returns
The element in the registry at the index specified by the _Index parameter.

Implements Concurrency::network_link_registry< _Block >.

884  {
885  if (_Index == 0)
886  {
887  return _M_connectedLink;
888  }
889 
890  return NULL;
891  }
#define NULL
Definition: vcruntime.h:236
template<class _Block>
virtual void Concurrency::single_link_registry< _Block >::_Next_index ( size_t _Index)
inlineprotectedvirtual

Skips empty slots and updates the index to the next non-empty slot. This is called by the iterator.

Parameters
_IndexA reference to the index that is to be updated.

Implements Concurrency::network_link_registry< _Block >.

865  {
866  if (_M_connectedLink == NULL)
867  {
868  _Index++;
869  }
870  }
#define NULL
Definition: vcruntime.h:236
template<class _Block>
virtual void Concurrency::single_link_registry< _Block >::add ( typename network_link_registry< _Block >::_EType  _Link)
inlinevirtual

Adds a link to the single_link_registry object.

Parameters
_LinkA pointer to a block to be added.

The method throws an invalid_link_target exception if there is already a link in this registry.

776  {
777  if (_Link == NULL)
778  {
779  return;
780  }
781 
782  // Only one link can be added.
783  if (_M_connectedLink != NULL)
784  {
785  throw invalid_link_target("_Link");
786  }
787 
789  }
#define NULL
Definition: vcruntime.h:236
_FS_DLL int __CLRCALL_PURE_OR_CDECL _Link(const wchar_t *, const wchar_t *)
template<class _Block>
virtual network_link_registry<_Block>::iterator Concurrency::single_link_registry< _Block >::begin ( )
inlinevirtual

Returns an iterator to the first element in the single_link_registry object.

The end state is indicated by a NULL link.

Returns
An iterator addressing the first element in the single_link_registry object.

Implements Concurrency::network_link_registry< _Block >.

850  {
851  return (typename network_link_registry<_Block>::iterator(this, 0));
852  }
template<class _Block>
virtual bool Concurrency::single_link_registry< _Block >::contains ( typename network_link_registry< _Block >::_EType  _Link)
inlinevirtual

Searches the single_link_registry object for a specified block.

Parameters
_LinkA pointer to a block that is to be searched for in the single_link_registry object.
Returns
true if the link was found, false otherwise.
823  {
824  return ((_Link != NULL) && (_M_connectedLink == _Link));
825  }
#define NULL
Definition: vcruntime.h:236
_FS_DLL int __CLRCALL_PURE_OR_CDECL _Link(const wchar_t *, const wchar_t *)
template<class _Block>
virtual size_t Concurrency::single_link_registry< _Block >::count ( )
inlinevirtual

Counts the number of items in the single_link_registry object.

Returns
The number of items in the single_link_registry object.

Implements Concurrency::network_link_registry< _Block >.

835  {
836  return (_M_connectedLink == NULL) ? 0 : 1;
837  }
#define NULL
Definition: vcruntime.h:236
template<class _Block>
virtual bool Concurrency::single_link_registry< _Block >::remove ( typename network_link_registry< _Block >::_EType  _Link)
inlinevirtual

Removes a link from the single_link_registry object.

Parameters
_LinkA pointer to a block to be removed, if found.
Returns
true if the link was found and removed, false otherwise.
802  {
803  if ((_Link != NULL) && (_M_connectedLink == _Link))
804  {
806  return true;
807  }
808 
809  return false;
810  }
#define NULL
Definition: vcruntime.h:236
_FS_DLL int __CLRCALL_PURE_OR_CDECL _Link(const wchar_t *, const wchar_t *)

Member Data Documentation

template<class _Block>
network_link_registry<_Block>::_EType Concurrency::single_link_registry< _Block >::_M_connectedLink
private

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