proj home

Files   Classes   Functions   Hierarchy  

keyboard.cpp

Go to the documentation of this file.
00001 
00002 #include <cassert>
00003 #include <iostream>
00004 #include <complex>
00005 #include <sstream>
00006 using namespace std;
00007 
00008 #include <rawinterpreter.h>
00009 #include <scopedependentfunctions.h>
00010 
00011 
00012 #include <keyboard.h>
00013 
00014 
00015 
00016 
00017 class fprint
00018 {
00019   keyboardinterface& x;
00020 public:
00021 
00022   fprint(keyboardinterface& x_) 
00023     : x(x_) {}
00024 
00025   void operator()()
00026     { x.print(); }
00027 };
00028 
00029 keyboardinterface::keyboardinterface
00030 (
00031   string const initinput 
00032 )
00033 {
00034   // Initialiazation
00035 
00036   rpnprogramstackstate().init();
00037 
00038   inputstatescope inscp;
00039   SingletonPtr<inputstatescope> init(&inscp);
00040 
00041   initscopedependentfunctions();  
00042 
00043   // Callback to print(); 
00044   fprint prnt(*this); 
00045 
00046 
00047   stringstream ss(initinput.c_str());
00048   SingletonPtr<inputstatescope>()->fd.process2_silent(ss);
00049 
00050   prnt();
00051 
00052   SingletonPtr<inputstatescope>()->fd.process2(cin,prnt);
00053 
00054 }
00055 
00056 void keyboardinterface::print()
00057 {
00058   bool found(false);
00059   string path;
00060   
00061   rpnprogramstackstate().findprogram(
00062     found,path,rpnprogramstackstate().ps->front() );
00063   if (!found)
00064     path = "";
00065   cout << path << " ";
00066 
00067   deque<rpnbase*>& ds = rpnprogramstackstate().ds();
00068   cout << "size=" << ds.size();
00069   cout << "   depth=" << rpnprogramstackstate().ps->size();
00070 
00071   cout << endl;
00072 
00073 
00074   if (ds.empty())
00075     return;
00076 
00077   unsigned int const imax = 10;
00078   for (unsigned int i=min(ds.size(),imax); i>0; )
00079   {
00080     --i;
00081     cout << i << ": " << ds[i] << endl;
00082   }
00083   cout << "@";
00084   if (SingletonPtr<inputstatescope>()->evalimmediate)
00085     cout << "+ ";
00086   else
00087     cout << "- ";
00088 }
00089 
00090 

Generated on Fri Mar 4 00:49:30 2011 for Chelton Evans Source by  doxygen 1.5.8