Hi Mark,
I would say that an approach more consistent with the SDO spec would be to
simply create a readonly property, "SomePropertyPlusTwo", and then using
some "implementation-specific" API, provide the value-producing
implementation code for the property. The SDO spec basically says that
setting readonly properties is implementation dependent. I think that
generalizing that to include setting the property to the "result of a
function", as opposed to "some specific value" is quite reasonable.
In the Java implementation of SDO you can already do this kind of thing,
by generating a static implementation class for the SDO type and then
providing your desired implementation code in the generated get() method.
I gather from your examples, however, that you're using the C++
implementation so I don't believe that's possible yet. Maybe you don't
really want generated classes anyway? It might be interesting to provide a
way to register an implementation method with a dynamic reaonly property,
regardless.
Perhaps some kind of API in the Tuscany C++ implementation that let's you
register a function with a readonly property would be a more
spec-consistent way to do this. For example:
Property* somePropertyPlusTwo = ...
extendedTypeHelper->registerPropertyImplementation(somePropertyPlusTwo,
SomePropertyPlusTwoFunction);
Maybe someone on the Tuscany C++ team knows of a better place to hook in
this kind of thing into the existing implementation.
Frank
Mark Trumbo <[EMAIL PROTECTED]> wrote on 08/24/2006 05:09:02 AM:
> Given some function
>
> int SomePropertyPlusTwoFunction(DataObjectPtr dc) { return
> dc->getInteger("SomeProperty") + 2; }
>
> I would like to write
>
> myDataFactory->addMethodToType(uri, "SomePropertyPlusTwo",
> "MyTypeWithSomeProperty",
> "SomePropertyPlusTwo", intType,
> SomePropertyPlusTwoFunction);
>
> which would associate the function SomePropertyPlusTwoFunction with
> the name SomePropertyPlusTwo and then
>
> dc->getValue("SomePropertyPlusTwo");
>
> which would invoke the function SomePropertyPlusTwoFunction
>
> Everything else would behave as though this were a read-only
> attribute -- queries, serialization, etc -- but instead returning
> data using a name as a key, the key would be associated with a
> function. Conceptually, the intention is to a const member function
> that takes no arguments, which is almost indistinguishable from
> read-only data.
>
> Is there already a way to do what I want to do?
>
> If not, is having such a facility inconsistent in any way with the
> rest of SDO?
>
> If not, is any one working on this?
>
> If not, I will.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]