summaryrefslogtreecommitdiff
path: root/docs/tutorials/Quoter/RTCORBA/Broker_i.h
blob: 9b840d93e781ec0a457faf9d60ecfcde95ca5f84 (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
// $Id$

/**
 * @file Broker_i.h
 * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu>
 * @author William R. Otte <wotte@dre.vanderbilt.edu>
 * @author Douglas C. Schmidt <schmidt@dre.vanderbilt.edu>
 */

#ifndef BROKERI_H_
#define BROKERI_H_

// local headers
#include "StockNameConsumer_i.h"
#include "BrokerS.h"
#include "DistributorC.h"

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

/**
 * @class Stock_StockBroker_i
 * @brief This class defined the Stock Broker client.
 */
class  Stock_StockBroker_i
  : public virtual POA_Stock::StockBroker
{
public:
  /**
   * Constructor.
   *
   * @param orb
   * @param stock_name The name of the stock that the Stock Broker client is interested in.
   * @param priority The CORBA priority of this Stock Broker client.
   */
  Stock_StockBroker_i (CORBA::ORB_ptr orb,
                       Stock::StockDistributor_ptr dist,
                       const char *stock_name);

  /// Destructor
  virtual ~Stock_StockBroker_i (void);

  /**
   * Return the StockNameConsumer object created by the Constructor.
   *
   * @return Returns a StockNameConsumer object reference.
   */
  virtual ::Stock::StockNameConsumer_ptr get_consumer_notifier ();

  /**
   * Duplicate a StockQuoter object using the StockQuoter object reference "c" in the argument.
   *
   * @param c A StockQuoter object reference.
   */
  virtual void connect_quoter_info (::Stock::StockQuoter_ptr c);

  /**
   * Destroy the StockQuoter object and return it.
   *
   * @return Returns the destroyed StockQuoter object reference.
   */
  virtual ::Stock::StockQuoter_ptr disconnect_quoter_info ();

  /**
   * Return the StockQuoter object.
   *
   * @return Returns the StockQuoter object reference that has been
   *         created by connect_quoter_info ().
   */
  virtual ::Stock::StockQuoter_ptr get_connection_quoter_info ();

  /**
   * Shutdown the object and destroy the application.
   */
  virtual void shutdown ();

private:
  // Cached ORB pointer
  CORBA::ORB_var orb_;

  /// A StockQuoter object reference that is used to get detailed
  /// stock information.
  Stock::StockQuoter_var quoter_;

  /// A StockNameConsumer servant that is used to get notification of
  /// updates.
  Stock_StockNameConsumer_i *consumer_;

  /// The distributor that we are registered with, useful for shutdown.
  Stock::StockDistributor_var distributor_;
};

/**
 * @class Stock_StockBrokerHome_i
 * @brief This class defined the Stock Broker home.
 */
class  Stock_StockBrokerHome_i
  : public virtual POA_Stock::StockBrokerHome,
    public ACE_Event_Handler
{
public:
  /**
   * Constructor.
   * Register the necessary factories and mappings with the specified orb and
   * Create a new instance of the StockBroker object.
   *
   * @param orb
   */
  Stock_StockBrokerHome_i (CORBA::ORB_ptr orb);

  /// Destructor
  virtual ~Stock_StockBrokerHome_i (void);

  /**
   * Return the StockBroker object created by the Constructor.
   *
   * @return The StockBroker object created by the Constructor.
   */
  virtual ::Stock::StockBroker_ptr create (Stock::StockDistributor_ptr dist,
                                           const char *stock_name);

  virtual int handle_signal (int signum,
                             siginfo_t * = 0,
                             ucontext_t * = 0);

private:
  /// The StockDistributor object created by its home.
  Stock::StockBroker_var broker_;

  /// Cache a reference to the ORB.
  CORBA::ORB_var orb_;
};

#endif /* BROKERI_H_  */