design question

Discussion in 'C Programming' started by Matt Kowalczyk, Mar 28, 2006.

  1. I have defined as structure to expose some functionality:

    typedef struct {
    /* methos */
    irc_session_t* (*get_session) (const char* irc_server);
    void (*add_session) (irc_session_t* session);
    int (*contains_session) (const char* irc_server);

    } IRCConnectionManager;

    After proprely initializing an IRCConnectioManager, the above functionality
    should be implemented.

    My question is, how can I maintain the underlining data structure for an
    IRCConnectionManager? I was thinking that I could use a GHashTable which would
    map a irc_server string to a irc_session_t structure. Could someone assist me
    in defining a .h and .c file for this to work? I would like the implementation
    of an IRCConnectionManager to be hidden from anyone using it. e.g. I do not want
    to expose the GHashTable. I basically want to add some hidden members to the
    IRCConnectionManager class. One of these would be the GHashTable.

    Here is what I am trying to accomplish:

    IRCConnectionManager* conn_manager = init_conn_manager();

    client->create_connection(conn_manager, "irc.server.com");

    The create_connection function would call get_session on the conn_manager and
    essentially add the string "irc.server.com" to the hashtable.

    Thanks,
    Matt
    Matt Kowalczyk, Mar 28, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ZackS
    Replies:
    5
    Views:
    6,784
    Just an Illusion
    Jul 9, 2004
  2. SpamProof
    Replies:
    3
    Views:
    638
    SpamProof
    Dec 1, 2003
  3. dave
    Replies:
    5
    Views:
    582
    William Brogden
    Jul 17, 2004
  4. Tim Smith
    Replies:
    2
    Views:
    845
    Tim Smith
    Dec 15, 2004
  5. Bartholomew Simpson

    class design/ design pattern question

    Bartholomew Simpson, Jun 12, 2007, in forum: C++
    Replies:
    2
    Views:
    443
    Daniel T.
    Jun 12, 2007
Loading...

Share This Page