summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-04-13 07:35:13 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-04-13 07:35:13 +0000
commit1053555959f6617d5bdca4f712d15c940f8fcb60 (patch)
tree4c289d66b108f5b35538fe2fed85480a9bea963c
parent17cfd8b6bef6330bbba34fc51ae35928152ee146 (diff)
downloadATCD-1053555959f6617d5bdca4f712d15c940f8fcb60.tar.gz
ChangeLogTag:Thu Apr 13 02:00:09 2000 Nanbor Wang <nanbor@cs.wustl.edu>
-rw-r--r--TAO/ChangeLogs/ChangeLog-02a16
-rw-r--r--TAO/tao/LocalObject.cpp19
-rw-r--r--TAO/tao/LocalObject.h14
-rw-r--r--TAO/tao/LocalObject.i27
-rw-r--r--TAO/tao/Object.cpp22
-rw-r--r--TAO/tao/Object.h15
-rw-r--r--TAO/tao/Object.i29
7 files changed, 132 insertions, 10 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a
index a7dcec8ec1f..4245c26b690 100644
--- a/TAO/ChangeLogs/ChangeLog-02a
+++ b/TAO/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,19 @@
+Thu Apr 13 02:00:09 2000 Nanbor Wang <nanbor@cs.wustl.edu>
+
+ * tao/Object.h:
+ * tao/Object.i:
+ * tao/Object.cpp: Added implementation of _tao_QueryInterface.
+ This method is used to downcast local object. Added a member
+ data called <is_local_> and a readonly accessor. We use this
+ method to find out whether an object reference points to a local
+ object or not. <_narrow> behaves differently for LocalObject
+ and Object.
+
+ * tao/LocalObject.h:
+ * tao/LocalObject.i:
+ * tao/LocalObject.cpp: Added implementation of
+ _tao_QueryInterface.
+
Sat Apr 01 02:04:09 2000 Nanbor Wang <nanbor@cs.wustl.edu>
* tao/corbafwd.h:
diff --git a/TAO/tao/LocalObject.cpp b/TAO/tao/LocalObject.cpp
index 9c5bb60375d..b3874f0e4e9 100644
--- a/TAO/tao/LocalObject.cpp
+++ b/TAO/tao/LocalObject.cpp
@@ -98,6 +98,25 @@ CORBA::LocalObject::_key (CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
}
+void *
+CORBA::LocalObject::_tao_QueryInterface (ptr_arith_t type)
+{
+ void *retv = 0;
+
+ if (type == ACE_reinterpret_cast (ptr_arith_t,
+ &CORBA::LocalObject::_narrow))
+ retv = ACE_reinterpret_cast (void *, this);
+ else if (type == ACE_reinterpret_cast (ptr_arith_t,
+ &CORBA::Object::_narrow))
+ retv = ACE_reinterpret_cast (void *,
+ ACE_static_cast (CORBA::Object_ptr,
+ this));
+ if (retv)
+ this->_add_ref ();
+
+ return retv;
+}
+
#if (TAO_HAS_MINIMUM_CORBA == 0)
// NON_EXISTENT ... send a simple call to the object, which will
diff --git a/TAO/tao/LocalObject.h b/TAO/tao/LocalObject.h
index de39a827bc7..d8445f7d421 100644
--- a/TAO/tao/LocalObject.h
+++ b/TAO/tao/LocalObject.h
@@ -48,6 +48,12 @@ public:
static CORBA::LocalObject_ptr _narrow (CORBA::Object_ptr obj,
CORBA_Environment &ACE_TRY_ENV =
TAO_default_environment ());
+ // @@ Narrowing a CORBA::LocalObject to a CORBA::Object is broken
+ // right now. The solution seems to be making CORBA::Object an
+ // abstract base class and create a CORBA::RemoteObject for regular
+ // object. Or, even easier, add a <is_local> member into
+ // CORBA::Object. I'll take the easier route for now.
+
static CORBA::LocalObject_ptr _unchecked_narrow (CORBA::Object_ptr obj,
CORBA_Environment &ACE_TRY_ENV =
TAO_default_environment ());
@@ -189,6 +195,10 @@ public:
// probably crash. This method does not create a new copy.
#endif /* 0 */
+ virtual void * _tao_QueryInterface (ptr_arith_t type);
+ // Downcasting this object pointer to some other derived class.
+ // This QueryInterface stuff only work for local object.
+
#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8
typedef CORBA::LocalObject_ptr _ptr_type;
typedef CORBA::LocalObject_var _var_type;
@@ -196,6 +206,10 @@ public:
// Useful for template programming.
protected:
+ LocalObject ();
+ // Default constructor. Make it protected to prevent instantiation
+ // of this class.
+
private:
// = Unimplemented methods
diff --git a/TAO/tao/LocalObject.i b/TAO/tao/LocalObject.i
index 97f6b0e4142..4d65647e542 100644
--- a/TAO/tao/LocalObject.i
+++ b/TAO/tao/LocalObject.i
@@ -21,18 +21,31 @@ CORBA::LocalObject::_nil (void)
ACE_INLINE CORBA::LocalObject_ptr
CORBA::LocalObject::_narrow (CORBA::Object_ptr obj, CORBA::Environment& ACE_TRY_ENV)
{
- if (obj->_is_a ("IDL:omg.org/CORBA/LocalObject:1.0", ACE_TRY_ENV))
- return CORBA::LocalObject::_unchecked_narrow (obj, ACE_TRY_ENV);
- else
- return 0;
+ if (obj->_is_local () != 0)
+ return
+ ACE_reinterpret_cast (CORBA::LocalObject_ptr,
+ obj->_tao_QueryInterface
+ (ACE_reinterpret_cast (ptr_arith_t,
+ &CORBA::LocalObject::_narrow)));
+ return 0;
}
ACE_INLINE CORBA::LocalObject_ptr
CORBA::LocalObject::_unchecked_narrow (CORBA::Object_ptr obj, CORBA::Environment&)
{
- return CORBA::LocalObject::_duplicate
- (ACE_reinterpret_cast (CORBA::LocalObject_ptr,
- ACE_reinterpret_cast (void *, obj)));
+ if (obj->_is_local () != 0)
+ return
+ ACE_reinterpret_cast (CORBA::LocalObject_ptr,
+ obj->_tao_QueryInterface
+ (ACE_reinterpret_cast (ptr_arith_t,
+ &CORBA::LocalObject::_narrow)));
+ return 0;
+}
+
+ACE_INLINE
+CORBA::LocalObject::LocalObject ()
+ : ACE_NESTED_CLASS (CORBA, Object (0))
+{
}
// *************************************************************
diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp
index 571304a3426..e4762c8b01c 100644
--- a/TAO/tao/Object.cpp
+++ b/TAO/tao/Object.cpp
@@ -39,6 +39,7 @@ CORBA_Object::CORBA_Object (TAO_Stub *protocol_proxy,
CORBA::Boolean collocated)
: servant_ (servant),
is_collocated_ (collocated),
+ is_local_ (0),
protocol_proxy_ (protocol_proxy),
refcount_ (1),
refcount_lock_ ()
@@ -196,6 +197,12 @@ CORBA_Object::_is_collocated (void) const
return this->is_collocated_;
}
+CORBA::Boolean
+CORBA_Object::_is_local (void) const
+{
+ return this->is_local_;
+}
+
// Quickly hash an object reference's representation data. Used to
// create hash tables.
@@ -250,6 +257,21 @@ CORBA::Object::_object_key (void)
return this->_stubobj ()->profile_in_use ()->object_key ();
}
+void *
+CORBA::Object::_tao_QueryInterface (ptr_arith_t type)
+{
+ void *retv = 0;
+
+ if (type == ACE_reinterpret_cast (ptr_arith_t,
+ &CORBA::Object::_narrow))
+ retv = ACE_reinterpret_cast (void *, this);
+
+ if (retv)
+ this->_add_ref ();
+
+ return 0;
+}
+
// @@ This doesn't seemed to be used anyplace! It should go away!! FRED
void
CORBA::Object::_use_locate_requests (CORBA::Boolean use_it)
diff --git a/TAO/tao/Object.h b/TAO/tao/Object.h
index 575d3e6d075..7127afe473e 100644
--- a/TAO/tao/Object.h
+++ b/TAO/tao/Object.h
@@ -77,7 +77,10 @@ public:
// return the associated servant (if one exists)
virtual CORBA::Boolean _is_collocated (void) const;
- // are we collocated with the servant?
+ // Is this object collocated with the servant?
+
+ virtual CORBA::Boolean _is_local (void) const;
+ // Is this a local object?
#if (TAO_HAS_MINIMUM_CORBA == 0)
@@ -191,6 +194,10 @@ public:
// If there's no in-use profile, then the program will
// probably crash. This method does not create a new copy.
+ virtual void * _tao_QueryInterface (ptr_arith_t type);
+ // Downcasting this object pointer to some other derived class.
+ // This QueryInterface stuff only work for local object.
+
#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8
typedef CORBA_Object_ptr _ptr_type;
typedef CORBA_Object_var _var_type;
@@ -219,6 +226,9 @@ public:
// the object
protected:
+ CORBA_Object (int dummy);
+ // Initializing a local object.
+
// = Internal Reference count managment.
CORBA::ULong _incr_refcnt (void);
// Increment the reference count.
@@ -233,6 +243,9 @@ protected:
// Flag to indicate collocation. It is 0 except for collocated
// objects.
+ CORBA::Boolean is_local_;
+ // Specify whether this is a local object or not.
+
private:
TAO_Stub *protocol_proxy_;
// Pointer to the protocol-specific "object" containing important
diff --git a/TAO/tao/Object.i b/TAO/tao/Object.i
index 2c7befa10a5..892002837cf 100644
--- a/TAO/tao/Object.i
+++ b/TAO/tao/Object.i
@@ -2,6 +2,17 @@
// ****************************************************************
+ACE_INLINE
+CORBA::Object::Object (int)
+ : servant_ (0),
+ is_collocated_ (0),
+ is_local_ (1),
+ protocol_proxy_ (0),
+ refcount_ (1),
+ refcount_lock_ ()
+{
+}
+
ACE_INLINE CORBA::ULong
CORBA_Object::_incr_refcnt (void)
{
@@ -42,13 +53,27 @@ CORBA_Object::_nil (void)
ACE_INLINE CORBA_Object_ptr
CORBA_Object::_narrow (CORBA_Object_ptr obj, CORBA::Environment&)
{
- return CORBA_Object::_duplicate (obj);
+ if (obj->is_local_)
+ return
+ ACE_reinterpret_cast (CORBA::Object_ptr,
+ obj->_tao_QueryInterface
+ (ACE_reinterpret_cast (ptr_arith_t,
+ &CORBA::Object::_narrow)));
+ else
+ return CORBA_Object::_duplicate (obj);
}
ACE_INLINE CORBA_Object_ptr
CORBA_Object::_unchecked_narrow (CORBA_Object_ptr obj, CORBA::Environment&)
{
- return CORBA_Object::_duplicate (obj);
+ if (obj->is_local_)
+ return
+ ACE_reinterpret_cast (CORBA::Object_ptr,
+ obj->_tao_QueryInterface
+ (ACE_reinterpret_cast (ptr_arith_t,
+ &CORBA::Object::_narrow)));
+ else
+ return CORBA_Object::_duplicate (obj);
}
ACE_INLINE TAO_Stub *