POA_Current_Impl.cpp

Go to the documentation of this file.
00001 // $Id: POA_Current_Impl.cpp 76898 2007-02-04 18:58:07Z johnnyw $
00002 
00003 // -- PortableServer Include --
00004 #include "tao/PortableServer/Object_Adapter.h"
00005 #include "tao/PortableServer/POA_Current_Impl.h"
00006 #include "tao/PortableServer/Root_POA.h"
00007 
00008 #include "tao/TSS_Resources.h"
00009 
00010 #if !defined (__ACE_INLINE__)
00011 # include "tao/PortableServer/POA_Current_Impl.inl"
00012 #endif /* __ACE_INLINE__ */
00013 
00014 ACE_RCSID (PortableServer,
00015            POA_Current_IMpl,
00016            "$Id: POA_Current_Impl.cpp 76898 2007-02-04 18:58:07Z johnnyw $")
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 namespace TAO
00021 {
00022   namespace Portable_Server
00023   {
00024     POA_Current_Impl::POA_Current_Impl (void)
00025       : poa_ (0),
00026         object_id_ (TAO_POA_OBJECT_ID_BUF_SIZE, 0, object_id_buf_),
00027         object_key_ (0),
00028         servant_ (0),
00029         priority_ (TAO_INVALID_PRIORITY),
00030         previous_current_impl_ (0),
00031         setup_done_ (false)
00032     {
00033     }
00034 
00035     void
00036     POA_Current_Impl::setup (::TAO_Root_POA *p, const TAO::ObjectKey &key)
00037     {
00038       // Remember information about this upcall.
00039       this->poa_ = p;
00040       this->object_key_ = &key;
00041 
00042       // Set the current context and remember the old one.
00043       this->tss_resources_ = TAO_TSS_Resources::instance ();
00044 
00045       this->previous_current_impl_ =
00046         static_cast <POA_Current_Impl *>
00047                          (this->tss_resources_->poa_current_impl_);
00048       this->tss_resources_->poa_current_impl_ = this;
00049 
00050       // Setup is complete.
00051       this->setup_done_ = true;
00052     }
00053 
00054     POA_Current_Impl *
00055     POA_Current_Impl::previous (void) const
00056     {
00057       return this->previous_current_impl_;
00058     }
00059 
00060     void
00061     POA_Current_Impl::teardown (void)
00062     {
00063       if (this->setup_done_)
00064         {
00065           // Reset the old context.
00066           this->tss_resources_->poa_current_impl_ = this->previous_current_impl_;
00067         }
00068     }
00069 
00070     PortableServer::POA_ptr
00071     POA_Current_Impl::get_POA (void)
00072     {
00073       return PortableServer::POA::_duplicate (this->poa_);
00074     }
00075 
00076     PortableServer::ObjectId *
00077     POA_Current_Impl::get_object_id (void)
00078     {
00079       PortableServer::ObjectId *objid = 0;
00080 
00081       // Create a new one and pass it back
00082       ACE_NEW_RETURN (objid,
00083                       PortableServer::ObjectId (this->object_id_),
00084                       0);
00085       return objid;
00086     }
00087 
00088     CORBA::Object_ptr
00089     POA_Current_Impl::get_reference (void)
00090     {
00091       return this->poa_->id_to_reference (this->object_id_);
00092     }
00093 
00094     PortableServer::Servant
00095     POA_Current_Impl::get_servant (void)
00096     {
00097       return this->servant_;
00098     }
00099 
00100     TAO_ORB_Core &
00101     POA_Current_Impl::orb_core (void) const
00102 
00103     {
00104       return this->poa_->orb_core ();
00105     }
00106   }
00107 }
00108 
00109 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:40:54 2010 for TAO_PortableServer by  doxygen 1.4.7