summaryrefslogtreecommitdiff
path: root/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Client.h
blob: 98fec1ba102b2e09a2bd6993343efcb508476aee (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// -*- c++ -*-
// $Id$

// ============================================================================
//
// = LIBRARY
//    TAO/tests/IDL_Cubit
//
// = FILENAME
//    Cubit_Client.h
//
// = DESCRIPTION
//      This class implements a simple "cube" CORBA client for the Cubit
//      example using stubs generated by the TAO ORB IDL compiler.
//
// = AUTHORS
//    Aniruddha Gokhale, Sumedh Mungee, and Sergio Flores-Gaitan
//
// ============================================================================

#ifndef _CUBIT_CLIENT_H
#define _CUBIT_CLIENT_H

#include "ace/Get_Opt.h"

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

#include "ace/Profile_Timer.h"
#include "tao/corba.h"
#include "cubitC.h"

class Cubit_Client
{
  // = TITLE
  //    Defines a class that encapsulates behaviour of the Cubit client
  //    example.  Provides a better understanding of the logic in an
  //    object oriented way.
  //
  // = DESCRIPTION
  //    This class declares an interface to run the example client for
  //    Cubit CORBA server.  All the complexity for initializing the
  //    server is hidden in the class.  Just the run() interface is needed.
public:
  // = Constructor and destructor.
  Cubit_Client (int shutdown = 0);

  ~Cubit_Client (void);

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

  int init (int argc, char **argv);
  // Initialize the client communication endpoint with server.
  // <collocation_test_ior> is used to pass in the ior file name.

private:
  int func (u_int i);
  // Simple function that returns the substraction of 117 from the
  // parameter.

  int read_ior (const char *filename);
  // Function to read the cubit factory ior from a file.

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

  unsigned int opt_to_mask (const char *optarg);
  // Obtain the bit mask representation of the specified test

  void enable_test (unsigned int mask);
  // Enable the specified test.

  void disable_test (unsigned int mask);
  // Disable the specified test.

  int check_enabled (unsigned int mask) const;
  // Check if the specified test has been enabled.

  void print_stats (const char *call_name,
                    ACE_Profile_Timer::ACE_Elapsed_Time &elapsed_time);
  // Prints the time stats.

  void cube_union (CORBA::Environment &ACE_TRY_ENV);
  // Exercise the union.  Cube a union.

  void cube_struct (int i,
                    CORBA::Environment &ACE_TRY_ENV);
  // calculate the cube from a struct.

  void cube_long (int i,
                  CORBA::Environment &ACE_TRY_ENV);
  // calculate the cube from a long.

  void cube_oneway (int i,
                    CORBA::Environment &ACE_TRY_ENV);
  // Oneway operation test.

  void cube_void (int i,
                  CORBA::Environment &ACE_TRY_ENV);
  // Twoway operation test.

  void cube_octet (int i,
                   CORBA::Environment &ACE_TRY_ENV);
  // Cube an octet.

  void cube_short (int i,
                   CORBA::Environment &ACE_TRY_ENV);
  // Cube a short.

  void cube_long_sequence (int i, int l,
                           CORBA::Environment &ACE_TRY_ENV);
  // Cube a sequence <l> is the length of the sequence.

  void cube_octet_sequence (int i, int l,
                            CORBA::Environment &ACE_TRY_ENV);
  // Cube a sequence of octets, <l> is the length of the sequence.

  void cube_many_sequence (int i, int l,
                           CORBA::Environment &ACE_TRY_ENV);
  // Cube a sequence of manys, <l> is the length of the sequence.

  void cube_rti_data (int i, int numUpdates, int numAttrs,
                      CORBA::Environment &ACE_TRY_ENV);
  // Cube a sequence <l> is the length of the sequence.

  int shutdown_server (int do_shutdown,
                       CORBA::Environment &ACE_TRY_ENV);
  // Invoke the method with <do_shutdown> != 0 to shutdown the server.

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

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

  char *cubit_factory_key_;
  // Key of factory obj ref.

  u_int loop_count_;
  // Number of times to do the cube operations.

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

  CORBA::ORB_var orb_;
  // Remember our orb, must show up before the other objects to
  // shutdown in the proper order.

  Cubit_Factory_var factory_;
  // factory pointer for cubit.

  Cubit_var cubit_;
  // Cubit obj ref.

  u_int call_count_;
  // # of calls made to functions.

  u_int error_count_;
  // # of errors incurred in the lifetime of the application.

  FILE *cubit_factory_ior_file_;
  // File from which to obtain the IOR.

  ACE_HANDLE f_handle_;
  // File handle to read the IOR.

  unsigned int bytes_in_octet_sequence_;
  // The number of bytes to send in the octet sequence test.

  unsigned int test_enable_bitset_;
  // Bitset that determines which tests get run.

  unsigned int test_disable_bitset_;
  // Bitset that determines which tests do not get run.
};

#endif /* _CUBIT_CLIENT_H */