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

R

Rahtgaz

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
processing.

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
parsing?


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.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top