Bug 2481 - Small refactor on new sequences, reduce code duplication
Summary: Small refactor on new sequences, reduce code duplication
Status: NEW
Alias: None
Product: TAO
Classification: Unclassified
Component: ORB (show other bugs)
Version: 1.5
Hardware: All All
: P3 enhancement
Assignee: DOC Center Support List (internal)
URL:
Depends on:
Blocks: 1929
  Show dependency tree
 
Reported: 2006-03-28 05:17 CST by Johnny Willemsen
Modified: 2007-04-11 06:11 CDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johnny Willemsen 2006-03-28 05:17:43 CST
Small todo item, refactor object and valuetype sequences to prevent code
duplication:


> > 	It is unfortunate that the traits for objects and 
> > valuetypes have
> > different names.  We would have been better off with a single 
> > trait for
> > all IDL types...
> 
> The methods are also different, I will have a look today how we could
> resolve this, do you have any specific ideas?

	There is no rule that requires all specializations to have the same
methods.  So we could have defined IDL_Traits differently for object
references, valuetypes, unions, structures, etc.  Naturally we would
want enough commonality to use the traits in the contexts that make
sense.

> 
> I tried the following, replaced Value_Traits with Objref_Traits and
> generated for the valuetypes the following trait specialization:
> 
>   template<>
>   struct TAO_ORT_Export
> Objref_Traits<PortableInterceptor::ObjectReferenceFactory>
>   {
>     static void add_ref (PortableInterceptor::ObjectReferenceFactory *);
>     static void remove_ref (PortableInterceptor::ObjectReferenceFactory *);
>     static void release (PortableInterceptor::ObjectReferenceFactory *);
>     static PortableInterceptor::ObjectReferenceFactory * duplicate
> (PortableInterceptor::ObjectReferenceFactory *);
>     static PortableInterceptor::ObjectReferenceFactory * nil (void);
>   };
> 
> The duplicate just calls add_ref and returns p, nil returns 0. If I then
> update all code to use this traits I can remove the Value_Traits completely
> and just use the Objref_Traits and then I can use the
> unbounded_object_reference_sequence template without getting compile
> problems (didn't run things yet). 


	Sounds like a good start.  On a future pass we may refactor the code to
name those traits better, maybe something like "Reference_Traits", or
just "IDL_Type_Traits" as I suggested above.


> What is your idea on this, go this way, or introduce a new value_type
> sequence that uses the Value_Traits as they now exist?

	Or refactor the code to a common sequence templatized by the trait
type:

template<class object_t, template<class U> trait_type>
class unbounded_reference_sequence { ...};

template<class object_t>
class unbounded_object_reference_sequence : public
unbounded_reference_sequence<object_t, Objref_Traits<object_t> >
{....};

and something similar for the unbounded_valuetype_sequence....
Comment 1 Johnny Willemsen 2006-03-28 05:18:07 CST
added blocks and reassign to me
Comment 2 Johnny Willemsen 2006-03-28 05:18:15 CST
accept
Comment 3 Johnny Willemsen 2007-04-11 06:11:16 CDT
to pool