Implementing an I/O wrapper and Parser (console project)

Discussion in 'C++' started by Rahtgaz, Nov 9, 2006.

  1. Rahtgaz

    Rahtgaz Guest

    Hello everyone,

    I'm wanting to start implementation of a pet project game IO mechanism.

    The game is console based. A cross between MUD and Rogue types. For I/O
    operations I'll be using ncurses (PDCurses to be accurate). Mainly
    taking advantage of colors in the console and wanting to minimize any
    work in porting it to Linux and Mac.

    What I'm thinking doing is designing two singletons CPrompt, CParse.

    CPrompt - responsible for I/O operations. It wraps ncurses
    functionality, accepts input from the user, sends to CParse. Receives
    input from various objects and formats to screen.

    CParse - Parses commands, returns error or sends to correct objects for

    Various objects (the game engine) - Receive processing requests from
    CParse and send results back to CPrompt for output.

    However, I'm not sure of this design on a few points:

    1. CPrompt is supposed to wrap ncurses functionality, but by having
    the various object communicate directly to it, I'll be forced to provide
    ncurses functionality on the objects themselves. Or probably complicate
    my code by sending to CPrompt also the output format requirements. What
    do you suggest?

    2. CParse seems to be doing too much; parsing the input and deciding
    on which objects to call. Is it better to provide some form of messaging
    system between CParse and the objects? And how would this be
    implemented. Links to reading material (books or web) would be enough if
    you don't want to spend much time discussing this point.

    3. By making CPrompt and Cparse singletons I'm thinking on the need
    of having these two object in memory at all times. There is of course
    only one prompt. But CParse is less obvious as a good candidate for a
    singleton class. It's the fact that it will be staying in memory at all
    times that moves me into making it a singleton. However, should it be
    ever-present? Is it more logical to have it be destroyed after each

    I would appreciate your help on this. Understanding the programming
    language is becoming less of a challenge as time moves on, but applying
    this knowledge is the real challenge.

    Best regards.
    Rahtgaz, Nov 9, 2006
    1. Advertisements

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. raffaele castagno

    Implementing a console (CLI) in java

    raffaele castagno, Oct 7, 2004, in forum: Java
    Raffaele Castagno
    Oct 8, 2004
  2. Ben Finney
    Egor Bolonev
    Jun 30, 2003
  3. Egor Bolonev
    Egor Bolonev
    Jun 30, 2003
  4. Serge Terekhoff
    Serge Terekhoff
    Jun 30, 2003
  5. Replies:
    James Kanze
    Mar 4, 2008

Share This Page