Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EventLogger.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_EventLogger_h_
00003 #define INCLUDED_EventLogger_h_
00004 
00005 #include "ControlBase.h"
00006 #include "Events/EventListener.h"
00007 #include <fstream>
00008 
00009 class FilterBankGenerator;
00010 class BehaviorBase;
00011 
00012 //! allows logging of events to the console or a file
00013 class EventLogger : public ControlBase, public EventListener {
00014 public:
00015   //!constructor
00016   EventLogger();
00017   virtual ~EventLogger();
00018 
00019   //!opens a custom (embedded) menu to toggle individual EGIDs
00020   virtual ControlBase* doSelect();
00021   
00022   virtual void refresh();
00023 
00024   //!sends all events received to stdout and/or logfile
00025   virtual void processEvent(const EventBase& event);
00026 
00027   //!returns #logSocket
00028   static class Socket* getLogSocket() { return logSocket; }
00029   
00030   //! returns #port
00031   static int getLogSocketPort() { return port; }
00032   
00033   //! sets #port
00034   static void setLogSocketPort(int p) { port=p; }
00035 
00036   //! send the current camera image over the log socket
00037   static void logImage(FilterBankGenerator& fbg, unsigned int layer, unsigned int channel, const BehaviorBase* source=NULL);
00038 
00039   //! send a string over the log socket
00040   static void logMessage(std::string msg, const BehaviorBase* source=NULL, const char* icon=NULL, unsigned int placement=0);
00041   
00042   //! request that the desktop side take a picture with the webcam (if available)
00043   static void logWebcam(const BehaviorBase* source=NULL);
00044   
00045 protected:
00046   virtual void clearSlots();
00047 
00048   //!sets the status char of slot @a i to @a c
00049   void setStatus(unsigned int i, char c);
00050 
00051   //!checks to see if logfilePath differs from the StringInputControl's value and switches it if it is
00052   void checkLogFile();
00053   
00054   //!address of the logfile, if any (empty string is no logfile)
00055   std::string logfilePath;
00056 
00057   //!if a filename is given, events are logged to here
00058   std::ofstream logfile;
00059   
00060   //! events which are logged will be sent over this port in an xml format.  See eventlog.dtd in the docs directory
00061   static class Socket* logSocket;
00062   
00063   //! port number #logSocket will listen on
00064   static int port;
00065   
00066   //! reference count for #logSocket -- when this hits 0, close the socket
00067   static unsigned int logSocketRefCount;
00068   
00069   //!controls the level of verbosity - currently 0 through 2
00070   unsigned int verbosity;
00071 };
00072 
00073 /*! @file
00074  * @brief Describes EventLogger, which allows logging of events to the console or a file
00075  * @author ejt (Creator)
00076  *
00077  * $Author: ejt $
00078  * $Name: tekkotsu-2_4_1 $
00079  * $Revision: 1.7 $
00080  * $State: Exp $
00081  * $Date: 2005/06/01 05:47:44 $
00082  */
00083 
00084 #endif

Tekkotsu v2.4.1
Generated Tue Aug 16 16:32:46 2005 by Doxygen 1.4.4