summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Message_Block_Data_Iterator.h
blob: 3f28eb5e7c6b89079ea2d577970aaba3607dc206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// -*- C++ -*-

//=============================================================================
/**
 *  @file     UIPMC_Message_Block_Data_Iterator.h
 *
 *  $Id$
 *
 *  @author Frank Hunleth <frank@hunleth.com>
 */
//=============================================================================

#ifndef TAO_UIPMC_MESSAGE_BLOCK_DATA_ITERATOR_H
#define TAO_UIPMC_MESSAGE_BLOCK_DATA_ITERATOR_H
#include /**/ "ace/pre.h"

#include "ace/os_include/sys/os_uio.h"
#include "ace/os_include/os_stddef.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

/**
 * @class UIPMC_Message_Block_Data_Iterator
 *
 * @brief This is a help class for iterating through ACE_Message_Blocks and to
 *        segment them into MIOP packets.
 */
class UIPMC_Message_Block_Data_Iterator
{
public:
  /// Constructor
  UIPMC_Message_Block_Data_Iterator (iovec *iov, int iovcnt);

  /// Get the next data block that has a size less than or equal
  /// to max_length.  Return the length of the block returned.
  size_t next_block (size_t max_length,
                     iovec &block);

private:
  enum State
  {
    INTER_BLOCK,
    INTRA_BLOCK
  };

  iovec *iov_;
  int iovcnt_;

  // Point internal to a message block, if we have to split one up.
  char *iov_ptr_;
  int iov_index_;

  // Length used in a split message block.
  size_t iov_len_left_;

  // Current message iterator state.
  State state_;

};

#include /**/ "ace/post.h"
#endif  /* TAO_UIPMC_MESSAGE_BLOCK_DATA_ITERATOR_H */