FSh.h

Go to the documentation of this file.
00001 #ifndef __FSH_H__
00002 #define __FSH_H__
00003 
00004 /*
00005 
00006 $Header$
00007 
00008 */
00009 
00010 #include "pcrecpp.h"
00011 #include "Service.h"
00012 #include "TcpConnection.h"
00013 #include "FShGetLine.h"
00014 #include "Telnet.h"
00015 #include "Registry.h"
00016 
00017 static const char *const NAME_FSH = "fsh";
00018 static const char *const MAN_FSH  = "\
00019 Service <service>fsh</service> is a <keyword>Forth Shell</keyword>. That is what you are \
00020 working with right now. To see all the available <keyword>Forth</keyword> words say <word>words</word>. \
00021 To discover what a cool thing <keyword>Forth</keyword> is go to <url>http://www.forth.org.ru</url>. \
00022 ";
00023 
00024 // Registry manuals.
00025 
00026 static const char *const MAN_FSH_COLORS_ON = "\
00027 <registry>bool fsh.colors.on(true)</registry>\n\n\
00028 Turn on and off colored output in the Forth shell (<service>fsh</service> service). \
00029 It is a global property. It affects all Forth shells in the system.\
00030 ";
00031 
00032 static const char *const MAN_FSH_LOG = "\
00033 <registry>bool fsh.log.errors.on(false)</registry>\n\
00034 <registry>String fsh.log.errors.regexp()</registry>\n\
00035 <registry>bool fsh.log.warnings.on(false)</registry>\n\
00036 <registry>String fsh.log.warnings.regexp()</registry>\n\
00037 <registry>bool fsh.log.debug.on(false)</registry>\n\
00038 <registry>String fsh.log.debug.regexp()</registry>\n\n\
00039 Entries <registry>fsh.log.*.on</registry> turn on and off \
00040 logs printing to a Forth shell. <registry>fsh.log.*.regexp</registry> \
00041 allow to filter those logs. See man page for word <word>GREP</word> \
00042 for <keyword>regular expressions</keyword> explanation. \
00043 These are private properties. They affect only the Forth shell they belong to.\
00044 ";
00045 
00046 using namespace pcrecpp;
00047 
00048 class FSh : public Service<FSh>
00049 {
00050 
00051 friend class Service<FSh>;
00052 friend class FShGetLine;
00053 
00054   PYLON_OBJECT
00055 
00056 public:
00057 
00058   inline
00059   static String NAME();
00060 
00061   inline
00062   static String MANUAL();
00063 
00064 protected:
00065 
00066   FSh(const ValueList &params);
00067   virtual ~FSh();
00068 
00069 private:
00070 
00071   int start();
00072 
00073   SLOT(dataReady);
00074   SLOT(die);
00075 
00076   SLOT(setColorEnabled, const bool &yes);
00077 
00078   SLOT(setLogErrorsEnabled, const bool &yes = true);
00079   SLOT(setLogErrorsRegexp, const String &re);
00080 
00081   SLOT(setLogWarningsEnabled, const bool &yes = true);
00082   SLOT(setLogWarningsRegexp, const String &re);
00083 
00084   SLOT(setLogDebugEnabled, const bool &yes = true);
00085   SLOT(setLogDebugRegexp, const String &re);
00086 
00087   SLOT(logError, const String &timestamp, const String &fileName,
00088                  const unsigned int lineNum, const String &functionName, const String &msg);
00089   SLOT(logWarning, const String &timestamp, const String &fileName,
00090                    const unsigned int lineNum, const String &functionName, const String &msg);
00091   SLOT(logDebug, const String &timestamp, const String &fileName,
00092                  const unsigned int lineNum, const String &functionName, const String &msg);
00093 
00094   REGISTRY(bool, colors__on, true, MAN_FSH_COLORS_ON);
00095 
00096   REGISTRY_PRIVATE(bool,   log__errors__on,       true,  MAN_FSH_LOG);
00097   REGISTRY_PRIVATE(String, log__errors__regexp,   "",    MAN_FSH_LOG);
00098   REGISTRY_PRIVATE(bool,   log__warnings__on,     false, MAN_FSH_LOG);
00099   REGISTRY_PRIVATE(String, log__warnings__regexp, "",    MAN_FSH_LOG);
00100   REGISTRY_PRIVATE(bool,   log__debug__on,        false, MAN_FSH_LOG);
00101   REGISTRY_PRIVATE(String, log__debug__regexp,    "",    MAN_FSH_LOG);
00102 
00103   TcpConnection *_connection;
00104   FShGetLine *_getLine;
00105   Telnet *_telnet;
00106 
00107   bool _logErrors;
00108   RE _logErrorsRe;
00109 
00110   bool _logWarnings;
00111   RE _logWarningsRe;
00112 
00113   bool _logDebug;
00114   RE _logDebugRe;
00115 };
00116 
00117 inline
00118 String FSh::NAME()
00119 {
00120   return NAME_FSH;
00121 }
00122 
00123 inline
00124 String FSh::MANUAL()
00125 {
00126   return MAN_FSH;
00127 }
00128 
00129 #endif

Generated on Thu Sep 6 20:11:25 2007 for Pylon Application Platform by  doxygen 1.5.1