1 #include "tao/PI/PICurrent.h"
3 #if TAO_HAS_INTERCEPTORS == 1
5 #if !defined (__ACE_INLINE__)
6 # include "tao/PI/PICurrent.inl"
7 #endif /* __ACE_INLINE__ */
9 #include "tao/PI/PICurrent_Impl.h"
10 #include "tao/ORB_Core.h"
11 #include "tao/TAO_Server_Request.h"
12 #include "ace/CORBA_macros.h"
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
16 TAO::PICurrent::PICurrent (TAO_ORB_Core
&orb_core
)
17 : orb_core_ (orb_core
),
18 tss_slot_ (0), // Call initialize() before use.
19 slot_count_ (0) // Call initialize() before use.
24 TAO::PICurrent::get_slot (PortableInterceptor::SlotId identifier
)
26 this->check_validity (identifier
);
28 return this->tsc ()->get_slot (identifier
);
32 TAO::PICurrent::set_slot (PortableInterceptor::SlotId identifier
,
33 const CORBA::Any
&data
)
35 this->check_validity (identifier
);
37 this->tsc ()->set_slot (identifier
, data
);
42 extern "C" void CleanUpPICurrent(void *object
, void *)
44 delete static_cast<TAO::PICurrent_Impl
*> (object
);
49 TAO::PICurrent::tsc ()
51 TAO::PICurrent_Impl
*impl
=
52 static_cast<TAO::PICurrent_Impl
*> (
53 this->orb_core_
.get_tss_resource (this->tss_slot_
));
55 // If this TSS has not yet been set-up, give it it's own PICurrent_Impl.
58 ACE_NEW_THROW_EX (impl
,
59 TAO::PICurrent_Impl (&this->orb_core_
, this->tss_slot_
),
61 CORBA::SystemException::_tao_minor_code (
64 CORBA::COMPLETED_NO
));
66 this->orb_core_
.set_tss_resource (this->tss_slot_
, impl
);
73 TAO::PICurrent::check_validity (const PortableInterceptor::SlotId
&identifier
)
75 // If the slot_count is zero, no initialization has been done (if there are
76 // no slots, then the PICurrent_impl object is not created as there is no
78 if (0 == this->slot_count_
)
79 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID
| 14, CORBA::COMPLETED_NO
);
81 // No need to acquire a lock for this check. At this point, these
82 // attributes are read only.
83 if (identifier
>= this->slot_count_
)
84 throw PortableInterceptor::InvalidSlot ();
88 TAO::PICurrent::_get_orb ()
90 return CORBA::ORB::_duplicate (this->orb_core_
.orb ());
94 TAO::PICurrent::initialize (PortableInterceptor::SlotId sc
)
96 // Only allow a single initialization; sc is the number of
97 // allocated PICurrent data slots the end user wants. If 0
98 // PICurrent is not used, as no data is to be stored.
99 if ((0 == this->slot_count_
) && (0 != sc
))
101 // NOTE: This function not only adds the cleanup function
102 // but ALSO allocates the TSS slot PICurrent is to use.
103 // It MUST be called BEFORE we attempt to get/set any
104 // PICurrent slot data.
105 if (0 != orb_core_
.add_tss_cleanup_func (CleanUpPICurrent
, this->tss_slot_
))
106 throw ::CORBA::NO_MEMORY (
107 CORBA::SystemException::_tao_minor_code (
110 CORBA::COMPLETED_NO
);
112 this->slot_count_
= sc
;
116 TAO_END_VERSIONED_NAMESPACE_DECL
118 #endif /* TAO_HAS_INTERCEPTORS == 1 */