summaryrefslogtreecommitdiff
path: root/TAO/examples/Simulator/Event_Supplier/DOVE_Supplier.h
blob: 7c5a3c3a5a85e5cbf28955f54951903830163942 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

//=============================================================================
/**
 *  @file    DOVE_Supplier.h
 *
 *  A wrapper around the event service initialization and marshalling.
 *
 *
 *  @author Michael Kircher (mk1@cs.wustl.edu) Chris Gill (cdgill@cs.wustl.edu)
 */
//=============================================================================


#include "orbsvcs/RtecEventChannelAdminC.h"

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

#include "orbsvcs/RtecEventCommS.h"
#include "orbsvcs/Event_Utilities.h"
#include "orbsvcs/Event_Service_Constants.h"
#include "orbsvcs/Scheduler_Factory.h"


#ifndef DOVE_SUPPLIER_H
#define DOVE_SUPPLIER_H

#define SOURCE_ID 123

class DOVE_Supplier
{
public:

  /// Constructor.
  DOVE_Supplier ();

  /// Destructor.
  ~DOVE_Supplier (void);

  /// Initialize the ORB and the connection to the Name Service
  int init (void);

  /// Connect to the event service.
  int connect (const char * MIB_name = 0,
               const char* es_name = 0,
               const char * ss_name = 0,
               ACE_Scheduler_Factory::POD_RT_Info * pod_rt_info = 0);

  /// Perform all post-connection-establishment processing.
  void connected ();

  /// Disconnect from the event service.
  void disconnect ();

  /// Notify the consumer proxy that we have events
  void notify (CORBA::Any& message);

  /// Use the next connection in the list of established connections.
  void use_next_connection ();

  /// Use the previous connection in the list of established connections.
  void use_prev_connection ();

private:

  // The following Supplier is needed because DOVE_Supplier has not
  // inherited from PushSupplier.

  class Internal_DOVE_Supplier : public POA_RtecEventComm::PushSupplier
  {
    friend class DOVE_Supplier;

  public:

    virtual void disconnect_push_supplier (void)
    {
    }

  private:

    Internal_DOVE_Supplier (DOVE_Supplier* impl_ptr);

    DOVE_Supplier* impl_ptr_;
  };

private:

  struct Connection_Params
  {
    const char * es_name_;
    const char * ss_name_;
    RtecEventChannelAdmin::EventChannel_var eventChannel_var_;
    RtecEventChannelAdmin::SupplierAdmin_var supplierAdmin_var_;
    RtecEventChannelAdmin::ProxyPushConsumer_var proxyPushConsumer_var_;
    RtecScheduler::Scheduler_var scheduler_var_;
    RtecScheduler::handle_t rt_info_;
    ACE_Scheduler_Factory::POD_RT_Info pod_rt_info_;
  };

  /// Get the event channel reference.
  int get_EventChannel ();

  /// Get the scheduler reference.
  int get_Scheduler ();

  /// Connect the the supplier with the event channel.
  int connect_Supplier ();

  /// Access the default rt_info singleton.
  static ACE_Scheduler_Factory::POD_RT_Info * pod_rt_info_instance ();

  static ACE_Scheduler_Factory::POD_RT_Info * pod_rt_info_instance_;

  // Object initialization flags
  int initialized_;
  int connected_;

  Connection_Params ** connection_params_list_;
  Connection_Params * current_connection_params_;
  int connection_count_;
  int current_connection_index_;

  // = ORB, ORB Services adminstration references.
  CosNaming::NamingContext_var namingContext_var_;
  PortableServer::POA_var root_POA_var_;
  PortableServer::POAManager_var poa_manager_;

  Internal_DOVE_Supplier* internal_DOVE_Supplier_ptr_;

  /// Keep the name of the MIB around.
  const char * MIB_name_;
};

#endif /* DOVE_SUPPLIER_H */