summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Event/Mcast/Common/EC_Wrapper.h
blob: cf73b4bca21c92cae33d7a9411eb44412247655f (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
/* -*- C++ -*- */
#ifndef EC_WRAPPER_H
#define EC_WRAPPER_H

#include "orbsvcs/RtecEventChannelAdminS.h"
#include "orbsvcs/Event/EC_Lifetime_Utils_T.h"
#include "ECMcastTests_export.h"

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

TAO_BEGIN_VERSIONED_NAMESPACE_DECL
class TAO_EC_Event_Channel;
TAO_END_VERSIONED_NAMESPACE_DECL

/**
 * @class EC_Wrapper
 *
 * @brief This class decorates Rtec Event Channel implementation:
 *        - destroy () also shutdowns the ORB
 *        - automatic cleanup in destructor, if necessary
 */
class ECMcastTests_Export EC_Wrapper:
  public virtual POA_RtecEventChannelAdmin::EventChannel,
  public TAO_EC_Deactivated_Object
{
public:
  /// Create a new EC_Wrapper object.
  /// (Constructor access is restricted to insure that all
  /// EC_Wrapper objects are heap-allocated.)
  static PortableServer::Servant_var<EC_Wrapper> create (void);

  /// Destructor.  Destroys the Event Channel implementation.
  virtual ~EC_Wrapper (void);

  /// Create and initialize underlying EC servant.
  int init (CORBA::ORB_ptr orb,
            PortableServer::POA_ptr poa);

  /// RtecEventChannelAdmin::Event_Channel methods.
  //@{
  virtual RtecEventChannelAdmin::ConsumerAdmin_ptr
    for_consumers (void);
  virtual RtecEventChannelAdmin::SupplierAdmin_ptr
    for_suppliers (void);

  /// Destroy the Event Channel, deactivate from POA, and shut down
  /// the ORB.
  virtual void destroy (void);

  virtual RtecEventChannelAdmin::Observer_Handle
    append_observer (RtecEventChannelAdmin::Observer_ptr observer);
  virtual void remove_observer (RtecEventChannelAdmin::Observer_Handle);
  //@}

protected:
  /// Constructor (protected).  Clients can create new
  /// EC_Wrapper objects using the static create() method.
  EC_Wrapper (void);

private:
  /// Helper - destroys Event Channel and deactivate from POA, if
  /// necessary.
  void destroy_ec (void);

  /// Event Channel implementation.
  /*
   * Once Event Channel implementation is made reference-counted, this
   * pointer should turn into a Servant_var.
   */
  TAO_EC_Event_Channel *ec_impl_;

  /// A reference to the ORB, so we can shut it down.
  CORBA::ORB_var orb_;
};

#endif /* EC_WRAPPER_H */