Boost logo

Boost :

Subject: Re: [boost] Any interest in creating new CORBA IDL to C++ mapping?
From: Jon Biggar (jon_at_[hidden])
Date: 2010-08-02 09:59:41


On 7/22/10 7:57 AM, Mathias Gaunard wrote:
> On 14/07/10 22:58, Kevin Heifner wrote:
>
>> - IDL string is std::string
>> - IDL sequence and array are std::vector
>> - Java maps them to the same thing
>>
>> std::vector<octet> object_id();
>> std::shared_ptr<Object> id_to_reference(const std::vector<octet>&);
> >
>
> Can you use templates?
> When you take strings/sequences, why not take ranges instead of specific
> types the user would have to convert to?

YES! YES! YES!

Although it's tricker than you think, because IDL allows you to declare
composite types with embedded sequences.

I'd like to see IDL sequences mapped into templates that use trait
classes that allow the programmer to use any of the appropriate STL
ordered container abstractions (vector, list, deque, or user defined
ones) as the underlying storage. IDL sequence classes should also be a
sequence container so that <algorithm> works with them.

So something like this:

// IDL
struct Foo {
    long l;
    string s;
};

typedef sequence<Foo> FooSeq;

interface Bar {
     FooSeq manipulate(in FooSeq arg);
};

would map to something like this:

// C++
struct Foo {
     CORBA::Long l;
     std::string s;
};

template <
class Storage = CORBA::ConcreteSequenceStorage<std::vector,Foo>
> class FooSeq : public CORBA::AbstractSequence<Foo> {
     ...
};

class Bar : public CORBA::Object {
     template<class _ResultType = FooSeq<>,
              class _argType = FooSeq<> >
     virtual _ResultType manipulate(
         const CORBA::SequenceInAdapter<_argType> &arg
     ) = 0;
};

// Example client code

Bar mybar = ...; // get from a factory somewhere

FooSeq<> simpleresult, simplearg;

simpleresult = bar->manipulate<>(simplearg);

// or for the more adventurous

typedef FooSeq<CORBA::ConcreteStorage<std::list,Foo> MyFoo;
MyFoo myresult
MyFoo myarg;

myresult = mybar->manipulate<MyFoo>(arg);

// and perhaps even

typedef CORBA::SequenceResultContainerAdaptor<std::deque,Foo>
    MyFooResult;
std::deque<Foo> myresult2;
std::set<Foo> myarg2;

myresult2 = mybar->manipulate<MyFooResult>(myarg2);

Let's think big.

-- 
Jon Biggar
jon_at_[hidden]
jon_at_[hidden]
jonbiggar_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk