Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / IORInterceptor / IORInfo.cpp
blob8ad96eb55c48c451c419eb86112da0bbcccd9d34
1 // -*- C++ -*-
2 #include "tao/IORInterceptor/IORInfo.h"
3 #include "tao/PortableServer/Root_POA.h"
5 #include "tao/PolicyC.h"
6 #include "tao/IOPC.h"
7 #include "tao/ORB_Constants.h"
9 #if !defined (__ACE_INLINE__)
10 # include "tao/IORInterceptor/IORInfo.inl"
11 #endif /* __ACE_INLINE__ */
13 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
15 TAO_IORInfo::TAO_IORInfo (TAO_Root_POA *poa)
16 : poa_ (poa),
17 components_established_ (false)
21 TAO_IORInfo::~TAO_IORInfo ()
25 CORBA::Policy_ptr
26 TAO_IORInfo::get_effective_policy (CORBA::PolicyType type)
28 this->check_validity ();
30 CORBA::Policy_var policy =
31 this->poa_->get_policy (type);
33 if (!CORBA::is_nil (policy.in ()))
35 return policy._retn ();
38 // TODO: Now check the global ORB policies.
39 // ........
41 // No policy matching the given PolicyType was found.
42 throw ::CORBA::INV_POLICY (CORBA::OMGVMCID | 3, CORBA::COMPLETED_NO);
45 void
46 TAO_IORInfo::add_ior_component (const IOP::TaggedComponent &component)
48 this->check_validity ();
50 if (this->components_established_)
51 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO);
53 // Add the given tagged component to all profiles.
54 this->poa_->save_ior_component (component);
57 void
58 TAO_IORInfo::add_ior_component_to_profile (
59 const IOP::TaggedComponent &component,
60 IOP::ProfileId profile_id)
62 this->check_validity ();
64 if (this->components_established_)
65 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO);
67 this->poa_->save_ior_component_and_profile_id (component, profile_id);
70 char *
71 TAO_IORInfo::manager_id ()
73 this->check_validity ();
75 PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager ();
76 return poa_manager->get_id ();
79 PortableInterceptor::AdapterState
80 TAO_IORInfo::state ()
82 this->check_validity ();
84 return this->poa_->get_adapter_state ();
87 PortableInterceptor::ObjectReferenceTemplate *
88 TAO_IORInfo::adapter_template ()
90 this->check_validity ();
92 // Return the Object Reference Template whenever an IOR Interceptor
93 // is invoked. Its value is the template created for the adapter
94 // policies and the IOR Interceptor calls to add_ior_component and
95 // add_ior_component_to_profile. It's a const value and its value
96 // never changes.
97 PortableInterceptor::ObjectReferenceTemplate *adapter_template =
98 this->poa_->get_adapter_template ();
100 if (adapter_template == 0)
102 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO);
105 return adapter_template;
108 PortableInterceptor::ObjectReferenceFactory *
109 TAO_IORInfo::current_factory ()
111 this->check_validity ();
113 // Return the current_factory that is used to create the object
114 // references by the adapter. Though initially, its value is the
115 // same as the adapter_template, unlike adapter_template, its value
116 // can be changed. The value of the current_factory can be changed
117 // only during the call to components_established method.
118 PortableInterceptor::ObjectReferenceFactory *adapter_factory =
119 this->poa_->get_obj_ref_factory ();
121 if (adapter_factory == 0)
123 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO);
126 return adapter_factory;
129 void
130 TAO_IORInfo::current_factory (
131 PortableInterceptor::ObjectReferenceFactory * current_factory)
133 this->check_validity ();
135 this->poa_->set_obj_ref_factory (current_factory);
138 void
139 TAO_IORInfo::check_validity ()
141 if (this->poa_ == 0)
143 // Although not defined by the spec, duplicate the behavior used
144 // by the ORBInitInfo object once CORBA::ORB_init() has been
145 // called. Specifically, the IORInfo object is no longer valid
146 // once the POA has invoked all IORInterceptor interception
147 // points. This also prevents memory access violations from
148 // occuring if the POA is destroyed before this IORInfo object.
149 throw ::CORBA::OBJECT_NOT_EXIST (TAO::VMCID, CORBA::COMPLETED_NO);
153 TAO_END_VERSIONED_NAMESPACE_DECL