summaryrefslogtreecommitdiff
path: root/trunk/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Acceptor_Registry.h
blob: a225818abadc0ecb7979e4e2deb966d7ee7ec157 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// -*- C++ -*-

//=============================================================================
/**
 *  @file     PortableGroup_Acceptor_Registry.h
 *
 *  $Id$
 *
 *  Registry for dynamically created acceptors.
 *
 *  @author Frank Hunleth <fhunleth@cs.wustl.edu>
 */
//=============================================================================

#ifndef TAO_PORTABLEGROUP_ACCEPTOR_REGISTRY_H
#define TAO_PORTABLEGROUP_ACCEPTOR_REGISTRY_H

#include /**/ "ace/pre.h"

#include "ace/Unbounded_Queue.h"

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

#include "ace/CORBA_macros.h"

#include "orbsvcs/PortableGroup/portablegroup_export.h"

#include "tao/Transport_Acceptor.h"
#include "tao/Resource_Factory.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

class TAO_Profile;

namespace CORBA
{
  class Environment;
}

/**
 * @class TAO_PortableGroup_Acceptor_Registry
 *
 * @brief .
 *
 * There is one TAO_PortableGroup_Acceptor_Registry per ORB_Core.
 */
class TAO_PortableGroup_Export TAO_PortableGroup_Acceptor_Registry
{
public:

  /**
   * @struct Entry
   *
   * @brief Value field of the portable group acceptor registry.
   */
  struct Entry
  {
    /// Pointer to the acceptor for this GroupId.
    TAO_Acceptor *acceptor;

    /// Cached endpoint that the acceptor is listening on.
    TAO_Endpoint *endpoint;

    /// Count of times that this GroupId has been opened.
    int cnt;
  };


  // = Initialization and termination methods.
  ///  Default constructor.
  TAO_PortableGroup_Acceptor_Registry (void);

  ///  Default destructor.
  ~TAO_PortableGroup_Acceptor_Registry (void);

  /// Open an acceptor based on a tagged profile.
  void open (const TAO_Profile* profile, TAO_ORB_Core &orb_core);

  /// Close all open acceptors.
  int close_all (void);

  typedef ACE_Unbounded_Queue<Entry> Acceptor_Registry;
  typedef ACE_Unbounded_Queue_Iterator<Entry> Acceptor_Registry_Iterator;

protected:

  /// Helper function to open a group acceptor.
  void open_i (const TAO_Profile* profile,
               TAO_ORB_Core &orb_core,
               TAO_ProtocolFactorySetItor &factory);

  /// Find an acceptor by using a profile.
  int find (const TAO_Profile* profile,
            Entry *&entry);

private:

  // The acceptor registry should not be copied.
  TAO_PortableGroup_Acceptor_Registry (
    const TAO_PortableGroup_Acceptor_Registry&);
  void operator= (const TAO_PortableGroup_Acceptor_Registry&);

private:
  /// List of acceptors that are currently open.
  Acceptor_Registry registry_;
};

TAO_END_VERSIONED_NAMESPACE_DECL

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

#endif /* TAO_PORTABLEGROUP_ACCEPTOR_REGISTRY_H */