Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / PortableServer / POA_Current_Impl.cpp
blobfb186752fefffc710ca9ce5e5df5998e4b8e2134
1 // -- PortableServer Include --
2 #include "tao/PortableServer/Object_Adapter.h"
3 #include "tao/PortableServer/POA_Current_Impl.h"
4 #include "tao/PortableServer/Root_POA.h"
6 #include "tao/TSS_Resources.h"
8 #if !defined (__ACE_INLINE__)
9 # include "tao/PortableServer/POA_Current_Impl.inl"
10 #endif /* __ACE_INLINE__ */
12 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 namespace TAO
16 namespace Portable_Server
18 POA_Current_Impl::POA_Current_Impl ()
19 : object_id_ (TAO_POA_OBJECT_ID_BUF_SIZE, 0, object_id_buf_),
20 object_key_ (0),
21 servant_ (0),
22 priority_ (TAO_INVALID_PRIORITY),
23 previous_current_impl_ (0),
24 setup_done_ (false)
28 void
29 POA_Current_Impl::setup (::TAO_Root_POA *p, const TAO::ObjectKey &key)
31 // Remember information about this upcall.
32 this->poa_ = p;
33 this->object_key_ = &key;
35 // Set the current context and remember the old one.
36 this->tss_resources_ = TAO_TSS_Resources::instance ();
38 this->previous_current_impl_ =
39 static_cast <POA_Current_Impl *>
40 (this->tss_resources_->poa_current_impl_);
41 this->tss_resources_->poa_current_impl_ = this;
43 // Setup is complete.
44 this->setup_done_ = true;
47 POA_Current_Impl *
48 POA_Current_Impl::previous () const
50 return this->previous_current_impl_;
53 void
54 POA_Current_Impl::teardown ()
56 if (this->setup_done_)
58 // Reset the old context.
59 this->tss_resources_->poa_current_impl_ = this->previous_current_impl_;
63 PortableServer::POA_ptr
64 POA_Current_Impl::get_POA ()
66 return PortableServer::POA::_duplicate (this->poa_);
69 PortableServer::ObjectId *
70 POA_Current_Impl::get_object_id ()
72 PortableServer::ObjectId *objid = 0;
74 // Create a new one and pass it back
75 ACE_NEW_RETURN (objid,
76 PortableServer::ObjectId (this->object_id_),
77 0);
78 return objid;
81 CORBA::Object_ptr
82 POA_Current_Impl::get_reference ()
84 return this->poa_->id_to_reference (this->object_id_);
87 PortableServer::Servant
88 POA_Current_Impl::get_servant ()
90 return this->servant_;
93 TAO_ORB_Core &
94 POA_Current_Impl::orb_core () const
97 return this->poa_->orb_core ();
102 TAO_END_VERSIONED_NAMESPACE_DECL