00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #ifndef _delegate_mixin_hh
00019 #define _delegate_mixin_hh
00020 
00021 #include "DelegateS.h"
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 template <class T, class T_var> class DelegateMixin :
00030     public virtual POA_BrokerDelegates::Delegate
00031 {
00032 
00033 public:
00034 
00035 
00036 
00037 
00038     DelegateMixin(void)
00039     {
00040     };
00041 
00042 
00043 
00044 
00045     virtual ~DelegateMixin(void)
00046     {
00047     };
00048 
00049 
00050     virtual void SetDelegateAttribute(const char *id,
00051                                       const CORBA::Any &value)
00052         throw (CORBA::SystemException)
00053     {
00054         if( id == NULL )
00055         {
00056             throw CORBA::BAD_PARAM();
00057         }
00058         else if( strcasecmp(id, "remote-object") == 0 )
00059         {
00060             CORBA::Object_var obj;
00061 
00062             if( value >>= CORBA::Any::to_object(obj) )
00063             {
00064                 this->dm_RemoteObject = T::_narrow(obj.in());
00065             }
00066             else
00067             {
00068                 throw CORBA::BAD_PARAM();
00069             }
00070         }
00071         else
00072         {
00073             throw CORBA::BAD_PARAM();
00074         }
00075     };
00076 
00077 
00078     virtual CORBA::Any_ptr GetDelegateAttribute(const char *id)
00079         throw (CORBA::SystemException)
00080     {
00081         CORBA::Any_var retval = new CORBA::Any();
00082 
00083         if( id == NULL )
00084         {
00085             throw CORBA::BAD_PARAM();
00086         }
00087         else if( strcasecmp(id, "remote-object") == 0 )
00088         {
00089             *retval <<= this->dm_RemoteObject.in();
00090         }
00091         else
00092         {
00093             throw CORBA::BAD_PARAM();
00094         }
00095         return( retval._retn() );
00096     };
00097 
00098     
00099     virtual void SetDelegateAttributeObject(const char *id,
00100                                             const CORBA::Object_ptr value)
00101         throw (CORBA::SystemException)
00102     {
00103         if( id == NULL )
00104         {
00105             throw CORBA::BAD_PARAM();
00106         }
00107         else if( strcasecmp(id, "remote-object") == 0 )
00108         {
00109             if( CORBA::is_nil(value) )
00110             {
00111                 this->dm_RemoteObject = T::_nil();
00112             }
00113             else
00114             {
00115                 T_var tmp = T::_narrow(value);
00116 
00117                 if( CORBA::is_nil(tmp.in()) )
00118                 {
00119                     throw CORBA::BAD_PARAM();
00120                 }
00121                 else
00122                 {
00123                     this->dm_RemoteObject = tmp;
00124                 }
00125             }
00126         }
00127         else
00128         {
00129             throw CORBA::BAD_PARAM();
00130         }
00131     };
00132 
00133     virtual CORBA::Object_ptr GetDelegateAttributeObject(const char *id)
00134         throw (CORBA::SystemException)
00135     {
00136         CORBA::Object_var retval;
00137 
00138         if( id == NULL )
00139         {
00140             throw CORBA::BAD_PARAM();
00141         }
00142         else if( strcasecmp(id, "remote-object") == 0 )
00143         {
00144             retval = T::_duplicate(this->dm_RemoteObject.in());
00145         }
00146         else
00147         {
00148             throw CORBA::BAD_PARAM();
00149         }
00150         return( retval._retn() );
00151     };
00152     
00153 
00154 protected:
00155 
00156 
00157 
00158 
00159     T_var dm_RemoteObject;
00160     
00161 };
00162 
00163 #endif