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  

collection_sequence Class Template Reference
[Interface Library]

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

#include <comstl_coll_sequence.h>

List of all members.

Public Types

typedef CI collection_interface_type
 Colleciton interface type.

typedef EI enumerator_interface_type
 Enumerator 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 collection_sequence<
CI, EI, V, VP, R, CP, Q > 
class_type
 Type of the current parameterisation.

typedef class_type sequence_type
 Type of the current parameterisation.

typedef cs_size_t size_type
 The size type.

enum  
 Quanta. More...


Public Methods

 collection_sequence (collection_interface_type *i, cs_bool_t bAddRef, cs_size_t quant=0)
 Constructor.

 ~collection_sequence ()
 Releases the adapted interface pointer.

iterator begin () const
 Begins the iteration.

iterator end () const
 Ends the iteration.

size_type size () const
 Returns the number of items in the collection.


Detailed Description

template<typename CI, typename EI, typename V, typename VP, typename R = V const &, typename CP = degenerate_cloning_policy<EI>, cs_size_t Q = 8>
class comstl::collection_sequence< CI, EI, 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 a notional IGUIDCollection collection instance.

  typedef collection_sequence< IGUIDCollection
   , IEnumGUID
   , GUID
   , GUID_policy
   , GUID const &
   , forward_cloning_policy<IEnumGUID>
   , 5
   >   collection_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 &);

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

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


Member Typedef Documentation

typedef collection_sequence<CI, EI, V, VP, R, CP, Q> class_type
 

Type of the current parameterisation.

typedef CP cloning_policy_type
 

Cloning policy type.

typedef CI collection_interface_type
 

Colleciton interface type.

typedef EI enumerator_interface_type
 

Enumerator interface type.

typedef cloning_policy_type::iterator_tag_type iterator_tag_type
 

Iterator tag type.

typedef R reference_type
 

Reference type.

typedef class_type sequence_type
 

Type of the current parameterisation.

typedef cs_size_t size_type
 

The size type.

typedef policy_adaptor<VP> value_policy_type
 

Value policy type.

typedef V value_type
 

Value type.


Member Enumeration Documentation

anonymous enum
 

Quanta.


Constructor & Destructor Documentation

collection_sequence collection_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

~collection_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

size_type size   const [inline]
 

Returns the number of items in the collection.

Note:
This method will not compile for collection interfaces that do not contain the get_Count method


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

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