C++ Manager Class

closed account (S6k9GNh0)
Not the employee manager but an actual manager class that manages something...


So I have this class: Manager.

This class manages a class called: Session.

Now, each time I create a new Session, I'd use something like: myManager.createSession("my.server.com");

The problem with this is that when I need to reference the session again at any time through the manager, I don't have any clean way to do it. My thoughts so far has gone to:
1
2
myManager.getSession("my.server.com");
which will use a map. Another method would be to return a handle or something:
1
2
SessionHndl tmpHndl = myManager.createSession("my.server.com");
myManager.getSession(tmpHndl);
which proposes the problems of getting the session globally and also looking terribly ugly and rather C-like. So, for those who can pick up my brain waves, any thoughts?
Last edited on
I'm not sure why you'd need a getSession function.

Instead of keeping track of the name of the session ("my.server.com") or a handle to the session, why don't you just keep a Session*?

1
2
3
4
Session* s = myManager.createSession("my.server.com");

// no need for a get function, you already have the session
s->DoWhatever();
closed account (S6k9GNh0)
o. Not sure why this stuff has been lapsing my mind as of late....
Topic archived. No new replies allowed.