The new Firebird OO API

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

The new Firebird OO API

Pierre Y.
Hi all,

If I understood well the conference about Providers, Plugins and new OO API from Alex this week-end at the Firebird Conference, all we have to do to enter the new OO API is to find the new fb_get_master_interface method and play with the new IMaster interface ?

Well. I found the fb_get_master_interface method in the binaries (libfbclient.so) but nowhere in the ibase.h file. Nor I can see any firebird/*.h in the include directory of the freshly compiled distribution of Firebird "HEAD"

So I think I must use the include files from the source tree. I tried to compile the UDR sample in $SOURCE/examples/udr without success :

I tried with something like :

g++ -Wall -I ../../src/include -L fbclient -o UdrCppExample UdrCppExample.cpp

I get tons of "undefined references to...

Any hint ? Thank you in advance,

Regards,

--
Pierre Yager

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Alex Peshkoff
 On 11/28/11 04:01, Pierre Y. wrote:

> Hi all,
>
> If I understood well the conference about Providers, Plugins and new OO API
> from Alex this week-end at the Firebird Conference, all we have to do to
> enter the new OO API is to find the new fb_get_master_interface method and
> play with the new IMaster interface ?
>
> Well. I found the fb_get_master_interface method in the binaries
> (libfbclient.so) but nowhere in the ibase.h file. Nor I can see any
> firebird/*.h in the include directory of the freshly compiled distribution
> of Firebird "HEAD"
>
> So I think I must use the include files from the source tree. I tried to
> compile the UDR sample in $SOURCE/examples/udr without success :
>
> I tried with something like :
>
> g++ -Wall -I ../../src/include -L fbclient -o UdrCppExample
> UdrCppExample.cpp
>
> I get tons of "undefined references to...

'-L fbclient' instead -lfbclient is not good idea :-)
You should also link with C++ UDR plugin libudr_engine.so.

And remember - you build shared library, i.e. please use -shared switch.
Something like this:
g++ -Wall -I../../src/include -lfbclient -o libUdrCppExample.so -fPIC
UdrCppExample.cpp ../../gen/Debug/firebird/plugins/libudr_engine.so -shared

Do not worry about "libudr_engine.so not found" message in ldd output -
it will be found at runtime.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Pierre Y.
> g++ -Wall -I../../src/include -lfbclient -o libUdrCppExample.so -fPIC
> UdrCppExample.cpp ../../gen/Debug/firebird/plugins/libudr_engine.so -shared

Thank you Alex for the answer. It compiled ! I don't know how to test
if it works, but it compiled ;-)

Next I want to compile a VERY simple piece of code, a kind of
'fb_get_master_interface hello world' :

$ cat firetest.cpp
#include "ibase.h"
#include "firebird/Interface.h"

int main()
{
  Firebird::IMaster *master;
  master = fb_get_master_interface();
  return master != NULL;
}

I tried to compile with :

$ LC_ALL=3DC g++ -Wall -I../firebird/src/include -lfbclient -o firetest
-fPIC firetest.cpp
/tmp/cc4TW3Oa.o: In function `main':
firetest.cpp:(.text+0x9): undefined reference to `fb_get_master_interface'
collect2: ld returned 1 exit status

Can you give me some hints again to go a step further ?

Regards,

--
Pierre Yager

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Pierre Y.
Alex,

I think I found the problem : -lfbclient can't find libfbclient.so
I added /opt/fb3cs/lib to ldconfig.conf.d but it don't changes anything.

Finally I changed the compile command to :

$ LC_ALL=C g++ -Wall -I../firebird/src/include -o firetest -fPIC
firetest.cpp /opt/fb3cs/lib/libfbclient.so

And it worked like a charm.

Now I started playing with the new API. I created a project on github for it :

https://github.com/zedalaye/fb3-oo-api

Is the OO API complete ? I think very strange to still have to build
DPB by hand... Can you expose something that may give access to the
ClumpletWriter to ease that ?

At least, I can create and drop a database ;-) But I would be able to
set up more complex fields like the default dialect, the page size and
the default character set.

Regards,

--
Pierre Yager

On Mon, Nov 28, 2011 at 8:55 PM, Pierre Y.
<[hidden email]> wrote:

>> g++ -Wall -I../../src/include -lfbclient -o libUdrCppExample.so -fPIC
>> UdrCppExample.cpp ../../gen/Debug/firebird/plugins/libudr_engine.so -shared
>
> Thank you Alex for the answer. It compiled ! I don't know how to test
> if it works, but it compiled ;-)
>
> Next I want to compile a VERY simple piece of code, a kind of
> 'fb_get_master_interface hello world' :
>
> $ cat firetest.cpp
> #include "ibase.h"
> #include "firebird/Interface.h"
>
> int main()
> {
>  Firebird::IMaster *master;
>  master = fb_get_master_interface();
>  return master != NULL;
> }
>
> I tried to compile with :
>
> $ LC_ALL=3DC g++ -Wall -I../firebird/src/include -lfbclient -o firetest
> -fPIC firetest.cpp
> /tmp/cc4TW3Oa.o: In function `main':
> firetest.cpp:(.text+0x9): undefined reference to `fb_get_master_interface'
> collect2: ld returned 1 exit status
>
> Can you give me some hints again to go a step further ?
>
> Regards,
>
> --
> Pierre Yager
>

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Alex Peshkoff
 On 11/29/11 02:53, Pierre Y. wrote:

> Alex,
>
> I think I found the problem : -lfbclient can't find libfbclient.so
> I added /opt/fb3cs/lib to ldconfig.conf.d but it don't changes anything.
>
> Finally I changed the compile command to :
>
> $ LC_ALL=C g++ -Wall -I../firebird/src/include -o firetest -fPIC
> firetest.cpp /opt/fb3cs/lib/libfbclient.so
>
> And it worked like a charm.
>
sooner of all you have old libfbclient somewhere
> Now I started playing with the new API. I created a project on github for it :
>
> https://github.com/zedalaye/fb3-oo-api
>
> Is the OO API complete ?

not 100%
main missing part is C++ wrapper to access results of query or
parameters easily for unknown in advance SQL operator.

> I think very strange to still have to build
> DPB by hand... Can you expose something that may give access to the
> ClumpletWriter to ease that ?

Probably it's worth thinking about it, but IMHO building parameters
block is not critical from API point of view.

> At least, I can create and drop a database ;-) But I would be able to
> set up more complex fields like the default dialect, the page size and
> the default character set.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Mark Rotteveel-2
On Tue, 29 Nov 2011 11:19:27 +0400, Alex Peshkoff <[hidden email]>
wrote:
>> I think very strange to still have to build
>> DPB by hand... Can you expose something that may give access to the
>> ClumpletWriter to ease that ?
>
> Probably it's worth thinking about it, but IMHO building parameters
> block is not critical from API point of view.

But it does add to to the userfriendliness of that API; which I think is
an important consideration.

Mark

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Alex Peshkoff
 On 11/29/11 12:23, Mark Rotteveel wrote:
> On Tue, 29 Nov 2011 11:19:27 +0400, Alex Peshkoff <[hidden email]>
> wrote:
>>> I think very strange to still have to build
>>> DPB by hand... Can you expose something that may give access to the
>>> ClumpletWriter to ease that ?
>> Probably it's worth thinking about it, but IMHO building parameters
>> block is not critical from API point of view.
> But it does add to to the userfriendliness of that API; which I think is
> an important consideration.

OK, it there will not be any voices against this, we will do that.
Adding interface to build PB is very simple task.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Pierre Y.
>>>> I think very strange to still have to build
>>>> DPB by hand... Can you expose something that may give access to the
>>>> ClumpletWriter to ease that ?
>>> Probably it's worth thinking about it, but IMHO building parameters
>>> block is not critical from API point of view.
>> But it does add to to the userfriendliness of that API; which I think is
>> an important consideration.
>
> OK, it there will not be any voices against this, we will do that.
> Adding interface to build PB is very simple task.

THANK YOU very much !

--
Pierre Yager

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Pierre Y.
Hi,

I advanced a bit more with this new API but I just absolutely don't
see how to deal with FbMessage. What is it ? How do I have to use it
to access (or send ?) data ?

Thank you for your help, Regards,

--
Pierre Yager

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Alex Peshkoff
 On 12/02/11 11:26, Pierre Y. wrote:
> Hi,
>
> I advanced a bit more with this new API but I just absolutely don't
> see how to deal with FbMessage. What is it ? How do I have to use it
> to access (or send ?) data ?
>
> Thank you for your help, Regards,


There is a way to create FbMessage, using boost macros - more or less
like it's done in UDR engine samples. But there is unfortunately still
no sample of using it exactly like you want. And even that boost macros
are not SQLDA. Something similar to SQLDA is in our todo plans.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Adriano dos Santos Fernandes-3
In reply to this post by Pierre Y.
On 02/12/2011 05:26, Pierre Y. wrote:
> Hi,
>
> I advanced a bit more with this new API but I just absolutely don't
> see how to deal with FbMessage. What is it ? How do I have to use it
> to access (or send ?) data ?
>
>
https://github.com/asfernandes/fbstuff/blob/master/src/test/v3api/StaticMessageTest.cpp


Adriano


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Pierre Y.
>> I advanced a bit more with this new API but I just absolutely don't
>> see how to deal with FbMessage. What is it ? How do I have to use it
>> to access (or send ?) data ?
>>
>>
> https://github.com/asfernandes/fbstuff/blob/master/src/test/v3api/StaticMessageTest.cpp

Thank you Adriano. I think I understood the concept, for now, it is
necesseary to derive FbMessage and create static structures to map the
input parameters and the output parameters.

But... it seems to be very complex, can you explain why do you have to
generate BLR code at several places ? What is actually in FbMessage
returned by attachment->execute(...&out) ?

Many thanks for your help, I really want to understand.

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Adriano dos Santos Fernandes-3
On 02/12/2011 14:49, Pierre Y. wrote:

>>> I advanced a bit more with this new API but I just absolutely don't
>>> see how to deal with FbMessage. What is it ? How do I have to use it
>>> to access (or send ?) data ?
>>>
>>>
>> https://github.com/asfernandes/fbstuff/blob/master/src/test/v3api/StaticMessageTest.cpp
> Thank you Adriano. I think I understood the concept, for now, it is
> necesseary to derive FbMessage and create static structures to map the
> input parameters and the output parameters.
>
> But... it seems to be very complex, can you explain why do you have to
> generate BLR code at several places ? What is actually in FbMessage
> returned by attachment->execute(...&out) ?
>
> Many thanks for your help, I really want to understand.
>
>
The thing is that this is how Firebird really always worked at the
provider level.

What this example show us:

1) It's easy to construct messages of know format with macros. It's
still not completely elegant, so if anyone has a suggestion...

2) It's possible to construct dynamic messages, but we should improve this.


Adriano


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|

Re: The new Firebird OO API

Alex Peshkoff
In reply to this post by Pierre Y.
В Пт., 02/12/2011 в 17:49 +0100, Pierre Y. пишет:

> >> I advanced a bit more with this new API but I just absolutely don't
> >> see how to deal with FbMessage. What is it ? How do I have to use it
> >> to access (or send ?) data ?
> >>
> >>
> > https://github.com/asfernandes/fbstuff/blob/master/src/test/v3api/StaticMessageTest.cpp
>
> Thank you Adriano. I think I understood the concept, for now, it is
> necesseary to derive FbMessage and create static structures to map the
> input parameters and the output parameters.
>
> But... it seems to be very complex, can you explain why do you have to
> generate BLR code at several places ?

Treat that BLR code as description of message format, which can be
safely passed across the wire between various architectures (that's Byte
stream) andb is easily understood by fb engine.

> What is actually in FbMessage
> returned by attachment->execute(...&out) ?

Values for fields, present in that message, and NULL flags for them.



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel