Namespaces | Defines | Functions | Variables

Object.cpp File Reference

#include "tao/Object.h"
#include "tao/Stub.h"
#include "tao/Profile.h"
#include "tao/ORB_Core.h"
#include "tao/Connector_Registry.h"
#include "tao/LocateRequest_Invocation_Adapter.h"
#include "tao/debug.h"
#include "tao/Dynamic_Adapter.h"
#include "tao/IFR_Client_Adapter.h"
#include "tao/Remote_Object_Proxy_Broker.h"
#include "tao/CDR.h"
#include "tao/SystemException.h"
#include "tao/PolicyC.h"
#include "ace/Dynamic_Service.h"
#include "ace/OS_NS_string.h"
#include "ace/CORBA_macros.h"
Include dependency graph for Object.cpp:

Go to the source code of this file.

Namespaces

namespace  TAO
 

Define symbolic names for the ORB collocation strategies.


Defines

#define TAO_OBJECT_IOR_EVALUATE
#define TAO_OBJECT_IOR_EVALUATE_RETURN

Functions

CORBA::Boolean operator<< (TAO_OutputCDR &cdr, const CORBA::Object *x)
CORBA::Boolean operator>> (TAO_InputCDR &cdr, CORBA::Object *&x)

Variables

TAO::Object_Proxy_Broker *(* _TAO_Object_Proxy_Broker_Factory_function_pointer )(void)=0

Define Documentation

#define TAO_OBJECT_IOR_EVALUATE
Value:
if (!this->is_evaluated_) \
  { \
    ACE_GUARD (ACE_Lock , mon, *this->object_init_lock_); \
      if (!this->is_evaluated_) \
        CORBA::Object::tao_object_initialize (this); \
  }

Definition at line 97 of file Object.cpp.

#define TAO_OBJECT_IOR_EVALUATE_RETURN
Value:
if (!this->is_evaluated_) \
  { \
    ACE_GUARD_RETURN (ACE_Lock , mon, *this->object_init_lock_, 0); \
    if (!this->is_evaluated_) \
      CORBA::Object::tao_object_initialize (this); \
  }

Definition at line 105 of file Object.cpp.


Function Documentation

CORBA::Boolean operator<< ( TAO_OutputCDR cdr,
const CORBA::Object x 
)

Definition at line 681 of file Object.cpp.

{
  if (x == 0)
    {
      // NIL objrefs ... marshal as empty type hint, no elements.
      cdr.write_ulong (1);
      cdr.write_char ('\0');
      cdr.write_ulong (0);
      return (CORBA::Boolean) cdr.good_bit ();
    }

  if (!x->is_evaluated ())
    {
      // @@ This is too inefficient. Need to speed this up if this is
      // a bottle neck.
      cdr << const_cast<IOP::IOR &> (x->ior ());
      return cdr.good_bit ();
    }

   TAO_Stub *stubobj = x->_stubobj ();

   if (stubobj == 0)
     return false;

  return (stubobj->marshal (cdr));
}

CORBA::Boolean operator>> ( TAO_InputCDR cdr,
CORBA::Object *&  x 
)

Definition at line 811 of file Object.cpp.

{
  bool lazy_strategy = false;
  TAO_ORB_Core *orb_core = cdr.orb_core ();

  if (orb_core == 0)
    {
      orb_core = TAO_ORB_Core_instance ();
      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_WARNING,
                      ACE_TEXT ("TAO (%P|%t) WARNING: extracting object from ")
                      ACE_TEXT ("default ORB_Core\n")));
        }
    }
  else
    {
      if (orb_core->resource_factory ()->resource_usage_strategy () ==
          TAO_Resource_Factory::TAO_LAZY)
        {
          lazy_strategy = true;
        }
    }

  if (!lazy_strategy)
    {
      // If the user has set up a eager strategy..
      CORBA::String_var type_hint;

      if (!(cdr >> type_hint.inout ()))
        return false;

      CORBA::ULong profile_count;
      if (!(cdr >> profile_count))
        return false;

      if (profile_count == 0)
        {
          x = CORBA::Object::_nil ();
          return (CORBA::Boolean) cdr.good_bit ();
        }

      // get a profile container to store all profiles in the IOR.
      TAO_MProfile mp (profile_count);

      TAO_ORB_Core *orb_core = cdr.orb_core ();
      if (orb_core == 0)
        {
          orb_core = TAO_ORB_Core_instance ();
          if (TAO_debug_level > 0)
            {
              ACE_DEBUG ((LM_WARNING,
                          ACE_TEXT ("TAO (%P|%t) - Object::tao_object_initialize ")
                          ACE_TEXT ("WARNING: extracting object from ")
                          ACE_TEXT ("default ORB_Core\n")));
            }
        }

      // Ownership of type_hint is given to TAO_Stub
      // TAO_Stub will make a copy of mp!

      TAO_Stub *objdata = 0;

      try
        {
          TAO_Connector_Registry *connector_registry =
            orb_core->connector_registry ();

          for (CORBA::ULong i = 0; i != profile_count && cdr.good_bit (); ++i)
            {
              TAO_Profile *pfile = connector_registry->create_profile (cdr);
              if (pfile != 0)
                {
                  mp.give_profile (pfile);
                }
            }

          // Make sure we got some profiles!
          if (mp.profile_count () != profile_count)
            {
              // @@ This occurs when profile creation fails when decoding the
              //    profile from the IOR.
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("TAO (%P|%t) - ERROR: Could not create all ")
                                 ACE_TEXT ("profiles while extracting object [%d, %d]\n")
                                 ACE_TEXT ("TAO (%P|%t) - ERROR: reference from the ")
                                 ACE_TEXT ("CDR stream.\n"),
                                 mp.profile_count (), profile_count),
                                false);
            }

          objdata = orb_core->create_stub (type_hint.in (), mp);
        }
      catch (const ::CORBA::Exception& ex)
        {
          if (TAO_debug_level > 0)
            ex._tao_print_exception (
              ACE_TEXT ("TAO (%P|%t) - ERROR creating stub ")
              ACE_TEXT ("object when demarshaling object ")
              ACE_TEXT ("reference.\n"));

          return false;
        }

      TAO_Stub_Auto_Ptr safe_objdata (objdata);

      x = orb_core->create_object (safe_objdata.get ());
      if (!x)
        {
          return false;
        }

      // Transfer ownership to the CORBA::Object
      (void) safe_objdata.release ();
    }
  else
    {
      // Lazy strategy!
      IOP::IOR *ior = 0;

      ACE_NEW_RETURN (ior,
                      IOP::IOR (),
                      false);

      if (!(cdr >> *ior))
        {
          return false;
        }
        
      ACE_NEW_RETURN (x,
                      CORBA::Object (ior, orb_core),
                      false);
    }

  return (CORBA::Boolean) cdr.good_bit ();
}


Variable Documentation

TAO::Object_Proxy_Broker*(* _TAO_Object_Proxy_Broker_Factory_function_pointer)(void)=0

This function pointer is set only when the Portable server library is present.

Definition at line 1000 of file Object.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines