design question

M

Matt Kowalczyk

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top