Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

c++.cpp

Go to the documentation of this file.
00001 
00014 /*
00015  *  The contents of this file are subject to the Mozilla Public License
00016  *  Version 1.0 (the "License"); you may not use this file except in
00017  *  compliance with the License. You may obtain a copy of the License
00018  *  at http://www.mozilla.org/MPL/
00019  *
00020  *  Software distributed under the License is distributed on an "AS IS"
00021  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00022  *  the License for the specific language governing rights and
00023  *  limitations under the License.
00024  *
00025  *  The Original Code is legOS code, released October 17, 1999.
00026  *
00027  *  The Initial Developer of the Original Code is Markus L. Noga.
00028  *  Portions created by Markus L. Noga are Copyright (C) 1999
00029  *  Markus L. Noga. All Rights Reserved.
00030  *
00031  *  Contributor(s): Markus L. Noga <markus@noga.de>
00032  */
00033 
00034 #include <conio.h>
00035 #include <unistd.h>
00036 #include <dsound.h>
00037 
00039 class StateChanger {
00040 public:
00041   virtual void setState(bool state) {
00042     if(state)
00043       enable();
00044     else
00045       disable();
00046   }
00047 
00048   virtual void enable()  = 0;
00049   virtual void disable() = 0;
00050 
00051   void onOff();
00052 };
00053 
00055 class DisplayState : public StateChanger {
00056 public:
00057   void enable() {
00058     cputs("on");
00059   }
00060 
00061   void disable() {
00062     cls();
00063   }
00064 };
00065 
00066 #ifdef CONF_DSOUND
00067 
00068 class SoundState : public StateChanger {
00069 public:
00070   void enable() {
00071     dsound_system(DSOUND_BEEP);
00072   }
00073 
00074   void disable() {
00075   }
00076 };
00077 #endif // CONF_DSOUND
00078 
00079 void StateChanger::onOff() {
00080   setState(1);
00081   sleep(1);
00082   setState(0);
00083   sleep(1);
00084 }
00085 
00086 int main(int argc, char **argv) {
00087   StateChanger *s;
00088 
00089   s=new DisplayState;
00090   s->onOff();
00091   delete s;
00092 
00093 #ifdef CONF_DSOUND
00094   s=new SoundState;
00095   s->onOff();
00096   delete s;
00097 #endif // CONF_DSOUND
00098 
00099   return 0;
00100 }

Generated on Fri Feb 25 08:02:34 2005 for brickos by  doxygen 1.3.9.1