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 (_EType _Link)
 Adds a link to the single_link_registry object. More...
 
virtual bool remove (_EType _Link)
 Removes a link from the single_link_registry object. More...
 
virtual bool contains (_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 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 _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

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

742  {
743  }
#define NULL
Definition: crtdbg.h:30
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.

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

Member Function Documentation

template<class _Block>
virtual _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 >.

883  {
884  if (_Index == 0)
885  {
886  return _M_connectedLink;
887  }
888 
889  return NULL;
890  }
#define NULL
Definition: crtdbg.h:30
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 >.

864  {
865  if (_M_connectedLink == NULL)
866  {
867  _Index++;
868  }
869  }
#define NULL
Definition: crtdbg.h:30
template<class _Block>
virtual void Concurrency::single_link_registry< _Block >::add ( _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.

Implements Concurrency::network_link_registry< _Block >.

775  {
776  if (_Link == NULL)
777  {
778  return;
779  }
780 
781  // Only one link can be added.
782  if (_M_connectedLink != NULL)
783  {
784  throw invalid_link_target("_Link");
785  }
786 
788  }
_FS_DLL int __CLRCALL_PURE_OR_CDECL _Link(const char *, const char *)
#define NULL
Definition: crtdbg.h:30
template<class _Block>
virtual 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 >.

849  {
850  return (iterator(this, 0));
851  }
template<class _Block>
virtual bool Concurrency::single_link_registry< _Block >::contains ( _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.

Implements Concurrency::network_link_registry< _Block >.

822  {
823  return ((_Link != NULL) && (_M_connectedLink == _Link));
824  }
_FS_DLL int __CLRCALL_PURE_OR_CDECL _Link(const char *, const char *)
#define NULL
Definition: crtdbg.h:30
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 >.

834  {
835  return (_M_connectedLink == NULL) ? 0 : 1;
836  }
#define NULL
Definition: crtdbg.h:30
template<class _Block>
virtual bool Concurrency::single_link_registry< _Block >::remove ( _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.

Implements Concurrency::network_link_registry< _Block >.

801  {
802  if ((_Link != NULL) && (_M_connectedLink == _Link))
803  {
805  return true;
806  }
807 
808  return false;
809  }
_FS_DLL int __CLRCALL_PURE_OR_CDECL _Link(const char *, const char *)
#define NULL
Definition: crtdbg.h:30

Member Data Documentation

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

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