summaryrefslogtreecommitdiff
path: root/TAO/tests/NestedUpcall/MT_Client_Test/client.h
blob: 9f7bc2f1d3f123d8e360066895a4424564283b11 (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

//=============================================================================
/**
 *  @file    client.h
 *
 *  Test for multithreaded client using one global ORB (and Reactor)
 *
 *  @author Michael Kircher
 */
//=============================================================================

#ifndef MT_CLIENT_H
#define MT_CLIENT_H

#include "ace/Get_Opt.h"

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

#include "ace/Task.h"
#include "ace/Thread_Manager.h"
#include "tao/ORB.h"
#include "MT_Client_TestC.h"

/**
 * @class MT_Client
 *
 * @brief A simple client talking to one server
 *
 * It is connecting to a server which holds the Object_A
 * or using the "-m" switch to a server holding the MT_Object
 */
class MT_Client
{

public:
  /// = Constructor and destructor.
  MT_Client (void);
  ~MT_Client (void);

  /// Execute client example code.
  int run (void);

  /// Initialize the client communication endpoint with server.
  int init (int argc,
            ACE_TCHAR **argv,
            int client_number);

private:
  /// reading the IOR of object A in
  int read_ior (ACE_TCHAR *filename);

  /// Parses the arguments passed on the command line.
  int parse_args (void);

  /// # of arguments on the command line.
  int argc_;

  /// arguments from command line.
  ACE_TCHAR **argv_;

  /// Key of the object
  char *object_key_;

  /// Flag to tell server to shutdown.
  int shutdown_;

  /// Remember our orb.
  CORBA::ORB_var orb_var_;

  /// pointer to the mt Object
  MT_Object_var mT_Object_var_;

  /// This is used to choose the server...
  int client_number_;

  /// number of loops
  unsigned long iterations_;

};

/**
 * @class MT_Client_Task
 *
 * @brief Wrapper for the MT_Client to be an extra thread
 *
 * No big purpose, just wrapping
 */
class MT_Client_Task : public ACE_Task<ACE_SYNCH>
{
public:
  MT_Client_Task (int argc, ACE_TCHAR **argv, int client_number);

  virtual int svc ();

private:
  MT_Client mT_Client_;
  int argc_;
  ACE_TCHAR **argv_;

  /// To determine if we use the first or the second server.
  int client_number_;
};

#endif /* MT_CLIENT_H */