CTCLFileHandler

Name

CTCLFileHandler --  Base class for building object oriented Tcl File event handlers.

Synopsis


#include <TCLFileHandler.h>
...

class CTCLFileHandler  : public CTCLInterpreterObject
{
  CTCLFileHandler(CTCLInterpreter* pInterp,
                   UInt_t am_nFid = STDIN_FILENO);
  CTCLFileHandler(CTCLInterpreter* pInterp,
                  FILE* pFile);
  CTCLFileHandler (const CTCLFileHandler& aCTCLFileHandler );
  ~CTCLFileHandler ( );
  CTCLFileHandler& operator= (const CTCLFileHandler& aCTCLFileHandler);
  int operator== (const CTCLFileHandler& aCTCLFileHandler) const;

  UInt_t getFid() const;

  virtual   void operator() (int mask)   = 0;

  void Set (int mask)  ;
  void Clear ()  ;
};

    

DESCRIPTION

Tcl supplies an event loop. It is possible to add events specifications to this loop. One very useful event type is based on readability or writability of a file descriptor. The CTCLFileHandler allows you to create an object oriented file handler, and register it with the event loop so that you can gain control when, for example, a file becomes readable.

As CTCLFileHandler is an abstract base class, it is necessary to create a derived class. The derived class should implement the operator() which will be called when the specific event is fired. An instance of this derived class should be created, and then the Set and Clear members used to establish and remove the event handler.

METHODS


  CTCLFileHandler(CTCLInterpreter* pInterp,
                   UInt_t nFid = STDIN_FILENO);
  CTCLFileHandler(CTCLInterpreter* pInterp,
                  FILE* pFile);
  CTCLFileHandler (const CTCLFileHandler& aCTCLFileHandler );
        

Constructs a file handler object. pInterp is a pointer to the interpreter on which the file handler will be registered. The file can be specified either by nFid, a file descriptor, or pFile an stdio File stream pointer.

A copy constructor allows the creation of a copy of the file handler object given aCTCLFileHandler an existing one. This is normally not useful.


  CTCLFileHandler& operator= (const CTCLFileHandler& aCTCLFileHandler);
  int operator== (const CTCLFileHandler& aCTCLFileHandler) const;
            

These functions support assignment and equality comparison. Note that these functions are usually not very useful for file handlers.


  UInt_t getFid() const;
        

Returns the file id that is associated with the event.


  virtual   void operator() (int mask)   = 0;
            

The user's derived class must override this to provide the desired funtionality when event fires. mask indicates which event fired the function and can be an or of the following: TCL_READABLE if the file can be read without blocking, TCL_WRITABLE if the file can be written without blocking, or TCL_EXCEPTION if some exceptional condition occured on the file.


  void Set (int mask)  ;
  void Clear ()  ;
        

Set establishes the event handler for the set of conditions described in mask. The valid bits for mask, are described in the documentation for the mask parameter to operator().

SEE ALSO

CTCLObject(3), CTCLInterpreter(3) Tcl_CreateFileHandler(3tcl), Tcl_DeleteFileHandler(3tcl)