Re: Problem with function pointers and structures



Simon Connah <simon.connah@xxxxxxxxxxxxxx> wrote:
On 2009-07-02 21:13:20 +0100, jt@xxxxxxxxxxx (Jens Thoms Toerring) said:

As far as I understood you this should be a pointer to the structure
with the function pointers. Then you would need here

user_interface *interface;

} user;

The you can do in the C code

user_interface ifc = { add, delete, edit );
user a_user;

a_user.interface = &ifc;

a_user.interface->add( PGconn_arg1, &a_user );

etc. Is it that what you're planning to do?

Yeah that is pretty much the plan.

I'm basically looking for a way to achieve some level of data
abstraction with my library so that client applications can perform
certain tasks on data without having to know specific implementation
details specifically the layout of the structures in use.

The real issue is to expose a public interface for manipulating the
structures which is sufficiently general to allow radical redesign of
the underlying implementation without requireing programs to be
rewritten to take advantage of new or improved code.

To me it looks a bit as if you're still in a design stage of your
project. There are still a lot of words like "some level", "certain
tasks", "sufficiently general" etc. in your problem description
that make it rather difficult to decide on a certain way of how to
implement things.

While it would most likely be easier in an object orientated language,
it is more fun in C.

It looks as if you intent to use some OO techniques implemented
in C. That definitely could be a way to go. But if it is I can't
deduced from what you have posted. All what's rather clear is
that you seem to have some "users" (perhaps going to be stored in
a database if I interpret the 'PGconn' variable correctly - it
looks a bit like you intent to use PostgreSQL and, if that's the
case, you might want to think about the question if there isn't
a way to write your program to not bind on a certain database)
to be added, changed or deleted. But that's about all what one
(or at least I) can deduce from what you've posted. But I guess
what the "client application' is going to be that has to do
"certain tasks" remains a mystery for everyone but you, so
commenting on that (and especially on how exactly to do it)
is a bit difficult.

Perhaps it would be advantageous to concentrate on the design
at the moment and not to worry too much about how to implement
it in C (or another language) at this stage. You may end up not
using C if it is to be too cumbersome for what you want to do,
or arrive at questions that are easier to answer;-)

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.



Relevant Pages

  • Re: Amazing LINQ for .Net
    ... > ...but you have to realize the intent. ... > database language into C#. ... > database for defining views. ... of logic to get these objects for you from the total set of objects. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Parsing Mail Messages
    ... Step 1: Grab the appropriate message ... The intent here is to call this from an Outlook rule. ... If necessary, this can be to a delimited text file, but preferably it would be to a database. ... grep wrote: ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: PARTIAL display of recordset in form
    ... When I opened a copy of the database on my home computer, ...
    (microsoft.public.access.forms)
  • Re: READ ONLY
    ... to work and do some fine tuning, however it opens up in the READ ONLY mode... ... I've copied the tables and forms to a "new" database file so I could continue to work on the design, the problem is, when I save the .mdb file to disk I get another READ ONLY message at home and have to re-create the database... ... how can I stop this madness and turn off the READ ONLY during the design stage of the database then turn it back on once I've got things setup? ...
    (microsoft.public.access.gettingstarted)
  • Re: "His Haydn was incomparable."
    ... unless a composer left notes about his intent or was ... We can deduce his intent. ... Are you suggesting that all artists work in a vacuum? ...
    (rec.music.classical.recordings)