2
// ComponentDef_i.cpp,v 1.11 2003/08/01 03:45:55 parsons Exp
4
#include "Repository_i.h"
5
#include "ComponentDef_i.h"
6
#include "ProvidesDef_i.h"
8
#include "EmitsDef_i.h"
9
#include "PublishesDef_i.h"
10
#include "ConsumesDef_i.h"
11
#include "ExtAttributeDef_i.h"
12
#include "IFR_Service_Utils.h"
14
ACE_RCSID (IFRService,
16
"ComponentDef_i.cpp,v 1.11 2003/08/01 03:45:55 parsons Exp")
21
TAO_Port_Desc_Seq_Utils<CORBA::ComponentIR::UsesDescriptionSeq>::get_is_multiple (
22
CORBA::ComponentIR::UsesDescriptionSeq &desc_seq,
23
ACE_Configuration *config,
24
ACE_Configuration_Section_Key &key,
28
CORBA::ULong is_multiple = 0;
29
config->get_integer_value (key,
32
desc_seq[index].is_multiple =
33
ACE_static_cast (CORBA::Boolean,
40
TAO_Port_Desc_Seq_Utils<CORBA::ComponentIR::EventPortDescriptionSeq>::port_base_type (
41
CORBA::ComponentIR::EventPortDescriptionSeq &desc_seq,
46
desc_seq[index].event = holder.fast_rep ();
52
TAO_Port_Utils<CORBA::ComponentIR::UsesDef>::set_is_multiple (
53
CORBA::Boolean is_multiple,
54
ACE_Configuration *config,
55
ACE_Configuration_Section_Key &key
58
config->set_integer_value (key,
63
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
65
template class TAO_Port_Desc_Seq_Utils<CORBA::ComponentIR::UsesDescriptionSeq>;
66
template class TAO_Port_Desc_Seq_Utils<CORBA::ComponentIR::EventPortDescriptionSeq>;
67
template class TAO_Port_Utils<CORBA::ComponentIR::UsesDef>;
69
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
71
#pragma instantiate TAO_Port_Desc_Seq_Utils<CORBA::ComponentIR::UsesDescriptionSeq>
72
#pragma instantiate TAO_Port_Desc_Seq_Utils<CORBA::ComponentIR::EventPortDescriptionSeq>
73
#pragma instantiate TAO_Port_Utils<CORBA::ComponentIR::UsesDef>
75
#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION*/
77
// ==============================================================
79
TAO_ComponentDef_i::TAO_ComponentDef_i (
80
TAO_Repository_i *repo
82
: TAO_IRObject_i (repo),
83
TAO_Container_i (repo),
84
TAO_Contained_i (repo),
86
TAO_InterfaceDef_i (repo),
87
TAO_InterfaceAttrExtension_i (repo),
88
TAO_ExtInterfaceDef_i (repo)
92
TAO_ComponentDef_i::~TAO_ComponentDef_i (void)
97
TAO_ComponentDef_i::def_kind (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
98
ACE_THROW_SPEC ((CORBA::SystemException))
100
return CORBA::dk_Component;
104
TAO_ComponentDef_i::destroy (ACE_ENV_SINGLE_ARG_DECL)
105
ACE_THROW_SPEC ((CORBA::SystemException))
109
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
112
this->destroy_i (ACE_ENV_SINGLE_ARG_PARAMETER);
116
TAO_ComponentDef_i::destroy_i (ACE_ENV_SINGLE_ARG_DECL)
117
ACE_THROW_SPEC ((CORBA::SystemException))
119
// Destroy our special subsections first, then call destroy_i
120
// on our base class.
122
TAO_IFR_Generic_Utils<TAO_ProvidesDef_i>::destroy_special (
126
ACE_ENV_ARG_PARAMETER
130
TAO_IFR_Generic_Utils<TAO_UsesDef_i>::destroy_special (
134
ACE_ENV_ARG_PARAMETER
138
TAO_IFR_Generic_Utils<TAO_EmitsDef_i>::destroy_special (
142
ACE_ENV_ARG_PARAMETER
146
TAO_IFR_Generic_Utils<TAO_PublishesDef_i>::destroy_special (
150
ACE_ENV_ARG_PARAMETER
154
TAO_IFR_Generic_Utils<TAO_ConsumesDef_i>::destroy_special (
158
ACE_ENV_ARG_PARAMETER
162
this->TAO_ExtInterfaceDef_i::destroy_i (ACE_ENV_SINGLE_ARG_PARAMETER);
165
CORBA::Contained::Description *
166
TAO_ComponentDef_i::describe (ACE_ENV_SINGLE_ARG_DECL)
167
ACE_THROW_SPEC ((CORBA::SystemException))
169
TAO_IFR_READ_GUARD_RETURN (0);
171
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
172
ACE_CHECK_RETURN (0);
174
return this->describe_i (ACE_ENV_SINGLE_ARG_PARAMETER);
177
CORBA::Contained::Description *
178
TAO_ComponentDef_i::describe_i (ACE_ENV_SINGLE_ARG_DECL)
179
ACE_THROW_SPEC ((CORBA::SystemException))
181
CORBA::ComponentIR::ComponentDescription cd;
182
TAO_IFR_Desc_Utils<CORBA::ComponentIR::ComponentDescription,
183
TAO_ComponentDef_i>::fill_desc_begin (
187
ACE_ENV_ARG_PARAMETER
189
ACE_CHECK_RETURN (0);
192
this->repo_->config ()->get_string_value (this->section_key_,
195
cd.base_component = holder.fast_rep ();
197
CORBA::ULong count = 0;
198
ACE_Configuration_Section_Key supports_key;
199
int status = this->repo_->config ()->open_section (this->section_key_,
206
this->repo_->config ()->get_integer_value (supports_key,
211
cd.supported_interfaces.length (count);
212
char *stringified = 0;
215
for (i = 0; i < count; ++i)
217
stringified = TAO_IFR_Service_Utils::int_to_string (i);
218
this->repo_->config ()->get_string_value (supports_key,
222
cd.supported_interfaces[i] = holder.c_str ();
225
TAO_Port_Desc_Seq_Utils<
226
CORBA::ComponentIR::ProvidesDescriptionSeq
227
>::port_descriptions (cd.provided_interfaces,
228
this->repo_->config (),
232
TAO_Port_Desc_Seq_Utils<
233
CORBA::ComponentIR::UsesDescriptionSeq
234
>::port_descriptions (cd.used_interfaces,
235
this->repo_->config (),
239
TAO_Port_Desc_Seq_Utils<
240
CORBA::ComponentIR::EventPortDescriptionSeq
241
>::port_descriptions (cd.emits_events,
242
this->repo_->config (),
246
TAO_Port_Desc_Seq_Utils<
247
CORBA::ComponentIR::EventPortDescriptionSeq
248
>::port_descriptions (cd.publishes_events,
249
this->repo_->config (),
253
TAO_Port_Desc_Seq_Utils<
254
CORBA::ComponentIR::EventPortDescriptionSeq
255
>::port_descriptions (cd.consumes_events,
256
this->repo_->config (),
261
ACE_Configuration_Section_Key attrs_key;
263
this->repo_->config ()->open_section (this->section_key_,
269
this->repo_->config ()->get_integer_value (attrs_key,
274
cd.attributes.length (count);
275
ACE_Configuration_Section_Key attr_key;
277
for (i = 0; i < count; ++i)
279
stringified = TAO_IFR_Service_Utils::int_to_string (i);
280
this->repo_->config ()->get_string_value (attrs_key,
283
this->repo_->config ()->expand_path (this->repo_->root_key (),
287
TAO_ExtAttributeDef_i impl (this->repo_);
288
impl.section_key (attr_key);
289
impl.fill_description (cd.attributes[i]
290
ACE_ENV_ARG_PARAMETER);
291
ACE_CHECK_RETURN (0);
294
cd.type = this->type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
295
ACE_CHECK_RETURN (0);
297
CORBA::Contained::Description *cont_desc_ptr = 0;
298
ACE_NEW_THROW_EX (cont_desc_ptr,
299
CORBA::Contained::Description,
300
CORBA::NO_MEMORY ());
301
ACE_CHECK_RETURN (0);
302
CORBA::Contained::Description_var retval = cont_desc_ptr;
304
cont_desc_ptr->kind = CORBA::dk_Component;
306
cont_desc_ptr->value <<= cd;
307
return retval._retn ();
311
TAO_ComponentDef_i::type (ACE_ENV_SINGLE_ARG_DECL)
312
ACE_THROW_SPEC ((CORBA::SystemException))
314
TAO_IFR_READ_GUARD_RETURN (CORBA::TypeCode::_nil ());
316
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
317
ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
319
return this->type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
323
TAO_ComponentDef_i::type_i (ACE_ENV_SINGLE_ARG_DECL)
324
ACE_THROW_SPEC ((CORBA::SystemException))
327
this->repo_->config ()->get_string_value (this->section_key_,
332
this->repo_->config ()->get_string_value (this->section_key_,
336
return this->repo_->tc_factory ()->create_component_tc (
339
ACE_ENV_ARG_PARAMETER
343
CORBA::InterfaceDefSeq *
344
TAO_ComponentDef_i::supported_interfaces (ACE_ENV_SINGLE_ARG_DECL)
345
ACE_THROW_SPEC ((CORBA::SystemException))
347
TAO_IFR_READ_GUARD_RETURN (0);
349
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
350
ACE_CHECK_RETURN (0);
352
return this->supported_interfaces_i (ACE_ENV_SINGLE_ARG_PARAMETER);
355
CORBA::InterfaceDefSeq *
356
TAO_ComponentDef_i::supported_interfaces_i (ACE_ENV_SINGLE_ARG_DECL)
357
ACE_THROW_SPEC ((CORBA::SystemException))
359
CORBA::InterfaceDefSeq *seq = 0;
361
CORBA::InterfaceDefSeq (0),
363
CORBA::InterfaceDefSeq_var retval = seq;
366
CORBA::ULong count = 0;
367
ACE_Configuration_Section_Key supported_key;
369
this->repo_->config ()->open_section (this->section_key_,
376
this->repo_->config ()->get_integer_value (supported_key,
379
retval->length (count);
380
char *stringified = 0;
382
CORBA::Object_var tmp;
384
for (CORBA::ULong i = 0; i < count; ++i)
386
stringified = TAO_IFR_Service_Utils::int_to_string (i);
387
this->repo_->config ()->get_string_value (supported_key,
391
TAO_IFR_Service_Utils::path_to_ir_object (path,
393
ACE_ENV_ARG_PARAMETER);
394
ACE_CHECK_RETURN (0);
396
retval[i] = CORBA::InterfaceDef::_narrow (tmp.in ()
397
ACE_ENV_ARG_PARAMETER);
398
ACE_CHECK_RETURN (0);
402
return retval._retn ();
406
TAO_ComponentDef_i::supported_interfaces (
407
const CORBA::InterfaceDefSeq &supported_interfaces
410
ACE_THROW_SPEC ((CORBA::SystemException))
414
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
417
this->supported_interfaces_i (supported_interfaces
418
ACE_ENV_ARG_PARAMETER);
422
TAO_ComponentDef_i::supported_interfaces_i (
423
const CORBA::InterfaceDefSeq &supported_interfaces
426
ACE_THROW_SPEC ((CORBA::SystemException))
428
// Remove the old supported interfaces.
429
this->repo_->config ()->remove_section (this->section_key_,
433
CORBA::ULong length = supported_interfaces.length ();
434
ACE_Configuration_Section_Key inherited_key;
435
this->repo_->config ()->open_section (this->section_key_,
440
CORBA::String_var name;
441
char *supported_path = 0;
442
ACE_Configuration_Section_Key supported_key;
444
for (CORBA::ULong i = 0; i < length; ++i)
447
TAO_IFR_Service_Utils::reference_to_path (
448
supported_interfaces[i].in ()
451
// Get the servant's key into the temporary key holder, because
452
// the name clash checker for base interfaces is static, and has
453
// no other way to know about a specific key.
454
this->repo_->config ()->expand_path (this->repo_->root_key (),
456
TAO_IFR_Service_Utils::tmp_key_,
458
TAO_IFR_Service_Utils::name_exists (&TAO_InterfaceDef_i::name_clash,
462
ACE_ENV_ARG_PARAMETER);
465
char *stringified = TAO_IFR_Service_Utils::int_to_string (i);
466
this->repo_->config ()->set_string_value (supported_key,
472
CORBA::ComponentIR::ComponentDef_ptr
473
TAO_ComponentDef_i::base_component (ACE_ENV_SINGLE_ARG_DECL)
474
ACE_THROW_SPEC ((CORBA::SystemException))
476
TAO_IFR_READ_GUARD_RETURN (CORBA::ComponentIR::ComponentDef::_nil ());
478
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
479
ACE_CHECK_RETURN (CORBA::ComponentIR::ComponentDef::_nil ());
481
return this->base_component_i (ACE_ENV_SINGLE_ARG_PARAMETER);
484
CORBA::ComponentIR::ComponentDef_ptr
485
TAO_ComponentDef_i::base_component_i (ACE_ENV_SINGLE_ARG_DECL)
486
ACE_THROW_SPEC ((CORBA::SystemException))
490
this->repo_->config ()->get_string_value (this->section_key_,
496
return CORBA::ComponentIR::ComponentDef::_nil ();
499
CORBA::Contained_var obj = this->repo_->lookup_id (base_id.fast_rep ()
500
ACE_ENV_ARG_PARAMETER);
501
ACE_CHECK_RETURN (CORBA::ComponentIR::ComponentDef::_nil ());
503
return CORBA::ComponentIR::ComponentDef::_narrow (obj.in ()
504
ACE_ENV_ARG_PARAMETER);
508
TAO_ComponentDef_i::base_component (
509
CORBA::ComponentIR::ComponentDef_ptr base_component
512
ACE_THROW_SPEC ((CORBA::SystemException))
516
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
519
this->base_component_i (base_component
520
ACE_ENV_ARG_PARAMETER);
524
TAO_ComponentDef_i::base_component_i (
525
CORBA::ComponentIR::ComponentDef_ptr base_component
528
ACE_THROW_SPEC ((CORBA::SystemException))
530
if (CORBA::is_nil (base_component))
532
this->repo_->config ()->remove_value (this->section_key_,
537
const char *base_path =
538
TAO_IFR_Service_Utils::reference_to_path (base_component);
540
// Get the servant's key into the temporary key holder, because
541
// the name clash checker for base valuetypes is static, and has
542
// no other way to know about a specific key.
543
this->repo_->config ()->expand_path (
544
this->repo_->root_key (),
546
TAO_IFR_Service_Utils::tmp_key_,
549
TAO_IFR_Service_Utils::name_exists (&TAO_ComponentDef_i::name_clash,
553
ACE_ENV_ARG_PARAMETER);
556
this->repo_->config ()->set_string_value (
559
base_component->_interface_repository_id ()
563
CORBA::ComponentIR::ProvidesDef_ptr
564
TAO_ComponentDef_i::create_provides (
568
CORBA::InterfaceDef_ptr interface_type
571
ACE_THROW_SPEC ((CORBA::SystemException))
573
TAO_IFR_WRITE_GUARD_RETURN (CORBA::ComponentIR::ProvidesDef::_nil ());
575
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
576
ACE_CHECK_RETURN (CORBA::ComponentIR::ProvidesDef::_nil ());
578
return this->create_provides_i (id,
582
ACE_ENV_ARG_PARAMETER);
585
CORBA::ComponentIR::ProvidesDef_ptr
586
TAO_ComponentDef_i::create_provides_i (
590
CORBA::InterfaceDef_ptr interface_type
593
ACE_THROW_SPEC ((CORBA::SystemException))
597
CORBA::ComponentIR::ProvidesDef
607
ACE_ENV_ARG_PARAMETER);
610
CORBA::ComponentIR::UsesDef_ptr
611
TAO_ComponentDef_i::create_uses (const char *id,
614
CORBA::InterfaceDef_ptr interface_type,
615
CORBA::Boolean is_multiple
617
ACE_THROW_SPEC ((CORBA::SystemException))
619
TAO_IFR_WRITE_GUARD_RETURN (CORBA::ComponentIR::UsesDef::_nil ());
621
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
622
ACE_CHECK_RETURN (CORBA::ComponentIR::UsesDef::_nil ());
624
return this->create_uses_i (id,
629
ACE_ENV_ARG_PARAMETER);
632
CORBA::ComponentIR::UsesDef_ptr
633
TAO_ComponentDef_i::create_uses_i (const char *id,
636
CORBA::InterfaceDef_ptr interface_type,
637
CORBA::Boolean is_multiple
639
ACE_THROW_SPEC ((CORBA::SystemException))
643
CORBA::ComponentIR::UsesDef
653
ACE_ENV_ARG_PARAMETER);
656
CORBA::ComponentIR::EmitsDef_ptr
657
TAO_ComponentDef_i::create_emits (const char *id,
660
CORBA::ValueDef_ptr value
662
ACE_THROW_SPEC ((CORBA::SystemException))
664
TAO_IFR_WRITE_GUARD_RETURN (CORBA::ComponentIR::EmitsDef::_nil ());
666
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
667
ACE_CHECK_RETURN (CORBA::ComponentIR::EmitsDef::_nil ());
669
return this->create_emits_i (id,
673
ACE_ENV_ARG_PARAMETER);
676
CORBA::ComponentIR::EmitsDef_ptr
677
TAO_ComponentDef_i::create_emits_i (const char *id,
680
CORBA::ValueDef_ptr value
682
ACE_THROW_SPEC ((CORBA::SystemException))
686
CORBA::ComponentIR::EmitsDef
696
ACE_ENV_ARG_PARAMETER);
699
CORBA::ComponentIR::PublishesDef_ptr
700
TAO_ComponentDef_i::create_publishes (const char *id,
703
CORBA::ValueDef_ptr value
705
ACE_THROW_SPEC ((CORBA::SystemException))
707
TAO_IFR_WRITE_GUARD_RETURN (CORBA::ComponentIR::PublishesDef::_nil ());
709
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
710
ACE_CHECK_RETURN (CORBA::ComponentIR::PublishesDef::_nil ());
712
return this->create_publishes_i (id,
716
ACE_ENV_ARG_PARAMETER);
719
CORBA::ComponentIR::PublishesDef_ptr
720
TAO_ComponentDef_i::create_publishes_i (const char *id,
723
CORBA::ValueDef_ptr value
725
ACE_THROW_SPEC ((CORBA::SystemException))
729
CORBA::ComponentIR::PublishesDef
739
ACE_ENV_ARG_PARAMETER);
742
CORBA::ComponentIR::ConsumesDef_ptr
743
TAO_ComponentDef_i::create_consumes (const char *id,
746
CORBA::ValueDef_ptr value
748
ACE_THROW_SPEC ((CORBA::SystemException))
750
TAO_IFR_WRITE_GUARD_RETURN (CORBA::ComponentIR::ConsumesDef::_nil ());
752
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
753
ACE_CHECK_RETURN (CORBA::ComponentIR::ConsumesDef::_nil ());
755
return this->create_consumes_i (id,
759
ACE_ENV_ARG_PARAMETER);
762
CORBA::ComponentIR::ConsumesDef_ptr
763
TAO_ComponentDef_i::create_consumes_i (const char *id,
766
CORBA::ValueDef_ptr value
768
ACE_THROW_SPEC ((CORBA::SystemException))
772
CORBA::ComponentIR::ConsumesDef
782
ACE_ENV_ARG_PARAMETER);
786
TAO_ComponentDef_i::name_clash (const char *name)
790
TAO_Container_i::tmp_name_holder_ = name;
791
TAO_IFR_Service_Utils::name_exists (&TAO_Container_i::same_as_tmp_name,
792
TAO_IFR_Service_Utils::tmp_key_,
793
TAO_IFR_Service_Utils::repo_,
795
ACE_ENV_ARG_PARAMETER);