STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

enumerator_sequence Class Template Reference
[Interface Library]

A template for adapting COM enumeration to STL-compatible sequence iteration. More...

#include <comstl_enum_sequence.h>

Inheritance diagram for enumerator_sequence:

enum_simple_sequence List of all members.

Public Types

typedef I interface_type
 Interface type.

typedef V value_type
 Value type.

typedef policy_adaptor< VP > value_policy_type
 Value policy type.

typedef R reference_type
 Reference type.

typedef CP cloning_policy_type
 Cloning policy type.

typedef cloning_policy_type::iterator_tag_type iterator_tag_type
 Iterator tag type.

typedef enumerator_sequence<
I, V, VP, R, CP, Q > 
class_type
 Type of the current parameterisation.

enum  
 Quanta. More...


Public Methods

 enumerator_sequence (interface_type *i, cs_bool_t bAddRef, cs_size_t quant=0)
 Constructor.

 ~enumerator_sequence ()
 Releases the adapted interface pointer.

iterator begin () const
 Begins the iteration.

iterator end () const
 Ends the iteration.


Detailed Description

template<typename I, typename V, typename VP, typename R = V const &, typename CP = degenerate_cloning_policy<I>, cs_size_t Q = 8>
class comstl::enumerator_sequence< I, V, VP, R, CP, Q >

A template for adapting COM enumeration to STL-compatible sequence iteration.

Parameters:
I  Interface
V  Value type
VP  Value policy type
R  Reference type
CP  Cloning policy type
Q  Quanta
The various parameterising types are used to stipulate the interface and the value type, and how they are to be handled.

For example, the following parameterisation defines a sequence operating over an IEnumGUID enumerator instance.

  typedef enumerator_sequence< IEnumGUID
   , GUID
   , GUID_policy
   , GUID const &
   , forward_cloning_policy<IEnumGUID>
   , 5
   >   enum_sequence_t;

The value type is GUID and it is returned as a reference, as the GUID const & in fact.

The COMSTL type GUID_policy controls how the GUID instances are initialised, copied and destroyed.

The COMSTL type forward_cloning_policy allows the sequence to provide Forward Iterator semantics.

And the 5 indicates that the sequence should grab 5 values at a time, to save round trips to the enumerator.

So this would be used like the following:

  void dump_GUID(GUID const &);

  LPENUMGUID        *penGUIDs = . . .;      // Create an instance from wherever
  enum_sequence_t   guids(penGUIDs, false); // Eat the reference

  std::for_each(guids.begin(), guids.end(), dump_GUID);


Member Typedef Documentation

typedef enumerator_sequence<I, V, VP, R, CP, Q> class_type
 

Type of the current parameterisation.

Reimplemented in enum_simple_sequence.

typedef CP cloning_policy_type
 

Cloning policy type.

Reimplemented in enum_simple_sequence.

typedef I interface_type
 

Interface type.

Reimplemented in enum_simple_sequence.

typedef cloning_policy_type::iterator_tag_type iterator_tag_type
 

Iterator tag type.

Reimplemented in enum_simple_sequence.

typedef R reference_type
 

Reference type.

Reimplemented in enum_simple_sequence.

typedef policy_adaptor<VP> value_policy_type
 

Value policy type.

Reimplemented in enum_simple_sequence.

typedef V value_type
 

Value type.

Reimplemented in enum_simple_sequence.


Member Enumeration Documentation

anonymous enum
 

Quanta.


Constructor & Destructor Documentation

enumerator_sequence interface_type   i,
cs_bool_t    bAddRef,
cs_size_t    quant = 0
[inline]
 

Constructor.

Parameters:
i  The enumeration interface pointer to adapt
bAddRef  Causes a reference to be added if true, otherwise the sequence is deemed to sink, or consume, the interface pointer
quant  The actual quanta required for this instance. Must be <= Q

~enumerator_sequence   [inline]
 

Releases the adapted interface pointer.


Member Function Documentation

iterator begin   const [inline]
 

Begins the iteration.

Returns:
An iterator representing the start of the sequence

iterator end   const [inline]
 

Ends the iteration.

Returns:
An iterator representing the end of the sequence


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

STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004