Question about basic input output.

K

Key9

Question about basic input output.


HI All
I am a new C++er

Suppose I am designing a i/o device .

system have screens .
system have keyboards.
=======================

class char_signal;

class Input;
class Output;

class Keyboard : public Input{
public:
virtual void operation>>(char_signal&) ;

virtual void pressed_actions();
protected:
void keyPress(char_signal);
};


class Screen : public Output{
public:
virtual void operation<<(char_signal&);
};

****
//may be later

class Tcp_Keyboard : public Keyboard;
class Tcp_Screen : public Screen;



Q1 : So what I need is associate these class with std's istream / ostream.
but how? :p

especially may be I will use a TCP connection or a file as i/o source?
sorry for my std zero experience.


Q2 : Suppose I want input a key and display to both of screen :
//<----file main.cpp

Screen SCR1;
Screen SCR2;
Keyboard Kbd1;

int main(){

"cycle step"{
input_char = read_a_char(device); //

input_char >> Kbd1;
//Kbd1 can do his action;
SCR1 << input_char;
SCR2 << input_char;
}
}

how can I use such a "cycle step" to monitor keyboard with better
performance?
I DON'T want a "while(true)" structure here, so I should use a thread based
keyboard? or better idea?
How I can keep program "cycle" will not exit?
Does design a monitor(watch dog) thread works? and what's the roadmap?


Q3 : Any similar source code you known ?

Thank you very much.
your
key9
 

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,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top