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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
|
// -*- C++ -*-
//=============================================================================
/**
* @file ORB.h
*
* $Id$
*
* Header file for CORBA's ORB type.
*
* @author DOC Center - Washington University at St. Louis
* @author DOC Group - Vanderbilt University
* @author DOC Laboratory - University of California at Irvine
*/
//=============================================================================
#ifndef TAO_ORB_H
#define TAO_ORB_H
#include /**/ "ace/pre.h"
#include "UserException.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "orb_typesC.h"
#include "objectid.h"
#include "Policy_ForwardC.h"
#include "CORBA_methods.h"
#include "VarOut_T.h"
#include "ace/Thread_Mutex.h"
#include "ace/Guard_T.h"
typedef enum
{
TAO_SERVICEID_NAMESERVICE,
TAO_SERVICEID_TRADINGSERVICE,
TAO_SERVICEID_IMPLREPOSERVICE,
TAO_SERVICEID_INTERFACEREPOSERVICE,
TAO_SERVICEID_MCASTSERVER
} TAO_Service_ID;
/// Forward declarations.
class TAO_MProfile;
class TAO_Client_Strategy_Factory;
class TAO_Server_Strategy_Factory;
class TAO_InputCDR;
class TAO_OutputCDR;
class TAO_Stub;
class TAO_Valuetype_Adapter;
class TAO_Acceptor_Filter;
class TAO_SeqElem_String_Manager;
// ****************************************************************
namespace CORBA
{
class EnumMemberSeq;
class StructMemberSeq;
class UnionMemberSeq;
class ValueMemberSeq;
class ORB_ObjectIdList;
class ExceptionList;
typedef ExceptionList * ExceptionList_ptr;
class ContextList;
typedef ContextList * ContextList_ptr;
class Context;
typedef Context * Context_ptr;
// TODO - implement OMG's 'ORBid CORBA::ORB::id (void)'.
typedef
TAO_MngSeq_Var_T<
ORB_ObjectIdList,
TAO_SeqElem_String_Manager
>
ORB_ObjectIdList_var;
typedef
TAO_MngSeq_Out_T<
ORB_ObjectIdList,
ORB_ObjectIdList_var,
TAO_SeqElem_String_Manager
>
ORB_ObjectIdList_out;
struct ServiceInformation;
typedef
TAO_Var_Var_T<
ServiceInformation
>
ServiceInformation_var;
typedef
TAO_Out_T<
ServiceInformation,
ServiceInformation_var
>
ServiceInformation_out;
class ValueFactoryBase;
typedef ValueFactoryBase *ValueFactory;
typedef UShort ServiceType;
class Request;
typedef Request * Request_ptr;
typedef TAO_Pseudo_Var_T<Request> Request_var;
typedef TAO_Pseudo_Out_T<Request, Request_var> Request_out;
class ORB;
typedef ORB * ORB_ptr;
typedef TAO_Pseudo_Var_T<ORB> ORB_var;
typedef TAO_Pseudo_Out_T<ORB, ORB_var> ORB_out;
typedef CORBA::Short ValueModifier;
/**
* @class ORB
*
* @brief ORB pseudo-object.
*
* The "ORB" pseudo-object is used in bootstrapping, such as to
* create object references from strings. This class is intended
* to be inherited by others, which will provide some more of the
* CORBA support. Implementations of this "CORBA::ORB" class must
* know how to create stringify/destringify their objrefs, as well
* as how to marshal and unmarshal them.
*/
class TAO_Export ORB
{
public:
class TAO_Export InvalidName : public CORBA::UserException
{
public:
InvalidName (void);
InvalidName (const InvalidName &);
~InvalidName (void);
InvalidName &operator= (const InvalidName &);
static InvalidName *_downcast (CORBA::Exception *);
static CORBA::Exception *_alloc (void);
virtual CORBA::Exception *_tao_duplicate (void) const;
virtual void _raise (void) const;
virtual void _tao_encode (TAO_OutputCDR &
ACE_ENV_ARG_DECL) const;
virtual void _tao_decode (TAO_InputCDR &
ACE_ENV_ARG_DECL);
};
typedef char *ObjectId;
typedef CORBA::String_var ObjectId_var;
typedef CORBA::String_out ObjectId_out;
static CORBA::TypeCode_ptr const _tc_ObjectId;
typedef CORBA::ORB_ObjectIdList ObjectIdList;
typedef CORBA::ORB_ObjectIdList_var ObjectIdList_var;
typedef CORBA::ORB_ObjectIdList_out ObjectIdList_out;
typedef CORBA::ORB_ObjectIdList *ObjectIdList_ptr;
static CORBA::TypeCode_ptr const _tc_ObjectIdList;
/// Return a duplicate of @c orb.
/**
* When work with this duplicate is complete, it should be freed
* up using CORBA::release().
*/
static CORBA::ORB_ptr _duplicate (CORBA::ORB_ptr orb);
/// Returns a pointer to a nil ORB, i.e., an non-existent ORB. This
/// can be used for initialization or in comparisons.
static CORBA::ORB_ptr _nil (void);
/// Return this ORB's ORBid.
char * id (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
/**
* Turn a string-ified object reference back into an object
* pointer. Typically these strings are created using
* object_to_string(), but not necessarily locally.
*/
CORBA::Object_ptr string_to_object (const char *str
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
/**
* Turn an object reference into a string. Each type of ORB,
* e.g. an IIOP ORB, must implement this. This can be used by
* servers to publish their whereabouts to clients. The output of
* this is typically eventually given to @c string_to_object() as
* an argument.
*/
char * object_to_string (CORBA::Object_ptr obj
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
// Value factory operations (CORBA 2.3 ptc/98-10-05 Ch. 4.2 p.4-7)
CORBA::ValueFactory register_value_factory (
const char *repository_id,
CORBA::ValueFactory factory
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void unregister_value_factory (const char * repository_id
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::ValueFactory lookup_value_factory (
const char *repository_id
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
#if (TAO_HAS_MINIMUM_CORBA == 0)
// Typedefs for CORBA::ORB::RequestSeq, which is an argument of
// send_multiple_requests_*().
typedef
TAO_Unbounded_Pseudo_Sequence<
CORBA::Request
>
RequestSeq;
typedef
TAO_VarSeq_Var_T<
RequestSeq,
TAO_Pseudo_Object_Manager<
CORBA::Request
>
>
RequestSeq_var;
typedef
TAO_Seq_Out_T<
RequestSeq,
RequestSeq_var,
TAO_Pseudo_Object_Manager<
CORBA::Request
>
>
RequestSeq_out;
void create_list (CORBA::Long count,
CORBA::NVList_ptr &new_list
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void create_operation_list(CORBA::OperationDef_ptr,
CORBA::NVList_ptr&
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void create_named_value (CORBA::NamedValue_ptr &nmval
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void create_exception_list (CORBA::ExceptionList_ptr &exclist
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void create_environment (CORBA::Environment_ptr &new_env
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
// The following are not implemented and just throw
// CORBA::NO_IMPLEMENT.
void create_context_list (CORBA::ContextList_ptr &ctxtlist
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void get_default_context (CORBA::Context_ptr &ctx
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::Boolean get_service_information (
CORBA::ServiceType service_type,
CORBA::ServiceInformation_out service_information
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void send_multiple_requests_oneway (const CORBA::ORB::RequestSeq &req
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void send_multiple_requests_deferred (const CORBA::ORB::RequestSeq &req
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void get_next_response (CORBA::Request_ptr &req
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::Boolean poll_next_response (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
/// The ORB TypeCode creation functions.
CORBA::TypeCode_ptr create_struct_tc (
const char *id,
const char *name,
const CORBA::StructMemberSeq &members
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_union_tc (
const char *id,
const char *name,
CORBA::TypeCode_ptr discriminator_type,
const CORBA::UnionMemberSeq &members
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_enum_tc (
const char *id,
const char *name,
const CORBA::EnumMemberSeq &members
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_alias_tc (
const char *id,
const char *name,
CORBA::TypeCode_ptr original_type
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_exception_tc (
const char *id,
const char *name,
const CORBA::StructMemberSeq &members
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_interface_tc (
const char *id,
const char *name
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_string_tc (
CORBA::ULong bound
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_wstring_tc (
CORBA::ULong bound
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_fixed_tc (
CORBA::UShort digits,
CORBA::UShort scale
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_sequence_tc (
CORBA::ULong bound,
CORBA::TypeCode_ptr element_type
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_array_tc (
CORBA::ULong length,
CORBA::TypeCode_ptr element_type
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_value_tc (
const char *id,
const char *name,
CORBA::ValueModifier type_modifier,
CORBA::TypeCode_ptr concrete_base,
const CORBA::ValueMemberSeq &members
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_value_box_tc (
const char *id,
const char *name,
CORBA::TypeCode_ptr boxed_type
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_native_tc (
const char *id,
const char *name
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_recursive_tc (
const char *id
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_abstract_interface_tc (
const char *id,
const char *name
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_local_interface_tc (
const char *id,
const char *name
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_component_tc (
const char *id,
const char *name
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
CORBA::TypeCode_ptr create_home_tc (
const char *id,
const char *name
ACE_ENV_ARG_DECL_WITH_DEFAULTS
);
CORBA::TypeCode_ptr create_event_tc (
const char *id,
const char *name,
CORBA::ValueModifier type_modifier,
CORBA::TypeCode_ptr concrete_base,
const CORBA::ValueMemberSeq &members
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
#endif /* TAO_HAS_MINIMUM_CORBA */
// = ORB event loop methods.
/**
* Instructs the ORB to initialize itself and run its event loop in
* the current thread, not returning until the ORB has shut down.
* If an error occurs during initialization or at runtime, a CORBA
* system exception will be thrown.
*/
void run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
/**
* Instructs the ORB to initialize itself and run its event loop in
* the current thread, not returning until the ORB has shut down or
* the time value specified through @a tv has expired. If an
* error occurs during initialization or at runtime, a CORBA
* system exception will be thrown. @a tv is reduced by the
* amount of time spent in this call.
*
* If this function is called with a @ tv value, client threads
* making invocations will continue their operations. When the
* operation timesout and returns, any invocations showing up on
* the server will be buffered by TCP.
**/
void run (ACE_Time_Value &tv
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
/**
* Instructs the ORB to initialize itself and run its event loop in
* the current thread, not returning until the ORB has shut down or
* the time value specified through @a tv has expired. If an error
* occurs during initialization or at runtime, a CORBA system
* exception will be thrown. @a tv is reduced by the amount of time
* spent in this call. If @a tv is 0, it means that the timeout
* is infinite. If @a tv is @c ACE_Time_Value::zero, it specifies
* to poll and does not block.
*
* If this function is called with @a tv value, client threads
* making invocations will continue their operations. When the
* operation timesout and returns, any invocations showing up on
* the server will be buffered by TCP.
**/
void run (ACE_Time_Value *tv
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
/// Returns an indication of whether the ORB needs to perform some
/// work.
CORBA::Boolean work_pending (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
/// Returns an indication of whether the ORB needs to perform some
/// work but will look for work pending for no more than the
/// specified time.
/**
* @note This is useful for implementing an event loop with an
* idle timeout.
*/
CORBA::Boolean work_pending (ACE_Time_Value &tv
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
/**
* This operation performs an implementation-defined unit of work.
* Note that the default behavior is to block if the unit of work
* is not present; this behavior can be modified by passing an
* appropriate @c ACE_Time_Value as described in run().
**/
void perform_work (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
void perform_work (ACE_Time_Value &
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
void perform_work (ACE_Time_Value *
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
/**
* This operation instructs the ORB to shut down. Shutting down the
* ORB causes all Object Adapters to be shut down. If
* @c wait_for_completion parameter is TRUE, this operation blocks
* until all ORB processing (including request processing and object
* deactivation or other operations associated with object adapters)
* has completed.
*/
void shutdown (CORBA::Boolean wait_for_completion = 0
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
/**
* Explicitly destroy the ORB, releasing any resources. Note that
* TAO *cannot* implicitly release the resources even if you have
* destroyed all the references to a particular ORB since
* CORBA::ORB_init() is required to return the same pointer if
* called with the same ORBid, only after ORB::destroy() is called
* it may return a new one.
*
* The results of multi-threaded applications, trying to destroy ()
* the ORB in one thread and trying to service a request in another
* thread are not well defined. TAO does not support such cases.
*/
void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
CORBA::Object_ptr resolve_initial_references (
const char *name
ACE_ENV_ARG_DECL_WITH_DEFAULTS
);
/**
* This method acts as a mini-bootstrapping Naming Service, which is
* provided by the ORB for certain well-known object references. TAO
* supports the "NameService", "TradingService", "RootPOA",
* "ImplRepo", and "POACurrent" via this method. The @c timeout
* value bounds the amount of time the ORB blocks waiting to
* resolve the service. This is most useful for bootstrapping
* remote services, such as the "NameService" or "TradingService",
* that are commonly resolved via multicast. By default, the
* value is 0, which means "use the @c
* TAO_DEFAULT_SERVICE_RESOLUTION_TIMEOUT timeout period".
*
* @note By using a default value for the @c timeout parameter,
* TAO will remains compliant with the CORBA
* resolve_initial_references() specification.
*/
CORBA::Object_ptr resolve_initial_references (
const char *name,
ACE_Time_Value *timeout
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
/// Register an object reference with the ORB.
void register_initial_reference (const char * id,
CORBA::Object_ptr obj
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
/// Returns a sequence of ObjectIds that lists which objects have
/// references available via the initial references mechanism.
CORBA::ORB::ObjectIdList_ptr list_initial_services (
ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
CORBA::Policy_ptr create_policy (CORBA::PolicyType type,
const CORBA::Any& val
ACE_ENV_ARG_DECL_WITH_DEFAULTS);
// ----------------------------------------------------------------
// = TAO-specific extensions to the CORBA specification.
// ----------------------------------------------------------------
/// Create an empty policy, usually to be filled in later by
/// demarshaling.
CORBA::Policy_ptr _create_policy (CORBA::PolicyType type
ACE_ENV_ARG_DECL);
/// Resolve the POA.
CORBA::Object_ptr resolve_root_poa (ACE_ENV_SINGLE_ARG_DECL);
// Reference counting...
CORBA::ULong _incr_refcnt (void);
CORBA::ULong _decr_refcnt (void);
/// Set the IOR flag.
void _use_omg_ior_format (CORBA::Boolean ior);
/// Get the IOR flag.
CORBA::Boolean _use_omg_ior_format (void);
/// Get the ORB core.
TAO_ORB_Core *orb_core (void) const;
/**
* TAO specific extension to get and set the client ID. The client
* id can be set by the application which would be used by the FT
* service. As there are no specific interfaces defined in the
* spec, we have this proprietary extension.
*/
const ACE_CString &_tao_ft_client_id (void);
void _tao_ft_client_id (const char *id);
/// Factory method that creates an ORB.
static CORBA::ORB_ptr _tao_make_ORB (TAO_ORB_Core * orb_core);
// Useful for template programming.
typedef ORB_ptr _ptr_type;
typedef ORB_var _var_type;
/// Get the Timeout value
ACE_Time_Value *get_timeout (void);
protected:
// We must be created via the @c CORBA::ORB_init() function.
ORB (TAO_ORB_Core *orb_core);
/// Destructor
/**
* Protected destructor to enforce proper memory management
* through the reference counting mechanism.
*/
~ORB (void);
/// Resolve the POA current.
CORBA::Object_ptr resolve_poa_current (ACE_ENV_SINGLE_ARG_DECL);
/// Resolve the Policy Manager for this ORB.
CORBA::Object_ptr resolve_policy_manager (void);
/// Resolve the Policy Current for this thread.
CORBA::Object_ptr resolve_policy_current (void);
private:
/// Resolve the given service based on the service ID.
CORBA::Object_ptr resolve_service (TAO_MCAST_SERVICEID service_id
ACE_ENV_ARG_DECL);
/// Convert an OMG IOR into an object reference.
CORBA::Object_ptr ior_string_to_object (const char* ior
ACE_ENV_ARG_DECL);
/// Convert an URL style IOR into an object reference.
CORBA::Object_ptr url_ior_string_to_object (const char* ior
ACE_ENV_ARG_DECL);
/// Check if ORB has shutdown. If it has, throw the appropriate
/// exception.
void check_shutdown (ACE_ENV_SINGLE_ARG_DECL);
/// Set the timeout value
void set_timeout (ACE_Time_Value * timeout);
private:
/// lock required for mutual exclusion between multiple threads.
TAO_SYNCH_MUTEX lock_;
/// Maintains a reference count of number of instantiations of the
/// ORB.
CORBA::ULong refcount_;
/// The ORB_Core that created us....
TAO_ORB_Core *orb_core_;
/// Decides whether to use the URL notation or to use IOR notation.
CORBA::Boolean use_omg_ior_format_;
// Prevent copying and assignment.
ORB (const ORB &);
ORB &operator= (const ORB &);
/// Timeout value
ACE_Time_Value * timeout_;
};
} // End namespace CORBA
namespace TAO
{
namespace ORB
{
/// Initialize the ORB globals correctly, i.e., only when they
/// haven't been initialized yet.
void init_orb_globals (ACE_ENV_SINGLE_ARG_DECL);
}
}
#if defined (__ACE_INLINE__)
# include "tao/ORB.i"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* TAO_ORB_H */
|